managed to install emoncms so very excited to get it going. I have two self-built TH sensors (used a HUZZAH ESP8266 + DHT22) that I have running over WiFi. The log T & H onto a custom MySQL database over a GET request through my Apache server @ home. Very rudimentary approach but i have temperature logging which is my prime objective.
Then I cam across emoncms which seems to do exactly what I need (access T over web and android app). Eventually, I may even get myself a nice Chrismas present and get an emonpi to attach to my electricity meter.
Anyway, now the difficult part. How do I get the TH sensors to log data through emocms? Are there Arduino sketches I can customise to achieve this goal? I’ve been doing a bit of digging around but not sure I have got to the bottom of it. The fact that the OpenEnergyMonitor is relying on radio frequency through a hub and then logging to emoncms is quite a different approach to what I need. I’m not worried about generating traffic through WiFi for now so the radio approach would be a next step in the future.
Hey, @TristanLea, thanks. You make it sound easy but the truth is that I’m no PHP guru. Surely I need to create a device first so that emoncms prepares the database to store the data from the device first? In the device list, the closest I can get to my setup is the the emonTH sensor. However, it’s asking for a device key which I suspect all openenergy units have. My units are simply posting the last 6 hex digits of their mac address to the mysql database to the “temperature” table. I then filter against mac(6) when I want to plot the data.
So I’ve created a device and initialised it. I gave is the mac(6) as node id so somthing along XX:XX:XX. The device is listed. so then I tried to build the GET string as described by you which looks like:
but all I get is a “404 NOT FOUND The requested URL /emoncms/input/post was not found on this server.” More specifically, Apache access log suggests 404 416 (416 Requested Range Not Satisfiable). To me this suggests that its complaining because I’m trying to pass it ranges that are not allowed in the mysql table. I had assumed that my 10,50 would be my temperature and humidiy but maybe I’m wrong. I had also assumed that the database would be logging the timestamp automatically or do I have to pass it the time too. If so, I guess I would have to programme the Arduino sketch to pass over the time too in the get request?
As you can see, I feel I’m not so close to the solution as you had suggested
POSTSCRIPT: I’ve been digging around in the mysql tables and have not noticed any CURRENT_TIMESTAMP data type in any of the tables (looks like data is being stored in “feeds”). Still not quite sure how I have to construct the HTTP GET string to pass through the browser …
POSTSCRIPT2: Getting closer. Managed to log numbers in the emoncms mysql database by using the string:
Now, every time I log a new value via browser, the database only stores the most recent post in the “input” and “feeds” tables i.e. there is logging shown on the graphs (suggesting data is being logged somewhere) but the mysql database tables are only storing the most recent value.
Where are historical values stored and why is emoncms mysql not storing my historical values even though they are showing up in the graphs? Seems like actual data is stored outside mysql? And if so, how do I ensure that the data is backed up (would have been simple to include this in my mysql dumps if it were …?
You could do it directly from your nodes with Arduino code as you said. Take a look at the post from a few weeks ago. This uses the https interface. Set up each node to send the temp and humidity, then in emoncms you’ll see the data under inputs. Create feeds for both temps and humidity readings and create a dashboard. If you get it working you could then drop your SQL database and rely on emoncms to keep the historical data.
@borpin, thanks it does actually log. It took me a while to figure out that I needed to zoom into the default graph visualization (i.e. the default is a week and only a handful of values in a straight line were not showing … as soon as I zoomed to “Daily” I could see the data).
I think I’ve cracked it now using the JSON string type I had indicated in my previous post to post the data from my units to the database.
I’m having problems with a hanging “Admin” page now but I’ll post separately for that. Thanks for your help on the resolving issues to date.