Let's start wiring the Particle Photon board.
Let's add the temp and light sensors. You will find a nice video that show how to do that here :
The next step is to use the Webhook system from the Particle plateform to send datas whereever you want to, just like this one :
{
"eventName": "eventName",
"url": "VotreURL",
"requestType": "POST",
"json":
{
"photon": "{{photon}}",
"valueTEMP": "{{valueTEMP}}",
"valueLIGHT": "{{valueLIGHT}}",
"valueWIFI": "{{valueWIFI}}",
"date": "{{SPARK_PUBLISHED_AT}}"
},
"mydevices": true
}
Then, we decide to send all the datas from the Particle Photon sensors to OVH timeseries PaaS. It's simple and easy to setup. Just create your account here https://www.runabove.com/iot-paas-timeseries.xml and add your application. Then send your data with this simple snippet of code :
// send to OVH IOT TEMP
$data_string = array (
'metric' => 'temperature',
'timestamp' => time(),
'value' => (float)$sensor->valueTEMP,
'tags' => array( 'host' => 'myhost' )
);
$data_string = json_encode($data_string);
$ch = curl_init('https://opentsdb.iot.runabove.io/api/put');
curl_setopt($ch, CURLOPT_USERPWD, "WRITE_TOKEN:WRITE_PASSWORD");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
Finally, you can just setup a Grafana dashboard somewhere on your own machine and plug the Opentsdb from OVH as datasources to generate some nice graphics.
You can find the French version of this article here : http://www.matierenoire.io/iot-station-de-monitoring-de-temperature-et-de-luminosite-avec-un-particle-photon-runabove-iot-paas-timeseries-et-grafana/
Comments