Version finale
Dependencies: mbed
Fork of Main_V3_Old by
Diff: main.cpp
- Revision:
- 6:f552ca0f5165
- Parent:
- 5:ae57f8977663
- Child:
- 7:2748b1a2742c
diff -r ae57f8977663 -r f552ca0f5165 main.cpp --- a/main.cpp Mon Nov 20 13:12:03 2017 +0000 +++ b/main.cpp Mon Dec 18 14:00:21 2017 +0000 @@ -3,7 +3,9 @@ #include "OneWireDefs.h" #include "TSL2561.h" #include "DHT22.h" - +#include "bold_font.h" +#include "standard_font.h" +#include "ssd1306.h" #define THERMOMETER DS18B20 @@ -11,7 +13,8 @@ TSL2561 LUM(PB_7, PB_6); // Luminosité (I2C:SDA,SCL) DHT22 Tem_Hum_A(PA_11); // Température & Humidité air AnalogIn Humidite(PA_0); -Serial PC(PA_2, PA_3); +SSD1306 ecran(D3 /* cs */, D6/* reset */, A5 /* dc */, A4 /* clock */, D2 /* data */); +//Serial PC(PA_2, PA_3); Serial sigfox(PA_9, PA_10); DigitalOut myled(LED1); @@ -20,10 +23,14 @@ int main() { - + ecran.initialise(); + ecran.clear(); + ecran.set_contrast(255); + ecran.set_font(bold_font, 8); + serie.printf("New Program \r\n"); // device( crcOn, useAddress, parasitic, mbed pin ) - THERMOMETER device(true, true, false, PB_0); + THERMOMETER device(true, true, false, PA_8); while (!device.initialize()); // keep calling until it works @@ -34,18 +41,39 @@ device.readTemperature(); Temp_air = (int)(Tem_Hum_A.getTemperature()/10); Hum_air = (int) (Tem_Hum_A.getHumidity()/10); - Hum_sol = (int)(Humidite.read()) * 100; + Hum_sol = (int)(Humidite.read()* 100) ; Temp_sol = (int)device.readTemperature(); Lum = (int) LUM.lux(); - printf("Air Temperature : %d\n\r", Tem_Hum_A.getTemperature()/10); - printf("Air Humidity is %d\n\r", Tem_Hum_A.getHumidity()/10); + printf("Temperature air: %d\n\r", Tem_Hum_A.getTemperature()/10); + printf("Hum air: %d\n\r", Tem_Hum_A.getHumidity()/10); serie.printf("\rLum: %f \r\n", LUM.lux()); - serie.printf("Hum: %f \n\r",Humidite.read()*100); - serie.printf("Temperature du sol: %d \n\r",Temp_sol); - serie.printf("Lum: %d \r\n", Lum); - printf("---------------------------------------------\n\r"); + serie.printf("Temperature sol: %d \n\r",Temp_sol); + serie.printf("Hum sol: %f \n\r",Humidite.read()*100); + printf("------------------------------------------------------------\n\r"); sigfox.printf("AT$SS=%02x %02x %02x %02x %02x \r\n", Temp_sol, Temp_air, Lum, Hum_sol, Hum_air); - wait(30); + + //OLED + ecran.set_font(bold_font, 8); + ecran.printf("Valeurs"); + ecran.printf("\r\n"); + ecran.update(); + ecran.set_font(standard_font, 6); + ecran.printf("Temp air = %d",Temp_air ); + ecran.printf("\r\n"); + ecran.printf("Hum air = %d", Tem_Hum_A.getHumidity()/10); + ecran.printf("\r\n"); + ecran.printf("Lum = %f", LUM.lux()); + ecran.printf("\r\n"); + ecran.printf("Temp sol = %d",Temp_sol ); + ecran.printf("\r\n"); + ecran.printf("Hum sol = %f", Hum_sol); + ecran.printf("\r\n"); + ecran.update(); + ecran.clear(); + + + + wait(10); } return EXIT_SUCCESS; }