Dependencies: SSD1306 TSL2561 mbed DHT22 OneWire
Diff: main.cpp
- Revision:
- 2:34f81c0f5176
- Parent:
- 0:9904b68365e4
- Child:
- 3:4e142bba2a8e
--- a/main.cpp Tue Oct 17 10:19:42 2017 +0000 +++ b/main.cpp Mon Oct 30 15:53:56 2017 +0000 @@ -6,36 +6,53 @@ #include "ssd1306.h" #include "standard_font.h" #include "bold_font.h" +#include "DHT22.h" +#include "DS1820.h" SSD1306 oled(D3 /* cs */, A0 /* reset */, A7 /* dc */, A1 /* clock */, A6 /* data */); TSL2561 lum(PA_10,PA_9); AnalogIn moisture(MOIST_PIN); +Serial sigfox(PB_6, PB_7); +DHT22 Capt_temp_hum(A2); +DS1820 ds1820(A4); // substitute A4 with actual mbed pin name connected to the DS1820 data pin int main() { oled.initialise(); oled.clear(); oled.set_contrast(255); // max contrast - oled.set_font(bold_font, 8); - oled.printf("Heading\r\n"); - - oled.set_font(standard_font, 6); - oled.printf("Hello World!\r\n"); - oled.printf("Some more text here..."); - + if(ds1820.begin()){ + ds1820.startConversion(); // start temperature conversion + oled.printf("DS1820 Conversion started"); + wait(1.0); + } + else oled.printf("No DS1820 sensor found!\r\n"); oled.update(); - + int temp, hum, temp_sol; + char a; while (1) { - wait(2); + wait(10); + temp = (int) (Capt_temp_hum.getTemperature()/10); + hum = (int) (Capt_temp_hum.getHumidity()/10); + temp_sol = (int) ds1820.read(); + ds1820.startConversion(); + wait(1); + a='%'; oled.scroll_up(); oled.update(); oled.set_font(bold_font, 8); - //oled.printf("Quentin t cheum!\r\n"); - oled.printf("Moisture is %2.2f\r\n", (float) moisture); - oled.printf("Lum : %+5.1f lux\r\n", lum.lux()); - oled.printf("\n"); + Capt_temp_hum.sample(); + //oled.printf("Moisture is %2.2f\r\n", (float) moisture); + //oled.printf("Lum : %+5.1f lux\r\n", lum.lux()); + oled.printf("Temp : %d oC\r\n", temp); + oled.printf("Humidite : %d%c\r\n", hum, a); + oled.printf("Temp sol : %d\r\n", temp_sol); + //oled.printf("\n"); + sigfox.printf("AT$SF="); + sigfox.printf("%02x %02x %02x", temp_sol); + sigfox.printf("\r\n"); } } \ No newline at end of file