Hi,
Couldn’t find any forum post about using MCP9700 for measuring temperature so here’s a short intro.
Connect MCP9700 to Electric IMP’s terminals:
GND to GND
VDD to 3V3
Vout to Pin7
MCP9700 (TO-92) pin layout can be found here.
Copy and paste the following code to planner:
`
// Configure PIN 7 as analog INPUT.
hardware.pin7.configure(ANALOG_IN);
function readMCP9700(){
local data = hardware.pin7.read();
local hwvolts = hardware.voltage();
// convert the number from the ADC
local temp = data * (hwvolts / 65535);
// Sensors specs say "500 mV for 0°C"
temp = temp - 0.5;
// Sensor has linear Temperature Slope: 10mV/°C
temp = temp / 0.01;
server.log(“MCP temp[”+ temp +"] voltage["+data+"] hwVoltage=["+hwvolts+"]");
return temp;
}
readMCP9700();
`
Sensor is not the most accurate, but extremely simple to connect and use. Also very low Operating Current 12µA (max).
Sensors full specs here if you are interested:
http://ww1.microchip.com/downloads/en/DeviceDoc/21942e.pdf