corrected TH02 sample program
Dependencies: mbed
Fork of TH02_humidity_temp by
main.cpp@1:8326614f3037, 2019-10-21 (annotated)
- Committer:
- superphil06
- Date:
- Mon Oct 21 09:10:15 2019 +0000
- Revision:
- 1:8326614f3037
- Parent:
- 0:f1951c6c9187
th02 sensor application program
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
superphil06 | 0:f1951c6c9187 | 1 | #include "mbed.h" |
superphil06 | 1:8326614f3037 | 2 | |
superphil06 | 0:f1951c6c9187 | 3 | #include "th02.h" |
superphil06 | 0:f1951c6c9187 | 4 | |
superphil06 | 0:f1951c6c9187 | 5 | |
superphil06 | 0:f1951c6c9187 | 6 | |
superphil06 | 1:8326614f3037 | 7 | //DigitalOut myled(LED1); |
superphil06 | 0:f1951c6c9187 | 8 | |
superphil06 | 0:f1951c6c9187 | 9 | |
superphil06 | 1:8326614f3037 | 10 | TH02 MyTH02 (I2C_SDA,I2C_SCL,TH02_I2C_ADDR<<1);// connect hsensor on RX2 TX2 |
superphil06 | 1:8326614f3037 | 11 | //TH02 MyTH02 (p28,p27,TH02_I2C_ADDR<<1);// connect hsensor on RX2 TX2 |
superphil06 | 0:f1951c6c9187 | 12 | |
superphil06 | 0:f1951c6c9187 | 13 | int main() { |
superphil06 | 0:f1951c6c9187 | 14 | int iTemp,iTime,iTempbrute,iRH,iRHbrute; |
superphil06 | 1:8326614f3037 | 15 | printf ("\n\r start reading TH02"); |
superphil06 | 0:f1951c6c9187 | 16 | //MyTH02.startTempConv(true,true); |
superphil06 | 1:8326614f3037 | 17 | |
superphil06 | 1:8326614f3037 | 18 | MyTH02.startTempConv(true,true); |
superphil06 | 1:8326614f3037 | 19 | iTime= MyTH02.waitEndConversion();// wait until onversion is done |
superphil06 | 1:8326614f3037 | 20 | printf ("\n\r time=%d",iTime); |
superphil06 | 0:f1951c6c9187 | 21 | |
superphil06 | 0:f1951c6c9187 | 22 | |
superphil06 | 0:f1951c6c9187 | 23 | while(1) { |
superphil06 | 1:8326614f3037 | 24 | |
superphil06 | 1:8326614f3037 | 25 | MyTH02.startTempConv(true,true); |
superphil06 | 0:f1951c6c9187 | 26 | iTime= MyTH02.waitEndConversion();// wait until onversion is done |
superphil06 | 1:8326614f3037 | 27 | iTempbrute= MyTH02.getConversionValue(); |
superphil06 | 0:f1951c6c9187 | 28 | iTemp=MyTH02.getLastRawTemp(); |
superphil06 | 1:8326614f3037 | 29 | printf ("\n\r temp value=%d %d",iTemp,iTempbrute ); |
superphil06 | 1:8326614f3037 | 30 | |
superphil06 | 0:f1951c6c9187 | 31 | |
superphil06 | 0:f1951c6c9187 | 32 | MyTH02.startRHConv(true,true); |
superphil06 | 0:f1951c6c9187 | 33 | iTime= MyTH02.waitEndConversion();// wait until onversion is done |
superphil06 | 1:8326614f3037 | 34 | printf ("\n\r time=%d",iTime); |
superphil06 | 0:f1951c6c9187 | 35 | iRHbrute= MyTH02.getConversionValue(); |
superphil06 | 0:f1951c6c9187 | 36 | iRH=MyTH02.getLastRawRH(); |
superphil06 | 1:8326614f3037 | 37 | printf ("\n\r RH value=%d %d",iRH,iRHbrute ); |
superphil06 | 0:f1951c6c9187 | 38 | |
superphil06 | 0:f1951c6c9187 | 39 | |
superphil06 | 1:8326614f3037 | 40 | wait_ms(100); |
superphil06 | 0:f1951c6c9187 | 41 | |
superphil06 | 0:f1951c6c9187 | 42 | |
superphil06 | 0:f1951c6c9187 | 43 | |
superphil06 | 0:f1951c6c9187 | 44 | |
superphil06 | 0:f1951c6c9187 | 45 | } |
superphil06 | 0:f1951c6c9187 | 46 | } |