Tuesday, September 9, 2014

NETMF 4.2 - Reading a TMP36 sensor

Reading TMP36 from AnalogDevices

Product page: http://www.analog.com/en/mems-sensors/digital-temperature-sensors/tmp36/products/product.html
 

Using AnalogPin 0 on a GHI Cerbuino Bee. The flashing LED indicates alternating read cycles.



Cerbuino product page: https://www.ghielectronics.com/catalog/product/351
Cerbuino schematic: http://www.ghielectronics.com/downloads/schematic/FEZ_Cerbuino_Bee_SCH.PDF

AnalogInput ain = new AnalogInput((Cpu.AnalogChannel)10);
ain.Scale = 3.3;
OutputPort LED;
LED = new OutputPort(cerb.Pin.PB2, true);
double temp, temperatureF;
bool last = false; while (true)
{
    last = !last;
    LED.Write(last);
    temp = (ain.Read() - 0.5) * 100;
    Debug.Print("TempC: " + temp);
    temperatureF = (temp * 9.0 / 5.0) + 32.0;
    Debug.Print("TempF: " + temperatureF);
    Thread.Sleep(1500);
}
It's that simple!



No comments:

Post a Comment