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.
Hello @MegaTux, sounds like your almost there! Emoncms has a HTTP api. Navigate to the emoncms inputs page and click on āInput API Helpā to see the list of API options
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.
The Input screen shows the last input received. Against an input you can create Processes - more than one if you wish and one of these processes is a Log to Feed.
A Feed in EmonCMS terms is where a data value is stored in the database against a specific time.
If you open the Feed screen, and click on a feed name, you should be taken to a graphical view of your data in the database.
@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.