Sigfox project
Dependencies: mbed TCS34725 WakeUp DHT TSL2561_I2C DS1820
main.cpp@2:e153d5219f93, 2019-10-15 (annotated)
- Committer:
- Mohamed_Sadialiou
- Date:
- Tue Oct 15 09:50:21 2019 +0000
- Revision:
- 2:e153d5219f93
- Parent:
- 1:07835f780c89
- Child:
- 3:a5b1e083ffd2
ajout capteur humidite sol
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
youdllo5 | 0:cfed96a14467 | 1 | #include "mbed.h" |
ran_ghe | 1:07835f780c89 | 2 | #include "DS1820.h" |
youdllo5 | 0:cfed96a14467 | 3 | #include "DHT.h" |
youdllo5 | 0:cfed96a14467 | 4 | #include "TCS3472_I2C.h" |
youdllo5 | 0:cfed96a14467 | 5 | |
youdllo5 | 0:cfed96a14467 | 6 | //DigitalOut led(LED3); |
youdllo5 | 0:cfed96a14467 | 7 | Serial pc(USBTX, USBRX); |
youdllo5 | 0:cfed96a14467 | 8 | DHT dht(A1, 22); |
youdllo5 | 0:cfed96a14467 | 9 | TCS3472_I2C rgb_sensor( PB_4, PA_7 ); |
Mohamed_Sadialiou | 2:e153d5219f93 | 10 | AnalogIn ain(A0); // humidity sol |
ran_ghe | 1:07835f780c89 | 11 | DS1820 temp_sol(A2); |
youdllo5 | 0:cfed96a14467 | 12 | |
youdllo5 | 0:cfed96a14467 | 13 | int main(){ |
youdllo5 | 0:cfed96a14467 | 14 | |
youdllo5 | 0:cfed96a14467 | 15 | int data; |
youdllo5 | 0:cfed96a14467 | 16 | rgb_sensor.enablePowerAndRGBC(); |
youdllo5 | 0:cfed96a14467 | 17 | rgb_sensor.setIntegrationTime(100); |
youdllo5 | 0:cfed96a14467 | 18 | int rgb_readings[4]; |
Mohamed_Sadialiou | 2:e153d5219f93 | 19 | int hum_sol; |
youdllo5 | 0:cfed96a14467 | 20 | |
youdllo5 | 0:cfed96a14467 | 21 | |
ran_ghe | 1:07835f780c89 | 22 | //erreur temp_sol |
ran_ghe | 1:07835f780c89 | 23 | if(temp_sol.unassignedProbe(A2)) |
ran_ghe | 1:07835f780c89 | 24 | { |
ran_ghe | 1:07835f780c89 | 25 | pc.printf("error temperature_sol"); |
ran_ghe | 1:07835f780c89 | 26 | } |
ran_ghe | 1:07835f780c89 | 27 | |
youdllo5 | 0:cfed96a14467 | 28 | while(1){ |
ran_ghe | 1:07835f780c89 | 29 | //Capteur air |
ran_ghe | 1:07835f780c89 | 30 | //data = dht.readData(); |
youdllo5 | 0:cfed96a14467 | 31 | |
ran_ghe | 1:07835f780c89 | 32 | |
ran_ghe | 1:07835f780c89 | 33 | //Capteur RGB |
ran_ghe | 1:07835f780c89 | 34 | |
ran_ghe | 1:07835f780c89 | 35 | /*rgb_sensor.getAllColors(rgb_readings); |
youdllo5 | 0:cfed96a14467 | 36 | //led = !led; |
youdllo5 | 0:cfed96a14467 | 37 | if(data == ERROR_NONE){ |
youdllo5 | 0:cfed96a14467 | 38 | pc.printf("La temperature de la salle est: %.2f et Humidite est: %.2f\n", dht.ReadTemperature(CELCIUS), dht.ReadHumidity()); |
youdllo5 | 0:cfed96a14467 | 39 | } |
youdllo5 | 0:cfed96a14467 | 40 | else{ |
youdllo5 | 0:cfed96a14467 | 41 | //pc.printf("Erreur numero: %d\n", data); |
ran_ghe | 1:07835f780c89 | 42 | } |
ran_ghe | 1:07835f780c89 | 43 | pc.printf( "red: %d, green: %d, blue: %d, clear: %d\n", rgb_readings[0], rgb_readings[1], rgb_readings[2], rgb_readings[3] ); |
ran_ghe | 1:07835f780c89 | 44 | wait_ms(5000);*/ |
ran_ghe | 1:07835f780c89 | 45 | |
Mohamed_Sadialiou | 2:e153d5219f93 | 46 | //capteur humidite sol |
Mohamed_Sadialiou | 2:e153d5219f93 | 47 | hum_sol = (int)(((0.78 - ain.read())*100)/0.38); |
Mohamed_Sadialiou | 2:e153d5219f93 | 48 | pc.printf ("l'humidite du sol est %d%\n", hum_sol); // humidity sol |
Mohamed_Sadialiou | 2:e153d5219f93 | 49 | |
ran_ghe | 1:07835f780c89 | 50 | //Capteur temperature sol |
ran_ghe | 1:07835f780c89 | 51 | temp_sol.convertTemperature(true, DS1820::all_devices); |
ran_ghe | 1:07835f780c89 | 52 | pc.printf("temperature : %.1f\n", temp_sol.temperature()); |
ran_ghe | 1:07835f780c89 | 53 | wait(3); |
youdllo5 | 0:cfed96a14467 | 54 | |
youdllo5 | 0:cfed96a14467 | 55 | } |
youdllo5 | 0:cfed96a14467 | 56 | } |