![](/media/cache/profiles/17a98ed636b0294602e63e75d11339a2.jpg.50x50_q85.jpg)
a test program to read temperature from TI TMP102 sensor, and then display on OLED screen.
Dependencies: TMP102 eeprom mbed oled_i2c
Diff: main.cpp
- Revision:
- 0:1b2565997ba9
- Child:
- 1:8e6b9978a4d0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jun 19 06:06:05 2018 +0000 @@ -0,0 +1,51 @@ +#include "mbed.h" +#include "oled_i2c.h" +#include "oled_font.h" +#include "test_TMP102.h" + +DigitalOut myled(LED2); + +// for LPCXpresso LPC1114 board +// UART TX: xp9, dp16 +// UART RX: xp10, dp15 +// ************************************* +// ** serial port: 9600, 8, N, 1, N +// ************************************* +//Serial pc(xp9, xp10); +I2C i2c(dp5, dp27); +oled_i2c oled(i2c); +test_TMP102 temp1(i2c); + +int main() { + myled = 1; + printf("LPC1114 demo \r\n"); + i2c.frequency(1000 * 1000); + + // ------------ tmp102 -------------- + temp1.setExtendedMode(1); + temp1.setConversionRate(2); + temp1.sleep(); + + // ------------ oled ---------------- + oled.init_oled(); + //oled.fillScr(); + + while(1) + { + myled = 1; + + temp1.oneShot(); + float t1 = temp1; + + //oled.clrScr(); + oled.setFont(BigNumbers); + //oled.print("27", 20, 10); + //oled.printNumI(27, 0, 0); + oled.printNumF(t1, 2, 0, 0); + oled.setFont(SmallFont); + oled.print("~c", 60, 30); + oled.update(); + myled = 0; + wait(0.5); + } +}