Sigfox project
Dependencies: mbed TCS34725 WakeUp DHT TSL2561_I2C DS1820
main.cpp@0:cfed96a14467, 2019-10-15 (annotated)
- Committer:
- youdllo5
- Date:
- Tue Oct 15 06:51:33 2019 +0000
- Revision:
- 0:cfed96a14467
- Child:
- 1:07835f780c89
first commit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
youdllo5 | 0:cfed96a14467 | 1 | #include "mbed.h" |
youdllo5 | 0:cfed96a14467 | 2 | |
youdllo5 | 0:cfed96a14467 | 3 | #include "DHT.h" |
youdllo5 | 0:cfed96a14467 | 4 | |
youdllo5 | 0:cfed96a14467 | 5 | #include "TCS3472_I2C.h" |
youdllo5 | 0:cfed96a14467 | 6 | |
youdllo5 | 0:cfed96a14467 | 7 | //DigitalOut led(LED3); |
youdllo5 | 0:cfed96a14467 | 8 | Serial pc(USBTX, USBRX); |
youdllo5 | 0:cfed96a14467 | 9 | |
youdllo5 | 0:cfed96a14467 | 10 | DHT dht(A1, 22); |
youdllo5 | 0:cfed96a14467 | 11 | |
youdllo5 | 0:cfed96a14467 | 12 | TCS3472_I2C rgb_sensor( PB_4, PA_7 ); |
youdllo5 | 0:cfed96a14467 | 13 | |
youdllo5 | 0:cfed96a14467 | 14 | int main(){ |
youdllo5 | 0:cfed96a14467 | 15 | |
youdllo5 | 0:cfed96a14467 | 16 | int data; |
youdllo5 | 0:cfed96a14467 | 17 | rgb_sensor.enablePowerAndRGBC(); |
youdllo5 | 0:cfed96a14467 | 18 | rgb_sensor.setIntegrationTime(100); |
youdllo5 | 0:cfed96a14467 | 19 | int rgb_readings[4]; |
youdllo5 | 0:cfed96a14467 | 20 | |
youdllo5 | 0:cfed96a14467 | 21 | |
youdllo5 | 0:cfed96a14467 | 22 | while(1){ |
youdllo5 | 0:cfed96a14467 | 23 | |
youdllo5 | 0:cfed96a14467 | 24 | data = dht.readData(); |
youdllo5 | 0:cfed96a14467 | 25 | rgb_sensor.getAllColors(rgb_readings); |
youdllo5 | 0:cfed96a14467 | 26 | //led = !led; |
youdllo5 | 0:cfed96a14467 | 27 | if(data == ERROR_NONE){ |
youdllo5 | 0:cfed96a14467 | 28 | pc.printf("La temperature de la salle est: %.2f et Humidite est: %.2f\n", dht.ReadTemperature(CELCIUS), dht.ReadHumidity()); |
youdllo5 | 0:cfed96a14467 | 29 | } |
youdllo5 | 0:cfed96a14467 | 30 | else{ |
youdllo5 | 0:cfed96a14467 | 31 | //pc.printf("Erreur numero: %d\n", data); |
youdllo5 | 0:cfed96a14467 | 32 | } |
youdllo5 | 0:cfed96a14467 | 33 | |
youdllo5 | 0:cfed96a14467 | 34 | pc.printf( "red: %d, green: %d, blue: %d, clear: %d\n", rgb_readings[0], rgb_readings[1], rgb_readings[2], rgb_readings[3] ); |
youdllo5 | 0:cfed96a14467 | 35 | wait_ms(5000); |
youdllo5 | 0:cfed96a14467 | 36 | |
youdllo5 | 0:cfed96a14467 | 37 | } |
youdllo5 | 0:cfed96a14467 | 38 | } |