From 68449846c16a883c462e3b338ecc37f8bde49ff5 Mon Sep 17 00:00:00 2001 From: Laurent Deleers Date: Wed, 15 Apr 2020 08:42:59 +0200 Subject: [PATCH] adapt with board type for bmp280 --- arduino-envirstation.ino | 99 ++++++++++++---------------------------- doc/Documentation.md | 42 +++++++++++++++++ doc/Todos.md | 25 ++++++++++ doc/displayLayout.md | 11 ----- 4 files changed, 95 insertions(+), 82 deletions(-) create mode 100644 doc/Documentation.md create mode 100644 doc/Todos.md delete mode 100644 doc/displayLayout.md diff --git a/arduino-envirstation.ino b/arduino-envirstation.ino index 27ccf65..ceadb89 100644 --- a/arduino-envirstation.ino +++ b/arduino-envirstation.ino @@ -1,37 +1,19 @@ // Arduino Environment Station for Wemos D1 Mini -// BUSY -> D0 = GPIO16 -// RST -> D4 = GPIO2 -// DC -> D3 = GPIO0 -// CS -> D8 = GPIO15 (ADD 1Kohm pulldown resistor !!!) -// CLK -> D5 = GPIO14 -// DIN -> D7 = GPIO13 -// GND -> GND -// 3.3V -> 3.3V - - #include -// #include -#include +#include // pressure sensor #include -/* -#define BMP_SCK (13) -#define BMP_MISO (12) -#define BMP_MOSI (11) -#define BMP_CS (10) -*/ #define HEAD_HEIGHT 18 #include "DHT.h" -// DHT -> D6 -#define DHTPIN 12 // DHT Sensor PIN -#define DHTTYPE DHT22 // DHT Sensor Type +#define DHTPIN 12 // DHT Sensor PIN +#define DHTTYPE DHT22 // DHT Sensor Type -#include "NTPtimeESP.h" +#include "NTPtimeESP.h" // NTP Lib -#include -#include +#include // ePaper Lib +#include // ePaper 4.2 #include GxEPD_BitmapExamples @@ -41,42 +23,17 @@ #include #include #include - +// Graphic Lib #include #include char *ssid = "lauIOT"; // Set you WiFi SSID -char *password = "superiot1"; // Set you WiFi password +char *password = "superiot1"; // Set you WiFi password -GxIO_Class io(SPI, /*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2); // arbitrary selection of D3(=0), D4(=2), selected for default of GxEPD_Class -GxEPD_Class display(io, /*RST=D4*/ 2, /*BUSY=D0*/ 16); // default selection of D4(=2), D2(=4) - -/* - -TODOS ------ - - Draw Head OK - - - Draw Title OK - - Draw Widget OK - - Integrate TempS OK - - - Draw T° OK - - - Draw HR OK - - Integrate Pressure OK - - - Draw Press OK - - Draw min max OK - - Integrate Time OK - - - Draw Time OK - - Get variables private - - Publish REST API - - Show Temp & hydro graph - - Make formatting nicer :) - - Make it configurable (web interface) - - Timezone - - Wifi credentials - - reset high low -*/ +GxIO_Class io(SPI, /*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2); +GxEPD_Class display(io, /*RST=D4*/ 2, /*BUSY=D0*/ 16); DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor for normal 16mhz Arduino @@ -156,33 +113,33 @@ void setup() { Serial.begin(115200); Serial.println(); - Serial.println("Start setup"); + Serial.println("SETUP - Start setup"); /* SETUP WIFI */ - Serial.println("Connecting to Wi-Fi"); + Serial.println("SETUP - Connecting to Wi-Fi"); WiFi.mode(WIFI_STA); WiFi.begin (ssid, password); while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); } - Serial.println("."); - Serial.println("WiFi connected."); + Serial.println(".\n\n"); + Serial.println("SETUP - WiFi connected."); // Start the server server.begin(); - Serial.println("Server started"); + Serial.println("SETUP - Server started"); - Serial.print("Use this URL : http://"); + Serial.print("SETUP - Use this URL : http://"); Serial.print(WiFi.localIP()); Serial.println("/"); /* SETUP TEMP SENSOR */ display.init(115200); // enable diagnostic output on Serial - Serial.println("setup dht"); + Serial.println("SETUP - setup dht"); dht.begin(); /* SETUP PRESSURE SENSOR */ - Serial.println("setup pressure sensor"); - if (!bmp.begin()) { + Serial.println("SETUP - setup pressure sensor"); + if (!bmp.begin(0x76,0x58)) { Serial.println(F("Could not find a valid BMP280 sensor, check wiring!")); while (1); } @@ -199,7 +156,7 @@ void setup() /* INIT min/max to something that will be overwrited */ E = Environment(); - Serial.println("setup done"); + Serial.println("SETUP - setup done"); delay(1000); ref_time = millis(); @@ -212,7 +169,7 @@ void loop() if ( (millis() - ref_time) >= 10000 ) { // On attends depuis plus de 10 secondes. - Serial.println("Start Evt"); + Serial.println("DBG - Start Evt"); retreiveData(&E); drawDisplay(&E); ref_time = millis(); @@ -223,7 +180,7 @@ void loop() } // Wait until the client sends some data - Serial.println("new client"); + Serial.println("DBG - new client"); while(!client.available()) { delay(1); } @@ -240,7 +197,7 @@ void loop() ptr = strtok(NULL, delim); } - Serial.println(" Request with arguments : [" + (String)path[1] + "][" + (String)path[2] + "][" + (String)path[3] + "] "); + Serial.println("DBG - Request with arguments : [" + (String)path[1] + "][" + (String)path[2] + "][" + (String)path[3] + "] "); if(path[1].equals("GET")) { if(path[2].equals("ENVIR")) { sprintf(xmlFeedback,"%.2f%.2f%u",E.getTemp(),E.getHumid(),E.getPress()); @@ -253,7 +210,7 @@ void loop() * PATH 3 = PARAMETER */ else { - client.println("Message received !!!\n"); + client.println("DBG - Message received !!!\n"); } delay(1); } @@ -266,9 +223,9 @@ void retreiveData(Environment *E) { E->setHumid( dht.readHumidity() ); E->setPress( (int)round(bmp.readPressure()/100) ); E->setDateTime( NTPch.getNTPtime(1.0, 1)); - Serial.println("temp : " + String(E->getTemp())); - Serial.println("humid : " + String(E->getHumid())); - Serial.println("pressure : " + String(E->getPress())); + Serial.println("DBG - temp : " + String(E->getTemp())); + Serial.println("DBG - humid : " + String(E->getHumid())); + Serial.println("DBG - pressure : " + String(E->getPress())); } void drawDisplay(Environment *E) { @@ -309,7 +266,7 @@ void drawWidget(unsigned char widgetPos, String title, const GFXfont* f, String /* Header 20px height, Value 70px height */ int16_t x1, y1; uint16_t w, h; - Serial.print("Draw Widget "); Serial.println(widgetPos); + Serial.print("DBG - Draw Widget "); Serial.println(widgetPos); uint16_t box_w = 130; uint16_t box_h = 86; uint16_t box_x = (int)(((widgetPos%3)*133)+2); diff --git a/doc/Documentation.md b/doc/Documentation.md new file mode 100644 index 0000000..1cd168a --- /dev/null +++ b/doc/Documentation.md @@ -0,0 +1,42 @@ +## Board Pinnout + +### Screen +| Screen Pin | Board Pin | GPIO | comment | +| ---- | ---- | ------ | -- | +| BUSY | D0 | GPIO16 | | +| RST | D4 | GPIO2 | | +| DC | D3 | GPIO0 | | +| CS | D8 | GPIO15 | 1K pulldown | +| CLK | D5 | GPIO14 | | +| DIN | D7 | GPIO13 | | +| GND | GND | | | +| 3.3V | 3.3V | | | + +### BMP280 (pressure) + +| sensor Pin | Board Pin | GPIO | comment +| -- | -- | -- | -- | +| SCL | D1 | GPIO5 | used as i2c | +| SDA | D2 | GPIO4 | used as i2c | +| GDN | GND | | | +| 3.3V | 3.3V | | | + +### DHT22 (temp & hydro) + +| sensor Pin | Board Pin | GPIO | comment | +| -- | -- | -- | -- | +| DATA | D6 | GPIO12 | 10K pullup | +| GDN | GND | | | +| 5V | 5V | | | + + +## Display configuration + + + header of 28 pixel height ||| +|----------|----------|----------| +| widget 1
130x90
at 2,30 | widget 2
130x90
at 135,30 | widget 3
130x90
at 138,30 | +| widget 4
130x90
at 2,120 | widget 5
130x90
at 135,120 | widget 6
130x90
at 138,120 | +| widget 7
130x90
at 2,210 | widget 8
130x90
at 135,210 | widget 9
130x90
at 138,210 | + + diff --git a/doc/Todos.md b/doc/Todos.md new file mode 100644 index 0000000..aec1be4 --- /dev/null +++ b/doc/Todos.md @@ -0,0 +1,25 @@ + +## TODOS + + +- [x] Draw Head + - [x] Draw Title +- [x] Draw Widget +- [x] Integrate TempS + - [x] Draw T° + - [x] Draw HR + - [x] Integrate Pressure + - [x] Draw Press + - [x] Draw min max + - [x] Integrate Time + - [x] Draw Time + - [ ] Get variables private + - [ ] Publish REST API + - [ ] Show Temp & hydro graph + - [ ] Make formatting nicer :) + - [ ] Make it configurable (web interface) + - [ ] Timezone + - [ ] Wifi credentials + - [ ] reset high low + + diff --git a/doc/displayLayout.md b/doc/displayLayout.md deleted file mode 100644 index df5c73d..0000000 --- a/doc/displayLayout.md +++ /dev/null @@ -1,11 +0,0 @@ -## Display config - - - - header of 28 pixel height ||| -|----------|----------|----------| -| widget 1
130x90
at 2,30 | widget 2
130x90
at 135,30 | widget 3
130x90
at 138,30 | -| widget 4
130x90
at 2,120 | widget 5
130x90
at 135,120 | widget 6
130x90
at 138,120 | -| widget 7
130x90
at 2,210 | widget 8
130x90
at 135,210 | widget 9
130x90
at 138,210 | - -