Browse Source

split project components into several files

split_files
Hendrik Langer 5 years ago
parent
commit
0b5638f43e
  1. 33
      platformio.ini
  2. 46
      src/XD0MQTT.h
  3. 16
      src/display/Display.cpp
  4. 14
      src/display/Display.h
  5. 57
      src/display/Display_D32_EPD.cpp
  6. 16
      src/display/Display_D32_EPD.h
  7. 20
      src/hardware.h
  8. 132
      src/main.cpp
  9. 7
      src/network/XD0MQTT.cpp
  10. 39
      src/network/XD0MQTT.h
  11. 2
      src/network/XD0OTA.cpp
  12. 0
      src/network/XD0OTA.h
  13. 56
      src/sensors/BME280.cpp
  14. 19
      src/sensors/BME280.h
  15. 34
      src/sensors/SDS011.cpp
  16. 18
      src/sensors/SDS011.h

33
platformio.ini

@ -8,18 +8,15 @@
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:lolin_d32_pro]
[env]
platform = espressif32
;platform = https://github.com/platformio/platform-espressif32.git#feature/stage
framework = arduino
board = lolin_d32_pro
build_flags =
-DLOG_DEFAULT_LEVEL=ESP_LOG_VERBOSE
-DLOG_LOCAL_LEVEL=ESP_LOG_VERBOSE
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
-DWIFI_SSID="\"${sysenv.WIFI_SSID}\""
-DWIFI_PASSWD="\"${sysenv.WIFI_PASSWD}\""
-DWIFI_SSID2="\"${sysenv.WIFI_SSID}\""
@ -27,9 +24,28 @@ build_flags =
-DMQTT_BROKER_URI="\"${sysenv.MQTT_BROKER_URI}\""
-DMQTT_USERNAME="\"${sysenv.MQTT_USERNAME}\""
-DMQTT_PASSWORD="\"${sysenv.MQTT_PASSWORD}\""
lib_deps =
ArduinoJSON
monitor_speed = 115200
upload_speed = 115200
extra_scripts =
pre:script/autoversioning.py
pre:lib/script/autoversioning.py
[env:lolin_d32_pro]
board = lolin_d32_pro
build_flags =
${env.build_flags}
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
-DARDUINO_SAMD_VARIANT_COMPLIANCE
lib_deps =
${env.lib_deps}
GxEPD2
; https://github.com/wemos/LOLIN_EPD_Library
Adafruit GFX Library
@ -38,11 +54,8 @@ lib_deps =
; SDS011 sensor Library
; Nova Fitness Sds dust sensors library
https://github.com/lewapek/sds-dust-sensors-arduino-library.git
; ArduinoJSON
monitor_speed = 115200
upload_speed = 115200
extra_scripts =
pre:script/autoversioning.py
pre:lib/script/autoversioning.py
; 246f28d1a080 e paper
; a4cf1211c3e4 d32
; 246f28d1fa5c d32_pro 2

46
src/XD0MQTT.h

@ -1,46 +0,0 @@
#ifndef _XD0MQTT_H
#define _XD0MQTT_H
#include <Arduino.h>
class XD0MQTT {
public:
XD0MQTT(void);
bool begin(void);
private:
// openssl s_client -showcerts -connect home.xd0.de:8883 </dev/null 2>/dev/null|openssl x509 -outform PEM >mqtt_xd0.de.pem
const char* rootCACertificate = \
"-----BEGIN CERTIFICATE-----\n" \
"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\n" \
"-----END CERTIFICATE-----\n";
};
#endif /* _XD0MQTT_H */

16
src/display/Display.cpp

@ -0,0 +1,16 @@
#include "Display.h"
#include "esp_log.h"
static const char *TAG = "Display";
Display::Display() {}
bool Display::begin(void) {
}
void Display::helloWorld(void) {
}

14
src/display/Display.h

@ -0,0 +1,14 @@
#ifndef _DISPLAY_H
#define _DISPLAY_H
#include <Arduino.h>
class Display {
public:
Display(void);
virtual bool begin(void);
virtual void helloWorld(void);
private:
};
#endif /* _DISPLAY_H */

57
src/display/Display_D32_EPD.cpp

