Pushing Data to cloud service with HTTP Post

Started by jeremiah, February 24, 2016, 07:31:32 PM

jeremiah

I have a gateway up an running, it is logging data locally to the Pi as it should and graphing is working. However, I would like to be able to post the data points to a cloud service like ThingSpeak or data.sparkfun.com. They both allow HTTP Post to do so.

I am searching for the best place to put code into the existing code. basically trying to get it to log data in both places (local as currently already doing and to the cloud service). Looking through the code, it seems as if the logUtil.js is where the actual data gets saved out to the binary files locally, but I get lost there. I would need to know exactly what type of node is saving data in order to create the HTTP Post string correctly to match the data fields.

Anybody look into using cloud service for data logging with this Gateway?

Felix

Look for the request events in metrics.js, there are some samples there to make HTTP requests to a wifi thermostat.
You could then write some code like that for the serial message handler to post your data to the cloud in addition to logging it locally - look for global.processSerialData in gateway.js.
Or you could setup events that respond to incoming data of certain types and only submit to cloud in those instances. Many ways of doing it...

jeremiah

Just and update, I created a new Event option that allows for a http request to be run. It seemed like the best way to ensure them mode type is known. and it can be  turned on and off like a notification event.