Andrea Corrado
/
mbed-cloud-connect-sensor-temp-hum
Sets up LCD and prints sensor data value of SHT31-D temperature/humidity sensor to LCD
main.cpp@0:624458d6086e, 2017-11-01 (annotated)
- Committer:
- andcor02
- Date:
- Wed Nov 01 13:13:38 2017 +0000
- Revision:
- 0:624458d6086e
Initial commit
Who changed what in which revision?
User | Revision | Line number | New 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 | } |