@ -0,0 +1,57 @@
#include "Display.h"
#include "Display_D32_EPD.h"
#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include "bitmaps/Bitmaps128x250.h"
#include <Adafruit_GFX.h>
#include "../hardware.h"
#include "esp_log.h"
static const char *TAG = "Display";
namespace {
GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> display(GxEPD2_213_B72(/*CS=SS*/ TFT_CS, /*DC=*/ TFT_DC, /*RST=*/ TFT_RST, /*BUSY=*/ -1)); // GDEH0213B72
}
Display_D32_EPD::Display_D32_EPD(void) {}
bool Display_D32_EPD::begin(void) {
// initialize e-paper display
SPI.begin(18, 19, 23, TFT_CS);
display.init();
Serial.println("display init done"); Serial.flush();
display.clearScreen();
display.refresh();
helloWorld();
display.powerOff();
}
void Display_D32_EPD::helloWorld()
{
const char HelloWorld[] = "Hello World!";
//Serial.println("helloWorld");
display.setRotation(1);
display.setFont(&FreeMonoBold9pt7b);
display.setTextColor(GxEPD_BLACK);
int16_t tbx, tby; uint16_t tbw, tbh;
display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
// center bounding box by transposition of origin:
uint16_t x = ((display.width() - tbw) / 2) - tbx;
uint16_t y = ((display.height() - tbh) / 2) - tby;
display.setFullWindow();
display.firstPage();
do
{
display.fillScreen(GxEPD_WHITE);
display.setCursor(x, y);
display.print(HelloWorld);
}
while (display.nextPage());
//Serial.println("helloWorld done");
}

16
src/display/Display_D32_EPD.h

@ -0,0 +1,16 @@
#ifndef _DISPLAY_D32_EPD_H
#define _DISPLAY_D32_EPD_H
#include <Arduino.h>
#include "Display.h"
class Display_D32_EPD : public Display {
public:
Display_D32_EPD();
bool begin(void);
void helloWorld(void);
private:
};
#endif /* _DISPLAY_D32_EPD_H */

20
src/hardware.h

@ -0,0 +1,20 @@
#ifndef _HARDWARE_H
#define _HARDWARE_H
#include <Arduino.h>
static constexpr uint8_t BME_SDA = 21;
static constexpr uint8_t BME_SCL = 22;
/* defined in arduino-esp32/variants/d32_pro/pins_arduino.h */
//static const uint8_t LED_BUILTIN = 5;
//static const uint8_t _VBAT = 35; // battery voltage
//#define TF_CS 4 // TF (Micro SD Card) CS pin
//#define TS_CS 12 // Touch Screen CS pin
//#define TFT_CS 14 // TFT CS pin
//#define TFT_LED 32 // TFT backlight control pin
//#define TFT_RST 33 // TFT reset pin
//#define TFT_DC 27 // TFT DC pin
//#define SS TF_CS
#endif /* _HARDWARE_H */

132
src/main.cpp

