Sets up LCD and prints sensor data value of SHT31-D temperature/humidity sensor to LCD

Dependencies:   C12832 Sht31

Committer:
andcor02
Date:
Thu Jan 11 12:24:24 2018 +0000
Revision:
1:0ec5fde072a1
Parent:
0:624458d6086e
updated to mbed os latest

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andcor02 0:624458d6086e 1 #include "mbed.h"
andcor02 0:624458d6086e 2 #include "C12832.h"
andcor02 0:624458d6086e 3 #include "Sht31.h"
andcor02 0:624458d6086e 4
andcor02 0:624458d6086e 5 /* Sets up LCD and prints sensor data value of temperature sensor to LCD */
andcor02 0:624458d6086e 6
andcor02 0:624458d6086e 7 C12832 lcd(PE_14, PE_12, PD_12, PD_11, PE_9); //LCD: MOSI, SCK, RESET, A0, nCS
andcor02 0:624458d6086e 8 Sht31 sht31(PF_0, PF_1); //TEMP SENSOR: I2C_SDA, I2C_SCL
andcor02 0:624458d6086e 9
andcor02 0:624458d6086e 10 int main()
andcor02 0:624458d6086e 11 {
andcor02 0:624458d6086e 12 while(1) {
andcor02 0:624458d6086e 13 float t = sht31.readTemperature();
andcor02 0:624458d6086e 14 float h = sht31.readHumidity();
andcor02 0:624458d6086e 15
andcor02 0:624458d6086e 16 lcd.locate(0,3);
andcor02 0:624458d6086e 17 lcd.printf("[TEMP/HUM]");
andcor02 0:624458d6086e 18 lcd.locate(0,15);
andcor02 0:624458d6086e 19 lcd.printf("TEMP:%3.2fC, HUM:%3.2f%%", t, h); // Print to LCD values
andcor02 0:624458d6086e 20 }
andcor02 0:624458d6086e 21 }