This simple perl script can be used to feed pachube with average power and temperature readings from CurrentCost Envi (CC128) which is connected with CoreCard and using sns_Serial module. No CurrentCost data cable necessary for this setup.
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.
NB! It is also possible to use the same script if you don't have CoreCard and would like to connect CC128 directly with your PC using data cable. For that you need to uncomment corecard related config and define serial port where data cable is connected. Please look at source code of script for that. Look at pachube_currentcost page about one of such setup.
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 $id variable in the beginning of script.
Install sns_Serial module to CoreCard and connect CC128 directly to Corecard. No CurrentCost data cable nor RS232 expansion for Corecard necessary.
If you have CurrentCost Envi (CC128) then you need to connect it like this:
| CC128 pin | TIA/EIA-568-B Color | Function | Corecard pin | |
| 4 | Blue | GND | GND | |
| 8 | Brown | RxD | K | |
Copy script to your server and change at least $candaemonhost, $apikey and $id and you are ready to go. You just need to keep this script running in background (or in screen session). You should see something like this:
t61:pts9:~>./send_currentcost_to_pachube.pl connecting to candaemon.. connected set serial port speed to 56k S:0 T:25.5 I:00467 C: 1 2933 W C: 2 160 W C: 3 725 W AVERAGE 1272 W TOTAL 3818 W S:0 T:25.5 I:00467 C: 1 3000 W (since last update: 17598 Ws, avg 2933 W) C: 2 171 W (since last update: 960 Ws, avg 160 W) C: 3 720 W (since last update: 4350 Ws, avg 725 W) AVERAGE 1297 W (since last update: 7636 Ws, avg 1272 W) TOTAL 3891 W (since last update: 22908 Ws, avg 3818 W) S:0 T:25.5 I:00467 C: 1 3021 W (since last update: 35598 Ws, avg 2966 W) C: 2 165 W (since last update: 1986 Ws, avg 165 W) C: 3 727 W (since last update: 8670 Ws, avg 722 W) AVERAGE 1304 W (since last update: 15418 Ws, avg 1284 W) TOTAL 3913 W (since last update: 46254 Ws, avg 3854 W)
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
This script is way too long to include here. You can find the latest send_currentcost_to_pachube.pl here: http://github.com/Cougar/pachube