Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API DnsQuery ESP8266Interface NetworkSocketAPI mbed nRF51822
Fork of BLE_TemperatureBeacon by
temp.cpp
00001 #include "mbed.h" 00002 #include <math.h> 00003 AnalogIn thermistor(P0_3); 00004 00005 int beta = 3975; 00006 float temperature, resistance; 00007 00008 float getTemp() { 00009 unsigned int a = thermistor.read_u16(); /* Read analog value 16 bit 65536*/ 00010 00011 /* Calculate the resistance of the thermistor from analog votage read. positive feedback 100k to ground 10 bit ADC*/ 00012 resistance= (float) 100000.0 * ((1023.0 / a) - 1.0); 00013 00014 /* Convert the resistance to temperature using Steinhart's Hart equation */ 00015 temperature=(1/((log(resistance/100000.0)/beta) + (1.0/298.15)))-273.15; 00016 return temperature; 00017 }
Generated on Sun Jul 17 2022 17:11:33 by
1.7.2
