Sending data to remote MySQL

I opened my emonpi box about an hour ago, and haven't had much chance to look around yet... So assume little/no knowledge please!

I've got my house, solar and consumption feeds recording locally and uploading to emoncms.org, and now I'm wondering how best to get my numbers out to a remote MySQL database... opening up the data and paving the way to mobile apps, widgets etc

I've found the feed data files in /home/pi/data/phpfina and Trystan's phpfina.php script that demonstrates the reads. Of course I could write a cron job to read the file and send new entries to my server but ideally I'd like to hook in to the process that writes out to these feed files so that for every value written down to a feed file, I call out to my web service / database etc to record the value on my remote server.

A quick search of the forum didn't turn up anyone else talking about doing this... has anyone else tried to extract their data to a database? Is there a better way to do it? Am I overcomplicating things... can I add a MySQL Interfacer to emonhub.conf, or should I be looking to route the data to a new destination in MQTT?

​Any guidance would be much appreciated. Cheers!

ChrisBirkett's picture

Re: Sending data to remote MySQL

I've just found this related thread...

http://openenergymonitor.org/emon/node/10892

Can anyone help us out? :-)

chuayq's picture

Re: Sending data to remote MySQL

I am still stuck on the same problem. Anybody knows where I can find the emonhub source code?? The links google provided are no longer valid.

I will see if I can understand the code and try to write an interfacer for emonhub to directly write into mysql. If it's successful, I will post it here.  :)  Hopefully, this will save a lot of work and not have the data passed around before it reached MYSQL.

Another way will be have emonhub send to a URL I think, not too sure about the apikey part though. I am not well verse in HTTP.

pb66's picture

Re: Sending data to remote MySQL

The emonhub source code is at https://github.com/emonhub/emonhub.

I have to admit I'm alittle vague on what it is you are trying to do, I get you want your data in a SQL table, emoncms can do that, if you want the data to go to another target then how does that target want the data? do you have an application or database in mind?

Paul

ChrisBirkett's picture

Re: Sending data to remote MySQL

I'm just looking to get my data into a SQL table. How can emoncms be configured to do that? (I'm running my own installation, no longer emoncms.org)

pb66's picture

Re: Sending data to remote MySQL

The "extended" version of emoncms can write data to SQL tables, if you are running on a Pi you will need to add a hdd as it is not as "low-write" as the version included on the SDcard image.

If you want the data on another machine ie a local PC or Laptop you can set up emoncms "extended" on that machine and have emonhub forward data to that server in the same way you could send to emoncms.org.

emonHub is able to buffer data in RAM too so at a stretch you could allow the PC to sleep or laptop to travel and "catch up" when woken or made available. This isn't a perfect scenario however as the data is volatile in RAM any power disruptions and you will lose the buffered data.

Paul

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.