adapt with board type for bmp280
This commit is contained in:
@@ -1,37 +1,19 @@
|
|||||||
|
|
||||||
// Arduino Environment Station for Wemos D1 Mini
|
// 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 <Wire.h>
|
||||||
// #include <SPI.h>
|
#include <Adafruit_BMP280.h> // pressure sensor
|
||||||
#include <Adafruit_BMP280.h>
|
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
/*
|
|
||||||
#define BMP_SCK (13)
|
|
||||||
#define BMP_MISO (12)
|
|
||||||
#define BMP_MOSI (11)
|
|
||||||
#define BMP_CS (10)
|
|
||||||
*/
|
|
||||||
#define HEAD_HEIGHT 18
|
#define HEAD_HEIGHT 18
|
||||||
|
|
||||||
#include "DHT.h"
|
#include "DHT.h"
|
||||||
// DHT -> D6
|
#define DHTPIN 12 // DHT Sensor PIN
|
||||||
#define DHTPIN 12 // DHT Sensor PIN
|
#define DHTTYPE DHT22 // DHT Sensor Type
|
||||||
#define DHTTYPE DHT22 // DHT Sensor Type
|
|
||||||
|
|
||||||
#include "NTPtimeESP.h"
|
#include "NTPtimeESP.h" // NTP Lib
|
||||||
|
|
||||||
#include <GxEPD.h>
|
#include <GxEPD.h> // ePaper Lib
|
||||||
#include <GxGDEW042T2/GxGDEW042T2.h>
|
#include <GxGDEW042T2/GxGDEW042T2.h> // ePaper 4.2
|
||||||
|
|
||||||
#include GxEPD_BitmapExamples
|
#include GxEPD_BitmapExamples
|
||||||
|
|
||||||
@@ -41,42 +23,17 @@
|
|||||||
#include <Fonts/FreeMonoBold18pt7b.h>
|
#include <Fonts/FreeMonoBold18pt7b.h>
|
||||||
#include <Fonts/FreeMonoBold24pt7b.h>
|
#include <Fonts/FreeMonoBold24pt7b.h>
|
||||||
#include <Fonts/FreeSansBold18pt7b.h>
|
#include <Fonts/FreeSansBold18pt7b.h>
|
||||||
|
// Graphic Lib
|
||||||
#include <GxIO/GxIO_SPI/GxIO_SPI.h>
|
#include <GxIO/GxIO_SPI/GxIO_SPI.h>
|
||||||
#include <GxIO/GxIO.h>
|
#include <GxIO/GxIO.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *ssid = "lauIOT"; // Set you WiFi SSID
|
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
|
GxIO_Class io(SPI, /*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2);
|
||||||
GxEPD_Class display(io, /*RST=D4*/ 2, /*BUSY=D0*/ 16); // default selection of D4(=2), D2(=4)
|
GxEPD_Class display(io, /*RST=D4*/ 2, /*BUSY=D0*/ 16);
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
|
|
||||||
DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor for normal 16mhz Arduino
|
DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor for normal 16mhz Arduino
|
||||||
|
|
||||||
@@ -156,33 +113,33 @@ void setup()
|
|||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println("Start setup");
|
Serial.println("SETUP - Start setup");
|
||||||
/* SETUP WIFI */
|
/* SETUP WIFI */
|
||||||
Serial.println("Connecting to Wi-Fi");
|
Serial.println("SETUP - Connecting to Wi-Fi");
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFi.begin (ssid, password);
|
WiFi.begin (ssid, password);
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
delay(500);
|
delay(500);
|
||||||
}
|
}
|
||||||
Serial.println(".");
|
Serial.println(".\n\n");
|
||||||
Serial.println("WiFi connected.");
|
Serial.println("SETUP - WiFi connected.");
|
||||||
// Start the server
|
// Start the server
|
||||||
server.begin();
|
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.print(WiFi.localIP());
|
||||||
Serial.println("/");
|
Serial.println("/");
|
||||||
|
|
||||||
/* SETUP TEMP SENSOR */
|
/* SETUP TEMP SENSOR */
|
||||||
display.init(115200); // enable diagnostic output on Serial
|
display.init(115200); // enable diagnostic output on Serial
|
||||||
Serial.println("setup dht");
|
Serial.println("SETUP - setup dht");
|
||||||
dht.begin();
|
dht.begin();
|
||||||
|
|
||||||
/* SETUP PRESSURE SENSOR */
|
/* SETUP PRESSURE SENSOR */
|
||||||
Serial.println("setup pressure sensor");
|
Serial.println("SETUP - setup pressure sensor");
|
||||||
if (!bmp.begin()) {
|
if (!bmp.begin(0x76,0x58)) {
|
||||||
Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
|
Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
@@ -199,7 +156,7 @@ void setup()
|
|||||||
/* INIT min/max to something that will be overwrited */
|
/* INIT min/max to something that will be overwrited */
|
||||||
E = Environment();
|
E = Environment();
|
||||||
|
|
||||||
Serial.println("setup done");
|
Serial.println("SETUP - setup done");
|
||||||
|
|
||||||
delay(1000);
|
delay(1000);
|
||||||
ref_time = millis();
|
ref_time = millis();
|
||||||
@@ -212,7 +169,7 @@ void loop()
|
|||||||
|
|
||||||
if ( (millis() - ref_time) >= 10000 ) {
|
if ( (millis() - ref_time) >= 10000 ) {
|
||||||
// On attends depuis plus de 10 secondes.
|
// On attends depuis plus de 10 secondes.
|
||||||
Serial.println("Start Evt");
|
Serial.println("DBG - Start Evt");
|
||||||
retreiveData(&E);
|
retreiveData(&E);
|
||||||
drawDisplay(&E);
|
drawDisplay(&E);
|
||||||
ref_time = millis();
|
ref_time = millis();
|
||||||
@@ -223,7 +180,7 @@ void loop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait until the client sends some data
|
// Wait until the client sends some data
|
||||||
Serial.println("new client");
|
Serial.println("DBG - new client");
|
||||||
while(!client.available()) {
|
while(!client.available()) {
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
@@ -240,7 +197,7 @@ void loop()
|
|||||||
ptr = strtok(NULL, delim);
|
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[1].equals("GET")) {
|
||||||
if(path[2].equals("ENVIR")) {
|
if(path[2].equals("ENVIR")) {
|
||||||
sprintf(xmlFeedback,"<temperature>%.2f</temperature><humidity>%.2f</humidity><pressure>%u</pressure>",E.getTemp(),E.getHumid(),E.getPress());
|
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
|
* PATH 3 = PARAMETER
|
||||||
*/
|
*/
|
||||||
else {
|
else {
|
||||||
client.println("Message received !!!\n");
|
client.println("DBG - Message received !!!\n");
|
||||||
}
|
}
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
@@ -266,9 +223,9 @@ void retreiveData(Environment *E) {
|
|||||||
E->setHumid( dht.readHumidity() );
|
E->setHumid( dht.readHumidity() );
|
||||||
E->setPress( (int)round(bmp.readPressure()/100) );
|
E->setPress( (int)round(bmp.readPressure()/100) );
|
||||||
E->setDateTime( NTPch.getNTPtime(1.0, 1));
|
E->setDateTime( NTPch.getNTPtime(1.0, 1));
|
||||||
Serial.println("temp : " + String(E->getTemp()));
|
Serial.println("DBG - temp : " + String(E->getTemp()));
|
||||||
Serial.println("humid : " + String(E->getHumid()));
|
Serial.println("DBG - humid : " + String(E->getHumid()));
|
||||||
Serial.println("pressure : " + String(E->getPress()));
|
Serial.println("DBG - pressure : " + String(E->getPress()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawDisplay(Environment *E) {
|
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 */
|
/* Header 20px height, Value 70px height */
|
||||||
int16_t x1, y1;
|
int16_t x1, y1;
|
||||||
uint16_t w, h;
|
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_w = 130;
|
||||||
uint16_t box_h = 86;
|
uint16_t box_h = 86;
|
||||||
uint16_t box_x = (int)(((widgetPos%3)*133)+2);
|
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