10/07/2019

The Lightning Detector 52pi and Me

So I've been spending some time with Raspberry Pi's lately.

Normally I like the Google Nest products.. and I still do a lot of that.. but their organizational changes and Googles habit of canceling things without warning has got me back in the mode of "Can I do this myself?"

I had been enthralled with the $5 PiZero for a couple years.. and barely got Teamviewer or VNC server to work on one.. mostly through x86 emulation.. and that was not easy.

This year I finally upgraded to RPi 3b+ just before the RPi 4 came out and got the Teamviewer 11 beta/prototype for linux armf (?) architecture to work.. and it was astoundingly good.


All that I wanted and none that I didn't want.. and it integrated into whatever contacts list I had for my personal or work teamviewer account.. really nice.

I'd experimented with DynDNS way back in the day to build a dynamic router that would bridge ports to services on things on a local lan out to the cloud.. but security and ISP stability pretty much killed that effort. Teamviewer handles a lot of that backend and now that its on Linux (Raspbian) it was just low effort and great.

Finding a case for the Rpi 3b+ I've been through Argon One, and several others settling on a layered "kit case" which sort of sand castle layers itself up from the backplane to however high you want.. I didn't need or want a Top since I planned to use these "hat" modules from 52pi.

So far I've got the Powerboard (has a CPU fan and GPIO pass-thru), a Four SPST relay board and a multiple Sensor board with three Temp sensors, Baromoter, Humidity, Light and Motion sensor all built into one board.  In general the are accessed from the command line over the i2c bus using standard tools like i2cset or i2cdetect ect.. they work great.


There is also a LORA board for GPS and GPRS (low speed Internet over cell radio) which I have but haven't popped a Google Fi sim into yet.. I think its not super fast.. not sure what I'll use it for.. a headless Teamviewer session to a console window? I dunno.

I got a Lightning Detector i2c board with a solderless QWIIC connector from Sparkfun and that has been working well.. but I hear from people its not reliable on the i2c bus.. I saw this.. but only when something else was on the bus.. they say its because the Clock SDA (or something) gets mixed up and can't be reset without powering down the board.. so they recommend SPI instead. I guess I'll have to look into that.. but.. on RPi I do have it working and its been generating a lot of data from passing storms.. the data looks genuine and good.

I just got Cacti setup and was starting to create a data source and graph for plotting the total number of strikes versus Time.

My goal is to use the Cacti Threshold plugin Trigger command feature to safeguard a DSL line by breaking the two wire connection to the ISP (and) switching off a USB controlled power monitor and surge protector.. while the RPi hides out behind all this attached to a good sized smart UPS with yet another USB connection to the RPi.. if either the strikes falls to zero.. or the UPS battery gets low.. the RPi can try to enable mains power to recharge the UPS before its totally out of power.

Its quite the project.. but we've had a well house and pump freeze and burst, a new refrigerator fail due to lightning and I've had many DSL routers literally "smoked" by lightning strikes.

I'm hoping this works out.. I couldn't find a cheap solution from Google, Home Depot or Lowes and nothing online that doesn't really work for the consumer.. only for something like a Data Center or a TV station.

As an example here is how to low effort manipulate the Relays:

pi@raspberrypi:~ $ i2cset -y 1 0x10 0x01 0xff  + On
pi@raspberrypi:~ $ i2cset -y 1 0x10 0x01 0x00 - Off

pi@raspberrypi:~ $ i2cset -y 1 0x10 0x02 0xff
pi@raspberrypi:~ $ i2cset -y 1 0x10 0x02 0x00

pi@raspberrypi:~ $ i2cset -y 1 0x10 0x03 0x00
pi@raspberrypi:~ $ i2cset -y 1 0x10 0x03 0xff

pi@raspberrypi:~ $ i2cset -y 1 0x10 0x04 0x00
pi@raspberrypi:~ $ i2cset -y 1 0x10 0x04 0xff


And to read all the Sensors with a simple command line C program:

root@raspberrypi:~# ./sensor

No external temperature sensor!
Current onboard sensor brightness = 784 Lux
Current onboard sensor temperature = 29 Celsius
Current onboard sensor humidity = 35 %
Current barometer temperature = 29 Celsius
Current barometer pressure = 100829 Pascal
Live body detected within 5 seconds!

I haven't really got into the LoRA board yet.. but it looks like fun:

These are available through GeeekPi and Amazon or direct from China for pretty low cost and the build quality is actually really nice.

There is a Wiki with samples for Bash, Python and Java or C examples programs and quite a bit of documentation.

52pi.com Hat Stack

I hope they're doing well because you need very little in the way of soldering skills to connect all the modules and start programming. Its nice to have simple snap together IoT  devices with "total control" from a Bash command line, script, or language.

Some of the details and a few instructions are lacking a character here or there.. but if they paid for a really good translator.. I'm sure it would raise the price of these really nice modules.