a
Dependencies: mbed TextLCD BME280
main.cpp@0:f8c0f96ee619, 2020-02-04 (annotated)
- Committer:
- borjazuma
- Date:
- Tue Feb 04 08:58:11 2020 +0000
- Revision:
- 0:f8c0f96ee619
a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
borjazuma | 0:f8c0f96ee619 | 1 | #include "TextLCD.h" |
borjazuma | 0:f8c0f96ee619 | 2 | #include "mbed.h" |
borjazuma | 0:f8c0f96ee619 | 3 | #include "BME280.h" |
borjazuma | 0:f8c0f96ee619 | 4 | |
borjazuma | 0:f8c0f96ee619 | 5 | Serial pc(USBTX, USBRX); |
borjazuma | 0:f8c0f96ee619 | 6 | |
borjazuma | 0:f8c0f96ee619 | 7 | #if defined(TARGET_LPC1768) |
borjazuma | 0:f8c0f96ee619 | 8 | BME280 sensor(p28, p27); |
borjazuma | 0:f8c0f96ee619 | 9 | #else |
borjazuma | 0:f8c0f96ee619 | 10 | BME280 sensor(I2C_SDA, I2C_SCL); |
borjazuma | 0:f8c0f96ee619 | 11 | #endif |
borjazuma | 0:f8c0f96ee619 | 12 | TextLCD lcd(D8, D9, D2, D3, D4, D5, TextLCD::LCD16x2); // rs, e, d4-d7 |
borjazuma | 0:f8c0f96ee619 | 13 | int main() { |
borjazuma | 0:f8c0f96ee619 | 14 | |
borjazuma | 0:f8c0f96ee619 | 15 | double presion; |
borjazuma | 0:f8c0f96ee619 | 16 | |
borjazuma | 0:f8c0f96ee619 | 17 | while(1) |
borjazuma | 0:f8c0f96ee619 | 18 | { |
borjazuma | 0:f8c0f96ee619 | 19 | presion = sensor.getPressure()/10; |
borjazuma | 0:f8c0f96ee619 | 20 | pc.printf("%2.2f C, %04.2f kPa, %2.2f %%\n", sensor.getTemperature(), presion, sensor.getHumidity()); |
borjazuma | 0:f8c0f96ee619 | 21 | lcd.cls(); |
borjazuma | 0:f8c0f96ee619 | 22 | lcd.printf("%2.2fC %04.2fkPa %2.2f%%\n", sensor.getTemperature(), presion, sensor.getHumidity()); |
borjazuma | 0:f8c0f96ee619 | 23 | wait(0.5); |