@ -11,78 +11,42 @@
#include <Wire.h>
#include <SPI.h>
#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include "bitmaps/Bitmaps128x250.h"
#include <Adafruit_GFX.h>
#include "sensors/SDS011.h"
#include "sensors/BME280.h"
#include <Adafruit_Sensor.h>
#include "Adafruit_BME280.h"
#include "hardware.h"
#define ARDUINO_SAMD_VARIANT_COMPLIANCE
#include "SdsDustSensor.h"
#include "network/XD0OTA.h"
#include "network/XD0MQTT.h"
#include "XD0OTA.h"
#include "XD0MQTT.h"
#include "display/Display_D32_EPD.h"
extern "C" {
int rom_phy_get_vdd33();
uint8_t temprature_sens_read();
//uint32_t hall_sens_read();
}
static const char* TAG = "MAIN";
WiFiMulti wifiMulti;
GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> display(GxEPD2_213_B72(/*CS=SS*/ TFT_CS, /*DC=*/ TFT_DC, /*RST=*/ TFT_RST, /*BUSY=*/ -1)); // GDEH0213B72
Adafruit_BME280 bme; // I2C (also available: hardware SPI
//HardwareSerial Serial2(2);
SdsDustSensor sds(Serial2);
XD0MQTT mqtt;
Display *display = new Display_D32_EPD();
BME280 bme;
SDS011 sds;
void helloWorld()
{
const char HelloWorld[] = "Hello World!";
//Serial.println("helloWorld");
display.setRotation(1);
display.setFont(&FreeMonoBold9pt7b);
display.setTextColor(GxEPD_BLACK);
int16_t tbx, tby; uint16_t tbw, tbh;
display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
// center bounding box by transposition of origin:
uint16_t x = ((display.width() - tbw) / 2) - tbx;
uint16_t y = ((display.height() - tbh) / 2) - tby;
display.setFullWindow();
display.firstPage();
do
{
display.fillScreen(GxEPD_WHITE);
display.setCursor(x, y);
display.print(HelloWorld);
}
while (display.nextPage());
//Serial.println("helloWorld done");
}
void printValues() {
#define SEALEVELPRESSURE_HPA (1013.25)
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa");
Serial.print("Approx. Altitude = ");
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
Serial.println(" m");
Serial.print("Humidity = ");
Serial.print(bme.readHumidity());
Serial.println(" %");
Serial.println();
}
struct __attribute__((packed)) Measurements {
char timeStr[20];
float temperature;
float humidity;
float pressure;
int voltage;
int32_t rssi;
};
Measurements measurements;
void setup()
{
@ -93,34 +57,12 @@ void setup()
Serial.println("setup");
// initialize e-paper display
SPI.begin(18, 19, 23, TFT_CS);
display.init();
Serial.println("display init done"); Serial.flush();
display.clearScreen();
display.refresh();
helloWorld();
display.powerOff();
#define BME_SDA 21
#define BME_SCL 22
Wire.begin(BME_SDA, BME_SCL);
if (!bme.begin()) {
ESP_LOGE(TAG, "Could not find a valid BME280 sensor, check wiring!");
}
/*
// Set up oversampling and filter initialization
bme.setTemperatureOversampling(BME680_OS_8X);
bme.setHumidityOversampling(BME680_OS_2X);
bme.setPressureOversampling(BME680_OS_4X);
bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
bme.setGasHeater(320, 150); // 320*C for 150 ms
*/
bme.begin();
sds.begin();
display->begin();
display->helloWorld();
WiFi.setHostname("esp32-weatherstation");
wifiMulti.addAP(WIFI_SSID, WIFI_PASSWD);
wifiMulti.addAP(WIFI_SSID2, WIFI_PASSWD2);
@ -162,22 +104,8 @@ void loop()
display.print("Gas: "); display.print(bme.gas_resistance / 1000.0); display.println(" KOhms");
*/
PmResult pm = sds.readPm();
if (pm.isOk()) {
Serial.print("PM2.5 = ");
Serial.print(pm.pm25);
Serial.print(", PM10 = ");
Serial.println(pm.pm10);
// if you want to just print the measured values, you can use toString() method as well
Serial.println(pm.toString());
} else {
Serial.print("Could not read values from sensor, reason: ");
Serial.println(pm.statusToString());
}
printValues();
sds.readPm();
bme.read();
if(wifiMulti.run() != WL_CONNECTED) {
Serial.println("WiFi not connected!");

7
src/XD0MQTT.cpp → src/network/XD0MQTT.cpp

@ -102,9 +102,14 @@ bool XD0MQTT::begin(void) {
Serial.printf("BROKER URI: %s\n", MQTT_BROKER_URI);
Serial.printf("MQTT USERNAME: %s\n", MQTT_USERNAME);
Serial.printf("MQTT PASSWORD: %s\n", MQTT_PASSWORD);
esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg);
client = esp_mqtt_client_init(&mqtt_cfg);
//esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, client);
esp_mqtt_client_start(client);
return true;
}
bool XD0MQTT::publish(const char* topic, const char* data, int len, int qos=1, int retain=0) {
int msg_id = esp_mqtt_client_publish(client, topic, data, len, qos, retain);
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
}

39
src/network/XD0MQTT.h

@ -0,0 +1,39 @@
#ifndef _XD0MQTT_H
#define _XD0MQTT_H
#include <Arduino.h>
#include "mqtt_client.h"
class XD0MQTT {
public:
XD0MQTT(void);
bool begin(void);
bool publish(const char* topic, const char* data, int len, int qos, int retain);
private:
// openssl s_client -showcerts -connect home.xd0.de:8883 </dev/null 2>/dev/null|openssl x509 -outform PEM >mqtt_xd0.de.pem
const char* rootCACertificate = \
"-----BEGIN CERTIFICATE-----\n" \
"MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/\n" \
"MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT\n" \
"DkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow\n" \
"PzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD\n" \
"Ew5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\n" \
"AN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O\n" \
"rz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq\n" \
"OLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b\n" \
"xiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw\n" \
"7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD\n" \
"aeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV\n" \
"HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG\n" \
"SIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69\n" \
"ikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr\n" \
"AvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz\n" \
"R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5\n" \
"JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo\n" \
"Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ\n" \
"-----END CERTIFICATE-----\n";
esp_mqtt_client_handle_t client;
};
#endif /* _XD0MQTT_H */

2
src/XD0OTA.cpp → src/network/XD0OTA.cpp

@ -8,6 +8,8 @@
#include <time.h>
#include "hardware.h"
static const char* TAG = "OTA";
XD0OTA::XD0OTA(String deviceName) : deviceName{deviceName} {}

0
src/XD0OTA.h → src/network/XD0OTA.h

56
src/sensors/BME280.cpp

@ -0,0 +1,56 @@
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME280.h"
#include "BME280.h"
#include "../hardware.h"
#include "esp_log.h"
static const char *TAG = "BME280";
BME280::BME280() {}
bool BME280::begin(void) {
bme = new Adafruit_BME280(); // I2C (also available: hardware SPI
// #define BME_SDA 21
// #define BME_SCL 22
Wire.begin(BME_SDA, BME_SCL);
if (!bme->begin()) {
ESP_LOGE(TAG, "Could not find a valid BME280 sensor, check wiring!");
}
/*
// Set up oversampling and filter initialization
bme->setTemperatureOversampling(BME680_OS_8X);
bme->setHumidityOversampling(BME680_OS_2X);
bme->setPressureOversampling(BME680_OS_4X);
bme->setIIRFilterSize(BME680_FILTER_SIZE_3);
bme->setGasHeater(320, 150); // 320*C for 150 ms
*/
}
void BME280::read() {
#define SEALEVELPRESSURE_HPA (1013.25)
Serial.print("Temperature = ");
Serial.print(bme->readTemperature());
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bme->readPressure() / 100.0F);
Serial.println(" hPa");
Serial.print("Approx. Altitude = ");
Serial.print(bme->readAltitude(SEALEVELPRESSURE_HPA));
Serial.println(" m");
Serial.print("Humidity = ");
Serial.print(bme->readHumidity());
Serial.println(" %");
Serial.println();
}

