Hacking emoncms

Hello, I’m working on a Raspberry Pi based whole-house energy monitoring project. The Pi code is mostly written from scratch (i.e. ground up… I don’t mean the scratch programming language that comes on the Pi :slight_smile: ). I’d like to use emoncms to store and present the data, but I’m at a bit of a loss on how to go about this. I’ve been reading through the emoncms documentation and files but it’s all a bit daunting and I’m having difficulty getting a grasp on the whole thing. I’m looking for a little help to get me going in the right direction.

A few quick notes on my project: Raspberry Pi is the main unit, controlling three Arduino Micros (via I2C), which in turn connect to approximately 30 CT and VTs. Everything is wire connected (i.e. no WiFi). I’m using ADC chips (via SPI) to do the analog reading, not the I/O pins of the Arduino.

So my initial questions are:

  1. Am I correct in understanding that emoncms works either as a locally installed/running database, or as a emoncms.org web-based system resident in the cloud? If so, my initial preference is to use the locally installed system over the web-based system.

  2. What is the minimum set of components I need to install for emoncms to run on the Pi, given that I’m writing my own Python based code to handle the energy monitoring and data acquisition functions?

  3. I’m looking for an example of how to send data to the emoncms database, and I’ve assumed that the existing emonPi code would be just that… except that I’m having difficulty locating the exact module. What is the best example file to help me grasp the emoncms API interface?

Any help, suggestions or a turn in the right direction is appreciated. Thanks!

Have you studied the following:
https://emoncms.org/site/api#input
https://emoncms.org/site/api#feed
https://emoncms.org/site/api#userguides

Thanks for the links - I have seen these, but as I said, there is so much emoncms information that simply knowing which avenues to follow is part of the challenge. Thanks for highlighting these - it help get me going in a productive direction.

I’m still going through these more thoroughly (I do have a day job to contend with…), but a couple of questions off the top.

  1. The installation guide says in its final instruction to attach the RFM69Pi add-on board. I don’t need this for what I’m doing, at least hardware wise. Is this board required even if I’ve got all other sensor and hardware issues managed without it?

  2. I’d still like to see sample code that sends the sensor data off to emoncms. Can you please suggest a link.

Thanks.

@quercus my system is primarily cloud based so things are a little different including the syntax for the API. Those links I provided have slightly different text if you replace emoncms.org with 127.0.0.1 or your local network IP for the Pi.

  1. You shouldn’t need the RFM69Pi.

  2. My C++ is better than my Python and I generally use ESP’s rather than Pi’s but an example C++ String for a full json GET to send data to emoncms.org is

String fullString = ("\"P1\":" + String(powerNow) + ",\"C1\":" + String(currentNowFloat, 1) + ",\"RP1\":" + String(realPower) + ",\"T1\":" + String(celsius, 1) );

fullString is then added to “http://emoncms.org/input/post?node=1&fulljson={” and finally “}&apikey=xxxxxxxxxxxxxxxx” is tagged on to the end of the String.

Hopefully you can convert for Python use and change to cover the slightly different API for local server.