diff options
Diffstat (limited to 'sensor')
m--------- | sensor/DHTesp | 0 | ||||
-rw-r--r-- | sensor/Makefile | 10 | ||||
-rw-r--r-- | sensor/README.rst.txt | 8 | ||||
m--------- | sensor/esp8266-oled-ssd1306 | 0 | ||||
-rw-r--r-- | sensor/thermostat.ino | 36 |
5 files changed, 54 insertions, 0 deletions
diff --git a/sensor/DHTesp b/sensor/DHTesp new file mode 160000 +Subproject 643722c48fef78e6243089814c8544553674b48 diff --git a/sensor/Makefile b/sensor/Makefile new file mode 100644 index 0000000..68ba91f --- /dev/null +++ b/sensor/Makefile @@ -0,0 +1,10 @@ +SKETCH = thermostat.ino +CUSTOM_LIBS = DHTesp esp8266-oled-ssd1306 + +UPLOAD_PORT = /dev/ttyUSB0 +BOARD = lolin32 + +ESP_ROOT = $(HOME)/Arduino/hardware/espressif/esp32/ +CHIP = esp32 + +include $(HOME)/src/makeEspArduino/makeEspArduino.mk diff --git a/sensor/README.rst.txt b/sensor/README.rst.txt new file mode 100644 index 0000000..f97de5c --- /dev/null +++ b/sensor/README.rst.txt @@ -0,0 +1,8 @@ +Some links: + +* links to some ESP32 libraries + https://www.arduinolibraries.info/architectures/esp32 +* the OLED library https://github.com/ThingPulse/esp8266-oled-ssd1306 +* vague guide to the OLED library + https://diyprojects.io/using-i2c-128x64-0-96-ssd1306-oled-display-arduino/ +* the sensor library https://github.com/beegee-tokyo/DHTesp diff --git a/sensor/esp8266-oled-ssd1306 b/sensor/esp8266-oled-ssd1306 new file mode 160000 +Subproject 1254ef967da6785f420f0895dae9228258cfb87 diff --git a/sensor/thermostat.ino b/sensor/thermostat.ino new file mode 100644 index 0000000..63f87f0 --- /dev/null +++ b/sensor/thermostat.ino @@ -0,0 +1,36 @@ +#include <Wire.h> +#include "SSD1306.h" +#include "DHTesp.h" + +SSD1306 display(0x3c, 5, 4); +DHTesp dht; + +void setup() { + dht.setup(13,DHTesp::AUTO_DETECT); + + display.init(); + display.connect(); + display.displayOn(); +} + +void loop() { + delay(dht.getMinimumSamplingPeriod()); + float humidity = dht.getHumidity(); + float temperature = dht.getTemperature(); + + if (dht.getStatus() == DHTesp::ERROR_TIMEOUT) return; + + display.clear(); + + String line; + line = "T:"; line += temperature; + display.drawString(0,0,line); + line = "H:"; line += humidity; + display.drawString(50,0,line); + display.drawString(0,10,dht.getStatusString()); + + display.drawProgressBar(5,25,120,10,int(temperature)); + display.drawProgressBar(5,40,120,10,int(humidity)); + + display.display(); +} |