Web Based Thermometer

by savepaleni in Circuits > Sensors

838 Views, 2 Favorites, 0 Comments

Web Based Thermometer

Imp1.jpg

Some years ago tombrew made TempBug, a web based Thermometer. He used an Electric Imp Card and a thermistor as sensor. I followed his instructions and for years I was able to monitor ambient temperature remotely. Recently the sites TempBug needed to work properly became unreachable and so I had to find a solution.

You need an Electric Imp account:

https://impcentral.electricimp.com/login

And a ThingSpeak account:

https://thingspeak.com/

Both are free for basic tasks. Connect the TMP36 sensor, insert the USB cable and the Electric Imp card. Perform BlinkUp with your Android or iOS smartphone to connect the Imp to your WiFi network. As a last step you need to copy and paste the Agent and Device code in your impcentral Development Device Product:

AGENT

local thingspeakUrl = "http://api.thingspeak.com/update"; local headers = { "Content-Type": "application/x-www-form-urlencoded", "X-THINGSPEAKAPIKEY":"XXXXXXXXXXXXXXXX" };

local field = "field1";

function httpPostToThingspeak (data) { local request = http.post(thingspeakUrl, headers, data); local response = request.sendsync(); return response; }

device.on("updateTemp", function(temp) { local response = httpPostToThingspeak(field +"="+temp); server.log(response.body); });

DEVICE

hardware.pin8.configure(ANALOG_IN);

function getTemp() { local supplyVoltage = hardware.voltage(); local voltage = supplyVoltage * hardware.pin8.read() / 65535.0;

local c = (voltage - 0.5) * 100 ; local c_str = format("%.01f", c); server.log("Current temp is "+c_str+" °C");

agent.send("updateTemp", c_str); }

imp.onidle(function() { getTemp(); server.sleepfor(30); });

Agent_device.jpg

Since spaces, returns and parentheses are important, you can check the way they should look by clicking on the above picture.

End_Result.jpg

Here you can see what can be achieved after all the hard work...

Good Luck!