
Measures the temperature with averaging by using a Microchip MCP9700A analog thermometer. Averaged result is printed to standard output.
/ 05_analog_thermometer2
- Measeures the temperature by using a Microchip MCP9700A
- analog thermometer (parameteres: 10 mV/C, 500 mV offset, VCC= 2.3-5.5V)
- Averaged result is printed to standard output.
- Hardware requirements:
- - FRDM-KL25Z board
- - MCP9700A analog thermometer connected to A0 (PTB0)
- /
Revision 0:9f5cbd8850f2, committed 2015-11-18
- Comitter:
- icserny
- Date:
- Wed Nov 18 15:32:38 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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Nov 18 15:32:38 2015 +0000 @@ -0,0 +1,29 @@ +/** 05_analog_thermometer2 + * Measeures the temperature by using a Microchip MCP9700A + * analog thermometer (parameteres: 10 mV/C, 500 mV offset, VCC= 2.3-5.5V) + * Averaged 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 +uint32_t mysum; // Used for summation + +int main() +{ + printf("\r\n05_analog_thermometer2 - with averaging\r\n"); + while(1) { + mysum = 0; + for(int i=0; i<3300; i++) { + mysum += ain.read_u16(); // sum up raw 16-bit data + } + float voltage = mysum>>16; // voltage in millivolts + float tempC = (voltage -500)/10; // tempereature in Celsius + printf("voltage: %5.0f mV temp: %5.1f C\r\n",voltage,tempC); + wait(2); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Nov 18 15:32:38 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11 \ No newline at end of file