aboutsummaryrefslogtreecommitdiff
path: root/main.ino
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2022-01-28 16:42:14 +0000
committerdakkar <dakkar@thenautilus.net>2022-01-28 16:42:14 +0000
commit99be6b6d2a0f5a31b1d9ade85e2988ee357e4294 (patch)
treeff5789a86445ab497e0c7fe6c41b7ecadd1042ed /main.ino
parentsensirion example, works (diff)
downloadenv-sensor-99be6b6d2a0f5a31b1d9ade85e2988ee357e4294.tar.gz
env-sensor-99be6b6d2a0f5a31b1d9ade85e2988ee357e4294.tar.bz2
env-sensor-99be6b6d2a0f5a31b1d9ade85e2988ee357e4294.zip
show values on eink display
Diffstat (limited to 'main.ino')
-rw-r--r--main.ino49
1 files changed, 38 insertions, 11 deletions
diff --git a/main.ino b/main.ino
index bc27deb..604bdef 100644
--- a/main.ino
+++ b/main.ino
@@ -2,6 +2,20 @@
#include <SensirionI2CScd4x.h>
#include <Wire.h>
+#define LILYGO_T5_V213 // needed for the display libraries
+
+#include <boards.h>
+#include <GxEPD.h>
+#include <GxGDEH0213B73/GxGDEH0213B73.h> // screen model, probably correct
+#include <Fonts/FreeMonoBold12pt7b.h>
+#include <GxIO/GxIO_SPI/GxIO_SPI.h>
+#include <GxIO/GxIO.h>
+
+GxIO_Class io(SPI, EPD_CS, EPD_DC, EPD_RSET);
+GxEPD_Class display(io, EPD_RSET, EPD_BUSY);
+SPIClass SDSPI(VSPI); // for sdcard? maybe?
+
+
SensirionI2CScd4x scd4x;
void printUint16Hex(uint16_t value) {
@@ -28,6 +42,15 @@ void setup() {
Wire.begin(21,22);
+ SPI.begin(EPD_SCLK, EPD_MISO, EPD_MOSI);
+
+ display.init();
+ display.setTextColor(GxEPD_BLACK);
+ display.setRotation(3);
+ display.setFont(&FreeMonoBold12pt7b);
+ display.fillScreen(GxEPD_WHITE);
+ display.update();
+
uint16_t error;
char errorMessage[256];
@@ -75,20 +98,24 @@ void loop() {
float temperature = 0.0f;
float humidity = 0.0f;
error = scd4x.readMeasurement(co2, temperature, humidity);
+
+ display.fillScreen(GxEPD_WHITE);
+ display.setCursor(0,20);
+
if (error) {
- Serial.print("Error trying to execute readMeasurement(): ");
+ display.print("read error: ");
errorToString(error, errorMessage, 256);
- Serial.println(errorMessage);
+ display.println(errorMessage);
} else if (co2 == 0) {
- Serial.println("Invalid sample detected, skipping.");
+ display.println("Invalid sample detected, skipping.");
} else {
- Serial.print("Co2:");
- Serial.print(co2);
- Serial.print("\t");
- Serial.print("Temperature:");
- Serial.print(temperature);
- Serial.print("\t");
- Serial.print("Humidity:");
- Serial.println(humidity);
+ display.print("Co2:");
+ display.println(co2);
+ display.print("Temperature:");
+ display.println(temperature);
+ display.print("Humidity:");
+ display.println(humidity);
}
+
+ display.update();
}