I just started with openenergymonitor - especially because of the RFM69pi Modul… I use it for receiving data from my own RFM12B temperature sensors. At the moment I use the pre-built emonSD-03May16 Image - and it works great. I can see the Nodes and the temperature.
But I don’t want to use the local emoncms or emoncms.org services. I would like to forward the values to a local mysql database on a different server…
So I think about writing a connector which sends the data to the database.
Unfortunately I have no idea which (PHP) script is processing new sensor values… I think somewhere must be a function which is processing the new values. Then I could modify this code and do whatever I want…
The easiest way IMHO is to use nodeRED which is built into the emonSD-03May16 SD card image to read the data from MQTT on the emonPi / emonBase to post to another service. You can perform a HTTP request to post data to another service.
NodeRED is running on port 1880, see emonPi nodeRED documentation page:
In my mind emonhub is the more logical place to do what you want but I’m not fan of parsing the log file. It has been done before though and a direct SQL connector has been also been discussed. The better way would be to write a custom SQL reporter for emonhub, a reporter would buffer undelivered data during server/network interruptions etc.
Take a look at emonhub_reporters.py and the emoncms reporter in particular to see how it could be quite easily duplicated with changes to suit your own api or if you are more familiar with using remote SQL connections than I am (which isn’t at all difficult) we could look at connecting directly to the remote mySQL server.
The reporters are not found in the “emonPi variant” of emonHub on the emonSD image, so the buffering isn’t available, I would firmly recommend using the original version when posting remotely and you will also find it easier to develop for.
After solving a few problems with a clean Raspian Jessie (SysRQ / Crash because of cmdline settings) and struggling with the documentation I found a solution.
“Talking” with the RFM69Pi is much more easier than I tought. And emonhub.py is doing the rest.
At the moment I can access the values in emonhub.py / emonhub_reporter.py and post them to a PHP-Script / URL. I can access the values in the PHP Script - so insertig them in a mySQL Database is no problem.
Perhaps I will try to connect to mySQL directly from emonhub_reporter.py later - but at the moment I’m happy with this “quick-and-dirty” solution
but I should use that conector emonhub_reporters.py ?
or made changes on
[[emoncmsorg]]
Type = EmonHubEmoncmsHTTPInterfacer
[[[init_settings]]]
[[[runtimesettings]]]
pubchannels = ToRFM12,
subchannels = ToEmonCMS,
url = https://emoncms.org
apikey =
senddata = 1 # Enable sending data to Emoncms.org
sendstatus = 1 # Enable sending WAN IP to Emoncms.org MyIP > Emoncms - myip list
sendinterval= 30 # Bulk send interval to Emoncms.org in seconds