Extremely simple temperature sensing with MCP9700

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:
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.
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;


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:

Hey…I kinda need to build a non-contact clinical thermometer and transmit its data to a MySQL database per patient…Could you help me out???

It would be helpful if you would post the brand and model number of the thermometer. Also, is a web server with PHP available on the system that’s running MySQL?

There are many (free and secure) cloud services for the data. Would something like that be considered or is MySQL an absolute requirement?

(perhaps this should be a new post since we may have hijacked the original one by @baze)

I can help with the PHP and MySQLi part, but you first have to get your agent to successfully POST JSON to a remote website. In this case, the website will be your own? Or you have the ability to access someone’s webhost account?