19
src/sensors/BME280.h

@ -0,0 +1,19 @@
#ifndef _BME280_H
#define _BME280_H
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME280.h"
class BME280 {
public:
BME280(void);
bool begin(void);
void read(void);
private:
Adafruit_BME280 *bme;
};
#endif /* _BME280_H */

34
src/sensors/SDS011.cpp

@ -0,0 +1,34 @@
#include <Arduino.h>
#define ARDUINO_SAMD_VARIANT_COMPLIANCE
#include "SdsDustSensor.h"
#include "SDS011.h"
#include "esp_log.h"
static const char *TAG = "SDS011";
SDS011::SDS011() {}
bool SDS011::begin(void) {
//HardwareSerial Serial2(2);
sds = new SdsDustSensor(Serial2);
sds->begin();
}
void SDS011::readPm() {
PmResult pm = sds->readPm();
if (pm.isOk()) {
Serial.print("PM2.5 = ");
Serial.print(pm.pm25);
Serial.print(", PM10 = ");
Serial.println(pm.pm10);
// if you want to just print the measured values, you can use toString() method as well
Serial.println(pm.toString());
} else {
Serial.print("Could not read values from sensor, reason: ");
Serial.println(pm.statusToString());
}
}

18
src/sensors/SDS011.h

@ -0,0 +1,18 @@
#ifndef _SDS011_H
#define _SDS011_H
#include <Arduino.h>
#define ARDUINO_SAMD_VARIANT_COMPLIANCE
#include "SdsDustSensor.h"
class SDS011 {
public:
SDS011(void);
bool begin(void);
void readPm(void);
private:
SdsDustSensor *sds;
};
#endif /* _SDS011_H */
Loading…
Cancel
Save