Version finale

Dependencies:   mbed

Fork of Main_V3_Old by EI2I_4_projet_1_2017-2018

Committer:
ramialjed
Date:
Mon Dec 18 14:00:21 2017 +0000
Revision:
6:f552ca0f5165
Parent:
5:ae57f8977663
Child:
7:2748b1a2742c
je suis booo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ramialjed 3:534235b99bc6 1 #include "mbed.h"
ChrisnieM 4:784c4b53a3d4 2 #include "DS18B20.h"
ChrisnieM 4:784c4b53a3d4 3 #include "OneWireDefs.h"
ramialjed 3:534235b99bc6 4 #include "TSL2561.h"
ramialjed 5:ae57f8977663 5 #include "DHT22.h"
ramialjed 6:f552ca0f5165 6 #include "bold_font.h"
ramialjed 6:f552ca0f5165 7 #include "standard_font.h"
ramialjed 6:f552ca0f5165 8 #include "ssd1306.h"
ramialjed 3:534235b99bc6 9
ChrisnieM 4:784c4b53a3d4 10 #define THERMOMETER DS18B20
ChrisnieM 4:784c4b53a3d4 11
ChrisnieM 4:784c4b53a3d4 12 Serial serie(SERIAL_TX, SERIAL_RX);
ChrisnieM 4:784c4b53a3d4 13 TSL2561 LUM(PB_7, PB_6); // Luminosité (I2C:SDA,SCL)
ramialjed 5:ae57f8977663 14 DHT22 Tem_Hum_A(PA_11); // Température & Humidité air
ramialjed 3:534235b99bc6 15 AnalogIn Humidite(PA_0);
ramialjed 6:f552ca0f5165 16 SSD1306 ecran(D3 /* cs */, D6/* reset */, A5 /* dc */, A4 /* clock */, D2 /* data */);
ramialjed 6:f552ca0f5165 17 //Serial PC(PA_2, PA_3);
ramialjed 5:ae57f8977663 18 Serial sigfox(PA_9, PA_10);
ChrisnieM 4:784c4b53a3d4 19 DigitalOut myled(LED1);
ramialjed 3:534235b99bc6 20
ramialjed 5:ae57f8977663 21 int i, Hum_sol, Temp_sol, Lum, Temp_air, Hum_air;
ramialjed 5:ae57f8977663 22
ChrisnieM 4:784c4b53a3d4 23 int main()
ChrisnieM 4:784c4b53a3d4 24 {
ramialjed 5:ae57f8977663 25
ramialjed 6:f552ca0f5165 26 ecran.initialise();
ramialjed 6:f552ca0f5165 27 ecran.clear();
ramialjed 6:f552ca0f5165 28 ecran.set_contrast(255);
ramialjed 6:f552ca0f5165 29 ecran.set_font(bold_font, 8);
ramialjed 6:f552ca0f5165 30
ramialjed 5:ae57f8977663 31 serie.printf("New Program \r\n");
ChrisnieM 4:784c4b53a3d4 32 // device( crcOn, useAddress, parasitic, mbed pin )
ramialjed 6:f552ca0f5165 33 THERMOMETER device(true, true, false, PA_8);
ChrisnieM 4:784c4b53a3d4 34
ChrisnieM 4:784c4b53a3d4 35 while (!device.initialize()); // keep calling until it works
ChrisnieM 4:784c4b53a3d4 36
ChrisnieM 4:784c4b53a3d4 37 while (true)
ChrisnieM 4:784c4b53a3d4 38 {
ChrisnieM 4:784c4b53a3d4 39 myled = !myled;
ramialjed 5:ae57f8977663 40 Tem_Hum_A.sample();
ChrisnieM 4:784c4b53a3d4 41 device.readTemperature();
ramialjed 5:ae57f8977663 42 Temp_air = (int)(Tem_Hum_A.getTemperature()/10);
ramialjed 5:ae57f8977663 43 Hum_air = (int) (Tem_Hum_A.getHumidity()/10);
ramialjed 6:f552ca0f5165 44 Hum_sol = (int)(Humidite.read()* 100) ;
ramialjed 5:ae57f8977663 45 Temp_sol = (int)device.readTemperature();
ramialjed 5:ae57f8977663 46 Lum = (int) LUM.lux();
ramialjed 6:f552ca0f5165 47 printf("Temperature air: %d\n\r", Tem_Hum_A.getTemperature()/10);
ramialjed 6:f552ca0f5165 48 printf("Hum air: %d\n\r", Tem_Hum_A.getHumidity()/10);
ramialjed 5:ae57f8977663 49 serie.printf("\rLum: %f \r\n", LUM.lux());
ramialjed 6:f552ca0f5165 50 serie.printf("Temperature sol: %d \n\r",Temp_sol);
ramialjed 6:f552ca0f5165 51 serie.printf("Hum sol: %f \n\r",Humidite.read()*100);
ramialjed 6:f552ca0f5165 52 printf("------------------------------------------------------------\n\r");
ramialjed 5:ae57f8977663 53 sigfox.printf("AT$SS=%02x %02x %02x %02x %02x \r\n", Temp_sol, Temp_air, Lum, Hum_sol, Hum_air);
ramialjed 6:f552ca0f5165 54
ramialjed 6:f552ca0f5165 55 //OLED
ramialjed 6:f552ca0f5165 56 ecran.set_font(bold_font, 8);
ramialjed 6:f552ca0f5165 57 ecran.printf("Valeurs");
ramialjed 6:f552ca0f5165 58 ecran.printf("\r\n");
ramialjed 6:f552ca0f5165 59 ecran.update();
ramialjed 6:f552ca0f5165 60 ecran.set_font(standard_font, 6);
ramialjed 6:f552ca0f5165 61 ecran.printf("Temp air = %d",Temp_air );
ramialjed 6:f552ca0f5165 62 ecran.printf("\r\n");
ramialjed 6:f552ca0f5165 63 ecran.printf("Hum air = %d", Tem_Hum_A.getHumidity()/10);
ramialjed 6:f552ca0f5165 64 ecran.printf("\r\n");
ramialjed 6:f552ca0f5165 65 ecran.printf("Lum = %f", LUM.lux());
ramialjed 6:f552ca0f5165 66 ecran.printf("\r\n");
ramialjed 6:f552ca0f5165 67 ecran.printf("Temp sol = %d",Temp_sol );
ramialjed 6:f552ca0f5165 68 ecran.printf("\r\n");
ramialjed 6:f552ca0f5165 69 ecran.printf("Hum sol = %f", Hum_sol);
ramialjed 6:f552ca0f5165 70 ecran.printf("\r\n");
ramialjed 6:f552ca0f5165 71 ecran.update();
ramialjed 6:f552ca0f5165 72 ecran.clear();
ramialjed 6:f552ca0f5165 73
ramialjed 6:f552ca0f5165 74
ramialjed 6:f552ca0f5165 75
ramialjed 6:f552ca0f5165 76 wait(10);
ramialjed 3:534235b99bc6 77 }
ChrisnieM 4:784c4b53a3d4 78 return EXIT_SUCCESS;
ChrisnieM 4:784c4b53a3d4 79 }