Measures the temperature by using a Microchip MCP9700A analog thermometer. Result is printed to standard output.
05_analog_thermometer
Measures the temperature by using a Microchip MCP9700A analog thermometer (parameteres: 10 mV/C, 500 mV offset, VCC= 2.3-5.5V). The result is printed to standard output.
Hardware requirements:
- FRDM-KL25Z board
- MCP9700A analog thermometer connected to the A0 (PTB0) analog input
Revision 0:d5f4c581840b, committed 2015-11-18
- Comitter:
- icserny
- Date:
- Wed Nov 18 15:31:37 2015 +0000
- Commit message:
- First version
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r d5f4c581840b main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Nov 18 15:31:37 2015 +0000 @@ -0,0 +1,25 @@ +/** 05_analog_thermometer + * Measeures the temperature by using a Microchip MCP9700A + * analog thermometer (parameteres: 10 mV/C, 500 mV offset, VCC= 2.3-5.5V) + * Result is printed to standard output. + * + * Hardware requirements: + * - FRDM-KL25Z board + * - MCP9700A analog thermometer connected to A0 (PTB0) + */ + +#include "mbed.h" + +AnalogIn ain(A0); // Analog input at PTB0 + +int main() +{ + printf("\r\n05_analog_thermometer program\r\n"); + while(1) { + uint16_t raw = ain.read_u16(); // read raw 16-bit data + float voltage = ain.read()*3300; // read voltage in millivolts + float tempC = (voltage -500)/10; // tempereature in Celsius + printf("ADC: 0x%04X voltage: %5.0f temp: %5.1f C\r\n",raw,voltage,tempC); + wait(2); + } +}
diff -r 000000000000 -r d5f4c581840b mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Nov 18 15:31:37 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11 \ No newline at end of file