I recently had an ENVI-R wireless power monitor installed, and I set it up to record data to an always-on Ubuntu Linux box I have sitting around using MRTG. The setup required a fair bit of scripting in Perl, Bash, and a couple of extra bits of software.
This post is the first in a series outlining just how I set up the monitor and what was required.
The ENVI-R and accessories
I bought the ENVI-R unit in a pack which included the transmitter, a receiver LCD display, power supply and one current clamp. I also bought an additional two current clamps and the USB connector cable for the receiver.
The USB connector is actually a specially wired Prolific PL2303 USB to RS232 serial port adapter, with an RJ45 connector on the end. I don’t know the exact pinout, but that’s not required. Anyway, the adapter “just works” with Ubuntu 10.10.
Each transmitter unit can handle up to three current clamps, and one receiver can handle up to ~10 transmitters. I didn’t want to buy additional transmitters, and there isn’t a huge amount of space in my switchboard, so I just got an additional two current clamps bringing me to three. That allows for the monitoring of up to three loads.
The clamps themselves are no-contact types, and go around the active wire of whatever feed you want to monitor. They should be clamped entirely around the wire so that the ferrite core of the clamp encircles the active wire. The clamp operates by picking up the EM field around the active wire as current passes.
Be aware that the clamp cannot identify the direction that current is flowing. This isn’t a problem in the case of a house like mine that has no solar power, but if you have solar power you’ll want to install a clamp onto the feed coming from the solar cells, and then put your main power clamp after the location where the solar power feed connects to your main feed.
In my case, my electric hot water is on a different circuit from the main power, so the three clamps were connected as so;
- Main power: Clamp connected after main breaker, between breaker and switchboard. Registers all power going into the house (except hot water)
- Lights: Clamp connected after breaker for the lights (I only have one).
- Hot water: Clamp connected after breaker for the hot water.
Be aware as well that the ENVI-R assumes if you have multiple clamps connected to one transmitter that you’re measuring 3-phase power, and it therefore just adds together all the currents. In the case of mains + hot water that’s OK, but since my “main” clamp is actually registering the sum of lights and everything else, it’ll over-read if the lights are on. For that reason, if you’re setting up like me, don’t trust the display, use the serial data feed.
ENVI-R Receiver Installation
The receiver is pretty straightforward, and it’s just plugged in, and then the USB serial cable is hooked up. I’ll run through the software to actually interpret the data in a useable format for MRTG later.
The ENVI-R communicates at 57600 8N1 speed. If you want to just see the raw output, run this command from the command line;
$ stty -F /dev/ttyUSB0 speed 57600
$ cat /dev/ttyUSB0
You should see, about once every five seconds, output something like this;
CC128-v1.31 00022 22.0 0 03322 1 00000 00291 00000
If you do, great. The ENVI-R is all hooked up. Note that it also monitors temperature, and that temperature is the temperature of the receiver. Note, if you don’t have a transmitter attached, you won’t see any output from the ENVI-R at all.
For this kind of thing, most people seem to use Cacti. While it’s definite that Cacti can do more, the box I’m using has very limited memory, so I need to keep the number of running daemons to an absolute minimum. MRTG can run as a Cron job, and doesn’t require a database daemon to be running as well. For the small number of graphs I’m talking, Cacti is overkill.
In order to pass data to MRTG, I used a message broker written by IBM (Really Small Message Broker), since it does the job and it’s tiny. Then I wrote a couple of Perl scripts to handle converting the raw ENVI-R data into moving averages for MRTG to slurp up. So, the software required is;
- IBM’s RSMB or other MQTT-compatible message broker
- MRTG for generating the graphs
- A web server of some type. I used THTTPD, since it’s very small and fast.
- Perl. It’ll come with Ubuntu, but you will need a number of CPAN libraries.
If you get to this point, you should have a connected up ENVI-R with a few clamps, and it should be hurling data out to /dev/ttyUSB0 on your Linux recording box. Fantastic.
Now for the software….