I followed this tutorial (guide) to build a temperature logger using Electric Imp and April board. I can get my temperature in logger but I am having trouble actually getting it on Cosm Graph.
I’ve got the Cosm node and linked it with my node running the script.
For some reason I can’t save details (External Services) onto that node.
There are 3 things that I need to save:
“API Key”, “feed” and "datastream"
and I can’t save any of them… (When I re-open the External Services setting page by using the button on top right corner, none of the details I have copied and pasted is there…)
I have modified the original code
Current code:
`hardware.pin1.configure(ANALOG_IN);
// LED pin config
hardware.pin2.configure(DIGITAL_OUT_OD_PULLUP);
// initially set to off
hardware.pin2.write(0);
/*
If you don’t have a Hannah board but want to try the
Cosm.com temperature logging exercise, here it is!
temperature sensor used is tmp36 from adafruit.com for $2.00
http://learn.adafruit.com/tmp36-temperature-sensor
temp range -40°C to 150°C / -40°F to 302°F
*/
local output = OutputPort(“temp”,“number”);
local postInit = false;
local oldTemp = null;
local reading = null;
local ratio = null;
local voltage = null;
local temperatureC = null;
local temp = null;
function update_temp() {
// keep the imp awake
imp.wakeup(10, update_temp);
// get the raw voltage value from temp sensor btw 0-65535
// in this case that needs mapping to the range 0-3.3v
reading = hardware.pin1.read();
// get the ratio
ratio = 65535.0 / reading;
// make units milivolts and get voltage we can work with
//voltage = (hardware.voltage() * 1000) / divider;
voltage = 3300 / ratio;
// get temperature in degrees Celsius
temperatureC = (voltage - 500) / 10.0;
server.log(postInit);
server.log("temp: " + temperatureC);
// set our output to desired temperature unit
temp = temperatureC;
// after function’s first run set flag to true
postInit = true;
}
server.show(temp);
// Register with the server
imp.configure("Tempreature: ", [], [output]);
update_temp();`