Raspberry Pi with Adafruit.io using Python

For more advanced meter data users. Learn from others and ask questions about how to read meters, how to use the EKM Push Data, and how to display the meter data in useful ways.
Post Reply
Posts: 1
Joined: Mon Mar 01, 2021 5:19 pm

Raspberry Pi with Adafruit.io using Python

Post by georgeloyer »

This post is a celebration post of a working project after some great support from the EKM team. I am part of a nonprofit that built a public astronomical observatory in a state park, Sugarloaf Ridge, in Sonoma County, California. You can see the web site for our observatory at www.rfo.org. Robert Ferguson Observatory has a classroom in addition to the observatories under roll off roofs, and unlike the telescopes, the people in the classroom like to be warm at night! We've been using a propane wall heater but are considering a change to an all-electric heat pump system and are concerned that our 100A service will be enough to handle the 25A demand from the heater, especially when the coffee pots are turned on (can't do astronomy without coffee!).

We chose the Omnimeter I v.3 to monitor our 240V single phase main with a couple of 200A CTs. I wanted to use a Raspberry Pi to connect to the RS485 interface to collect the data and either report it to Adafruit.io or run a display in the observatory. At first I thought I could use EKM Dash to do this very simply and log in with VNC to see the display, but EKM Dash only works with x86 LInux versions. I'm most familiar with Python lately, so I chose to switch to that language and bought a simple USB to RS485 "converter" from Digikey. No dice with that, and I learned more about RS485 than I ever knew before. EKM uses data transfers in both directions so you really need the FTDI chip that EKM provides (if you don't want to roll your own) to enable the communication. Once I plugged that in, it just worked using the ekmmeters.py library.

Since the observatory is remote enough not to want to have to go there to reboot the Pi from time to time, I setup the python program, which you can clone from our git repository (https://github.com/vmoa/rfopower) as a standalone daemon called 'rfopower' that is set running with a shell script called run-rfopower.sh. That is configured with systemd on the Pi with the rfopower.services file that sets it up as a forked daemon that runs continuously and grabs EKM data every minute. With this configuration, if the system is rebooted, the rfopower daemon is automatically restarted as part of the boot process. I also set up the watchdog service so that if the Pi ever stops responding (stuck in a forever loop?) for 15 seconds, it reboots, so it should self-recover in most situations.

Since we have internet service via satellite, I decided the best display for the data was a public web site, and I was familiar with adafruit.io, so I set up this dashboard for the data: https://io.adafruit.com/georgel1/dashbo ... ic-service

I'm still actively developing so use the code at your own risk. The next thing I'm working on is figuring out what I want to display from the kWh data. This is already showing us how the observatory computer infrastructure is using power, as there is a regular daily update that wakes up all of the computers at about 2AM and doesn't calm down until close to 3AM. When the pandemic restrictions are dropped and we are allowed to open again, I'm looking forward to seeing how our power usage shows up during a public observing night when we have 200-300 people and 20 docents enjoying the night sky through the telescopes, listening to lectures, and drinking that coffee!

Glad to answer any questions about this project.
rfopower_example.png (117.13 KiB) Viewed 13925 times
Posts: 836
Joined: Fri Nov 04, 2011 7:42 pm
Location: Santa Cruz, CA

Re: Raspberry Pi with Adafruit.io using Python

Post by Jameson »

Hi George, thank you very much for posting this! And thank you for sharing your code so others can build upon what you are working on.

Did you ever figure out why the meter reported 60 volts initially? Seems like everything is working well now, and seems to be reliable. Good work!!
Post Reply