Byoungsul Lee
/
Temperature_I2C
i2c temp sensor
Fork of Nucleo_i2c_mcp9808 by
Diff: main.cpp
- Revision:
- 2:43ecb155d581
- Parent:
- 1:404c34e19f93
diff -r 404c34e19f93 -r 43ecb155d581 main.cpp --- a/main.cpp Mon Mar 02 20:12:10 2015 +0000 +++ b/main.cpp Sun Apr 01 18:07:51 2018 +0000 @@ -10,7 +10,7 @@ DigitalOut myled(LED1); -Serial pc(SERIAL_TX, SERIAL_RX); +//Serial pc(SERIAL_TX, SERIAL_RX); volatile char TempCelsiusDisplay[] = "+abc.dd C"; @@ -22,7 +22,7 @@ int tempval; wait(3); - pc.printf("PumpHouse mcp9808 test! March 2, 2015 1450\n\r"); + printf("PumpHouse mcp9808 test! March 2, 2015 1450\n\r"); i2c.frequency(10000); // default is 100000 /* Configure the Temperature sensor device MCP9808: @@ -34,14 +34,14 @@ data_write[2] = 0x00; // config lsb int status = i2c.write(MCP9808_ADDR, data_write, 3, 0); if (status != 0) { // Error - pc.printf(" error status = 0x%08x\r\n", status); + printf(" error status = 0x%08x\r\n", status); while (1) { myled = !myled; wait(0.2); } } - pc.printf("enter forever loop\r\n"); + printf("enter forever loop\r\n"); while (1) { // Read temperature register data_write[0] = MCP9808_REG_TEMP; @@ -50,16 +50,16 @@ // check Ta vs Tcrit if((data_read[0] & 0x80) == 0x80) { - pc.printf(" temp >= critical "); + printf(" temp >= critical "); } if((data_read[0] & 0x40) == 0x40) { - pc.printf(" temp > upper limit "); + printf(" temp > upper limit "); } if((data_read[0] & 0x20) == 0x20) { - pc.printf(" temp < lower limit "); + printf(" temp < lower limit "); } if(data_read[0] & 0xE0) { - pc.printf("\r\n"); + printf("\r\n"); data_read[0] = data_read[0] & 0x1F; // clear flag bits } if((data_read[0] & 0x10) == 0x10) { @@ -96,7 +96,7 @@ TempCelsiusDisplay[3] = ((tempval % 100) % 10) + 0x30; // Display result - pc.printf("temp = %s\r\n", TempCelsiusDisplay); + printf("temp = %s\r\n", TempCelsiusDisplay); myled = !myled; wait(1.0); }