Page 1 of 1

Simulating temperature readings from Smartphone to Bluemix

Posted: 11:38, 16 Feb 2016
by kiranshashiny
I want to send ( or simulate temperature readings ) from the smartphone to Bluemix.
Going thru the tutorial https://evothings.com/evothings-does-mqtt-with-bluemix/ and I found it is doing some publish.

How do I post a temperature in "json" format ?
The temperature will be something like 20, 24, 31, and so on.
Appreciate if you could help with a SAMPLE line.

=== Cut and Paste === from your app.js ===
setupCanvas () {
...
var msg = JSON.stringify({from: app.pos, to: {x:x, y:y}, color: app.color}) << == what would it be for temperature which is an integer.
app.publish(msg);

..
}

==X== Done Cut and paste ===X==

Re: Simulating temperature readings from Smartphone to Bluemix

Posted: 12:12, 16 Feb 2016
by alex
Hi!

I'd use something like Micke's example to simulate data from a SensorTag:

Code: Select all

function initialiseSimulationTimer()
{
    // Timer that updates temperature values.
    setInterval(function() {
        lastTemperatureReading = ((Math.random() * 5) + 20).toFixed(2)
        },
        5000)

    // Timer that sends data to the cloud.
    setInterval(onTemperatureTimer, 5000)
}


You can find the entire example here, it's for Parse but you'll get the idea :-)

https://evothings.com/how-to-make-a-mobile-iot-app-for-the-facebook-parse-data-cloud/