Simulating temperature readings from Smartphone to Bluemix

Ask, and ye shall receive.
kiranshashiny
Posts: 12
Joined: 09:35, 14 Feb 2016

Simulating temperature readings from Smartphone to Bluemix

Postby kiranshashiny » 11:38, 16 Feb 2016

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==

alex
Posts: 92
Joined: 00:59, 19 Nov 2013

Re: Simulating temperature readings from Smartphone to Bluemix

Postby alex » 12:12, 16 Feb 2016

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/


Return to “Questions and answers”

Who is online

Users browsing this forum: No registered users and 11 guests