adapt with board type for bmp280
This commit is contained in:
@@ -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 <Wire.h>
|
||||
// #include <SPI.h>
|
||||
#include <Adafruit_BMP280.h>
|
||||
#include <Adafruit_BMP280.h> // pressure sensor
|
||||
#include <ESP8266WiFi.h>
|
||||
/*
|
||||
#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
|
||||
|
||||
#include "NTPtimeESP.h"
|
||||
#include "NTPtimeESP.h" // NTP Lib
|
||||
|
||||
#include <GxEPD.h>
|
||||
#include <GxGDEW042T2/GxGDEW042T2.h>
|
||||
#include <GxEPD.h> // ePaper Lib
|
||||
#include <GxGDEW042T2/GxGDEW042T2.h> // ePaper 4.2
|
||||
|
||||
#include GxEPD_BitmapExamples
|
||||
|
||||
@@ -41,7 +23,7 @@
|
||||
#include <Fonts/FreeMonoBold18pt7b.h>
|
||||
#include <Fonts/FreeMonoBold24pt7b.h>
|
||||
#include <Fonts/FreeSansBold18pt7b.h>
|
||||
|
||||
// Graphic Lib
|
||||
#include <GxIO/GxIO_SPI/GxIO_SPI.h>
|
||||
#include <GxIO/GxIO.h>
|
||||
|
||||
@@ -50,33 +32,8 @@
|
||||
char *ssid = "lauIOT"; // Set you WiFi SSID
|
||||
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,"<temperature>%.2f</temperature><humidity>%.2f</humidity><pressure>%u</pressure>",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);
|
||||
|
||||
42
doc/Documentation.md
Normal file
42
doc/Documentation.md
Normal file
@@ -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 <br> 130x90 <br> at 2,30 | widget 2 <br> 130x90 <br> at 135,30 | widget 3 <br> 130x90 <br> at 138,30 |
|
||||
| widget 4 <br> 130x90 <br> at 2,120 | widget 5 <br> 130x90 <br> at 135,120 | widget 6 <br> 130x90 <br> at 138,120 |
|
||||
| widget 7 <br> 130x90 <br> at 2,210 | widget 8 <br> 130x90 <br> at 135,210 | widget 9 <br> 130x90 <br> at 138,210 |
|
||||
|
||||
|
||||
25
doc/Todos.md
Normal file
25
doc/Todos.md
Normal file
@@ -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
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
## Display config
|
||||
|
||||
|
||||
|
||||
header of 28 pixel height |||
|
||||
|----------|----------|----------|
|
||||
| widget 1 <br> 130x90 <br> at 2,30 | widget 2 <br> 130x90 <br> at 135,30 | widget 3 <br> 130x90 <br> at 138,30 |
|
||||
| widget 4 <br> 130x90 <br> at 2,120 | widget 5 <br> 130x90 <br> at 135,120 | widget 6 <br> 130x90 <br> at 138,120 |
|
||||
| widget 7 <br> 130x90 <br> at 2,210 | widget 8 <br> 130x90 <br> at 135,210 | widget 9 <br> 130x90 <br> at 138,210 |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user