A test program for LM75B temperature sensor

Dependencies:   LM75B mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "MSS.h"
00003 #include "LM75B.h"
00004 #define LM75B_I2C_ADDRESS (0x48)
00005 
00006 int main() {
00007     int8_t itemp = 0 ;
00008     float ftemp = 0.0 ;
00009     LM75B lm75b(PIN_SDA, PIN_SCL, LM75B_I2C_ADDRESS) ;
00010     
00011     printf("=== test LM75B for %s (%s) ===\n", BOARD_NAME, __DATE__) ;
00012     printf("Temperature (int) C, Temperature (float) C\n") ;
00013     
00014     while(1) {
00015         itemp = lm75b.temp() ;
00016         lm75b.getTemp(&ftemp) ;
00017 //        printf("Temp = %d C degree,  %.3f C degree\n", itemp, ftemp) ;
00018         printf("%4d, %4.3f\n", itemp, ftemp) ;
00019         wait(1) ;
00020     }
00021 }