Matthaeus Vorraber
/
TempHuminitysensor
Temperatur und Luffeuchtigkeit ueber I^2 einlesen und an der serielen Schnittstelle ausgeben
Revision 3:ab1d4af507d1, committed 2020-01-13
- Comitter:
- happy_alien
- Date:
- Mon Jan 13 18:01:54 2020 +0000
- Parent:
- 2:538939bfd629
- Commit message:
- Huminnty Sensor ueber I^2C einlesen (ohne lcd.Display)
Changed in this revision
Si7021.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 538939bfd629 -r ab1d4af507d1 Si7021.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Si7021.lib Mon Jan 13 18:01:54 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/irsanjul/code/Si7021/#d3514bc63a39
diff -r 538939bfd629 -r ab1d4af507d1 main.cpp --- a/main.cpp Thu Nov 21 16:35:53 2019 +0000 +++ b/main.cpp Mon Jan 13 18:01:54 2020 +0000 @@ -1,59 +1,26 @@ #include "mbed.h" - - - - // D20,D19,D18,D17,... -BusOut lb(D2,D3,D6,D9,D11,D12,A6,D13); - - - -DigitalIn T1(A2), T2(A1); - - -void OneRunLightStep2(); -void Dreierlicht(); - - -int main() +#include "Si7021.h" -{ - while(1) - { - if (T1==0) - OneRunLightStep2(); - if(T2==0) - Dreierlicht(); - - - +I2C env_i2c(PC4, PC5); + + // einlesen des +int main() { + int32_t temperature; + uint32_t humidity; + + /* Measure temperature and humidity */ + if(rhtsensor_en) { + rhtSensor->measure(); + rhtSensor->measure(); + temperature = rhtSensor->get_temperature(); + humidity = rhtSensor->get_humidity(); + + printf("Si7021:\r\n"); + printf("T: %ld.%03ld degC\r\n", temperature/1000, abs(temperature%1000)); + printf("h: %ld.%03ld %%\r\n", humidity/1000, humidity%1000); + } } - } - - -void OneRunLightStep2() -{ - if(lb==0) - lb=1; - else - lb=lb<<1; // Finster - wait_ms(500); -} -void Dreierlicht() -{ - int i=0; - lb=1; - for(i=0;i<8;i++) - { - wait_ms(500); - if(i<2) - lb=(lb<<1) |1; - else - lb=(lb<<1); - - } - - -} +