Matthaeus Vorraber
/
TempHuminitysensor
Temperatur und Luffeuchtigkeit ueber I^2 einlesen und an der serielen Schnittstelle ausgeben
main.cpp@3:ab1d4af507d1, 2020-01-13 (annotated)
- Committer:
- happy_alien
- Date:
- Mon Jan 13 18:01:54 2020 +0000
- Revision:
- 3:ab1d4af507d1
- Parent:
- 2:538939bfd629
Huminnty Sensor ueber I^2C einlesen (ohne lcd.Display)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
happy_alien | 0:fd27a92aaa8c | 1 | #include "mbed.h" |
happy_alien | 3:ab1d4af507d1 | 2 | #include "Si7021.h" |
happy_alien | 0:fd27a92aaa8c | 3 | |
happy_alien | 3:ab1d4af507d1 | 4 | I2C env_i2c(PC4, PC5); |
happy_alien | 3:ab1d4af507d1 | 5 | |
happy_alien | 3:ab1d4af507d1 | 6 | // einlesen des |
happy_alien | 3:ab1d4af507d1 | 7 | int main() { |
happy_alien | 3:ab1d4af507d1 | 8 | int32_t temperature; |
happy_alien | 3:ab1d4af507d1 | 9 | uint32_t humidity; |
happy_alien | 3:ab1d4af507d1 | 10 | |
happy_alien | 3:ab1d4af507d1 | 11 | /* Measure temperature and humidity */ |
happy_alien | 3:ab1d4af507d1 | 12 | if(rhtsensor_en) { |
happy_alien | 3:ab1d4af507d1 | 13 | rhtSensor->measure(); |
happy_alien | 3:ab1d4af507d1 | 14 | rhtSensor->measure(); |
happy_alien | 3:ab1d4af507d1 | 15 | temperature = rhtSensor->get_temperature(); |
happy_alien | 3:ab1d4af507d1 | 16 | humidity = rhtSensor->get_humidity(); |
happy_alien | 3:ab1d4af507d1 | 17 | |
happy_alien | 3:ab1d4af507d1 | 18 | printf("Si7021:\r\n"); |
happy_alien | 3:ab1d4af507d1 | 19 | printf("T: %ld.%03ld degC\r\n", temperature/1000, abs(temperature%1000)); |
happy_alien | 3:ab1d4af507d1 | 20 | printf("h: %ld.%03ld %%\r\n", humidity/1000, humidity%1000); |
happy_alien | 3:ab1d4af507d1 | 21 | } |
happy_alien | 0:fd27a92aaa8c | 22 | } |
happy_alien | 0:fd27a92aaa8c | 23 | } |
happy_alien | 2:538939bfd629 | 24 | |
happy_alien | 2:538939bfd629 | 25 | |
happy_alien | 3:ab1d4af507d1 | 26 |