This simple perl script can be used to feed pachube with average power and temperature readings from CurrentCost Envi (CC128) which is connected with ASUS WL-500G router. No CurrentCost data cable necessary for this setup but some soldering is required.
This script works also with multiple sensors and multiple channels. It is tested with two sensors where one had three channels and another had one channel. You can add and remove any sensor or channel any time without restarting script itself. CC128 detects all changes and updates XML feed accordingly.
!!!WARNING!!! This is not compatible with CurrentCost Classic. Different data speed and cable is necessary.
There is also similar page how to connect CurrentCost Envi with CoreCard and using sns_Serial module.
!!!WARNING!!! This HOWTO is based on latest send_currentcost_to_pachube2.pl.
Please follow instructions in CurrentCost website how to install sensor jaws. Here is picture of my three phase setup
First you need to create a new input feed here. Use manual Feed type and any Feed title you like (this will be overwritten later by script anyway). After that you will see your new feed ID. This should be entered to $conf→{feedname}{id} variable in the beginning of script.
No CurrentCost data cable necessary. Instead cable can be soldered directly to WL-500G board. There are two serial ports available. I used second one (/dev/cua/1).
If you have CurrentCost Envi (CC128) then you need to connect it like this:
| CC128 pin | TIA/EIA-568-B Color | Function | WL-500G pin | ||
|---|---|---|---|---|---|
| 4 | Blue | GND | GND | ||
| 8 | Brown | RxD | UART_RX1 | ||
I soldered 2×4 pin male header directly to WL-500G board and then connected female connector with wires of normal Ethernet patch cable where one end is cut off. You can solder wires directly to board too if you like. Or install some socket to the WL-500G (RJ45 for example) and use use normal Ethernet patch cable.
Here are some pictures how I did it:
This setup is tested with OpenWrt KAMIKAZE (8.09.1, r16278). A lot of per modules should be installed and some even missing in package repository. I copied these missing modules from my desktop running opensuse 11.2.
Copy script to your server and change serialport to /dev/cua/1 and you are ready to go. If you are not able to install Device::SerialPort then just comment out lines which configure serial port and use stty or minicom to set up port speed (57600 8N1). I use minicom for that (set port speed and then CTRL-A Q).
You just need to keep this script running in background (or in screen session). You should see something like this:
root@openwrt:~# /root/send_currentcost_to_pachube2.pl CC128 data read: S:0 T:26.3 I:00467 C:1 3624 W C:2 172 W C:3 1311 W SUM 5107 W sending XML for 23434 .. sent CC128 data read: S:0 T:26.3 I:00467 C:1 4618 W C:2 182 W C:3 1317 W SUM 6117 W Data storage for 20 sec updates: I:0 N:CurrentCost network S:0 T:26.3 I:00467 C:1 4618 W (since last update: 21744 Ws, avg 3624 W) C:2 182 W (since last update: 1032 Ws, avg 172 W) C:3 1317 W (since last update: 7866 Ws, avg 1311 W) SUM 6117 W (since last update: 30642 Ws, sum 5107 W) sending XML for 23434 .. sent CC128 data read: S:0 T:26.3 I:00467 C:1 5682 W C:2 191 W C:3 1316 W SUM 7189 W Data storage for 20 sec updates: I:0 N:CurrentCost network S:0 T:26.3 I:00467 C:1 5682 W (since last update: 49452 Ws, avg 4121 W) C:2 191 W (since last update: 2124 Ws, avg 177 W) C:3 1316 W (since last update: 15768 Ws, avg 1314 W) SUM 7189 W (since last update: 67344 Ws, sum 5612 W) sending XML for 23434 .. sent ....
Use -q flag to suppress all debug output.
I have one sensor with three jaws (one hardwired plus two additional) to measure power consumption of all three phases. You can see my script output here: http://www.pachube.com/feeds/6434 (update after every 20 sec) and here http://www.pachube.com/feeds/23434 (real time data)
This script is way too long to include here. You can find the latest send_currentcost_to_pachube2.pl here: http://github.com/Cougar/pachube . Old version send_currentcost_to_pachube.pl is also available.