From eab95f1f6c38ee734cd174392de3bfb856e41b57 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Tue, 11 Feb 2020 09:39:25 +0100 Subject: [PATCH 01/20] Update platformio.ini --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 4593402d..d1c32ed9 100644 --- a/platformio.ini +++ b/platformio.ini @@ -48,7 +48,7 @@ description = Paxcounter is a device for metering passenger flows in realtime. I release_version = 1.9.90 ; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose -debug_level = 5 +debug_level = 2 extra_scripts = pre:build.py otakeyfile = ota.conf lorakeyfile = loraconf.h From a51deb41165fbb1adeaaa915f6e20e171e473e0a Mon Sep 17 00:00:00 2001 From: August Quint <49277349+AugustQu@users.noreply.github.com> Date: Wed, 19 Feb 2020 13:55:08 +0100 Subject: [PATCH 02/20] Update platformio.ini --- platformio.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platformio.ini b/platformio.ini index e9d5dc49..e3dabd48 100644 --- a/platformio.ini +++ b/platformio.ini @@ -71,6 +71,8 @@ lib_deps_sensors = Adafruit Unified Sensor@>=1.1.1 Adafruit BME280 Library@>=2.0.0 Adafruit BMP085 Library@>=1.0.1 +lib_deps_sds = + https://github.com/ricki-z/SDS011.git#33fd8b6 lib_deps_basic = ArduinoJson@^5.13.1 76@>=1.2.4 ; #76 Timezone by Jack Christensen @@ -86,6 +88,7 @@ lib_deps_all = ${common.lib_deps_gps} ${common.lib_deps_sensors} ${common.lib_deps_matrix_display} + ${common.lib_deps_sds} build_flags_basic = -include "src/hal/${board.halfile}" -include "src/paxcounter.conf" From 40c27f8c66bc020c7b64c12104d0510438498677 Mon Sep 17 00:00:00 2001 From: August Quint <49277349+AugustQu@users.noreply.github.com> Date: Wed, 19 Feb 2020 13:57:21 +0100 Subject: [PATCH 03/20] Update sds011read.cpp --- src/sds011read.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/sds011read.cpp b/src/sds011read.cpp index cf6dccdf..13df56fa 100644 --- a/src/sds011read.cpp +++ b/src/sds011read.cpp @@ -21,12 +21,11 @@ boolean isSDS011Active; bool sds011_init() { pm25 = pm10 = 0.0; - sdsSerial.begin(9600, SERIAL_8N1, ESP_PIN_RX, ESP_PIN_TX); - sdsSensor.begin (&sdsSerial); - sdsSensor.contmode(0); // for safety: no wakeup/sleep by the sensor - sds011_sleep(); // we do it by ourselves - return true; + sdsSensor.begin (&sdsSerial, ESP_PIN_RX, ESP_PIN_TX); + sds011_sleep(); // we do sleep/wakup by ourselves + return true; } + // reading data: void sds011_loop() { From 25d4d9d0474b6c5f087c4ffb71ba8c99c91bf9e5 Mon Sep 17 00:00:00 2001 From: August Quint <49277349+AugustQu@users.noreply.github.com> Date: Wed, 19 Feb 2020 13:58:58 +0100 Subject: [PATCH 04/20] Update ttgov21new.h --- src/hal/ttgov21new.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hal/ttgov21new.h b/src/hal/ttgov21new.h index 90f93c7a..fc0b5036 100644 --- a/src/hal/ttgov21new.h +++ b/src/hal/ttgov21new.h @@ -11,6 +11,11 @@ // ATTENTION: check your board version! // This settings are for boards labeled v1.6 on pcb, NOT for v1.5 or older */ +// SDS011 dust sensor settings +#define HAS_SDS011 1 // use SDS011 +// used pins on the ESP-side: +#define ESP_PIN_TX 19 // connect to RX on the SDS011 +#define ESP_PIN_RX 23 // connect to TX on the SDS011 #define HAS_LORA 1 // comment out if device shall not send data via LoRa #define CFG_sx1276_radio 1 // HPD13A LoRa SoC @@ -48,4 +53,4 @@ #define LORA_IO1 (33) #define LORA_IO2 (32) -#endif \ No newline at end of file +#endif From 20df7ca28237c78fed8607c41af19f2d91efe3ee Mon Sep 17 00:00:00 2001 From: August Quint <49277349+AugustQu@users.noreply.github.com> Date: Tue, 25 Feb 2020 15:38:09 +0100 Subject: [PATCH 05/20] Update platformio.ini --- platformio.ini | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/platformio.ini b/platformio.ini index e3dabd48..a2640cfd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -31,6 +31,8 @@ halfile = generic.h ;halfile = octopus32.h ;halfile = tinypico.h ;halfile = tinypicomatrix.h +;halfile = m5core.h +;halfile = m5fire.h [platformio] ; upload firmware to board with usb cable @@ -43,10 +45,10 @@ description = Paxcounter is a device for metering passenger flows in realtime. I [common] ; for release_version use max. 10 chars total, use any decimal format like "a.b.c" -release_version = 1.9.85 +release_version = 1.9.90 ; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose -debug_level = 3 +debug_level = 5 extra_scripts = pre:build.py otakeyfile = ota.conf lorakeyfile = loraconf.h @@ -55,14 +57,13 @@ platform_espressif32 = espressif32@1.11.1 monitor_speed = 115200 upload_speed = 115200 lib_deps_lora = - ;MCCI LoRaWAN LMIC library@>=3.1.0 ; MCCI LMIC by Terrill Moore - https://github.com/mcci-catena/arduino-lmic.git#3ca90f3 + MCCI LoRaWAN LMIC library@>=3.1.0 ; MCCI LMIC by Terrill Moore lib_deps_display = - ss_oled@>=3.2.0 ; simple and small OLED lib by Larry Bank + ss_oled@>=3.3.1 ; simple and small OLED lib by Larry Bank BitBang_I2C@>=1.3.0 QRCode@>=0.0.1 lib_deps_matrix_display = - Ultrathin_LED_Matrix + Ultrathin_LED_Matrix@>=1.0.0 lib_deps_rgbled = SmartLeds@>=1.1.6 lib_deps_gps = @@ -71,7 +72,8 @@ lib_deps_sensors = Adafruit Unified Sensor@>=1.1.1 Adafruit BME280 Library@>=2.0.0 Adafruit BMP085 Library@>=1.0.1 -lib_deps_sds = + BSEC Software Library@1.5.1474 + ;SDS011 sensor Library https://github.com/ricki-z/SDS011.git#33fd8b6 lib_deps_basic = ArduinoJson@^5.13.1 @@ -88,7 +90,6 @@ lib_deps_all = ${common.lib_deps_gps} ${common.lib_deps_sensors} ${common.lib_deps_matrix_display} - ${common.lib_deps_sds} build_flags_basic = -include "src/hal/${board.halfile}" -include "src/paxcounter.conf" From 0d18feb29d66492384d48f86bb87fd9bb34750cf Mon Sep 17 00:00:00 2001 From: August Quint <49277349+AugustQu@users.noreply.github.com> Date: Tue, 25 Feb 2020 15:41:12 +0100 Subject: [PATCH 06/20] Update sds011read.cpp --- src/sds011read.cpp | 73 +++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/src/sds011read.cpp b/src/sds011read.cpp index 13df56fa..e6d1c216 100644 --- a/src/sds011read.cpp +++ b/src/sds011read.cpp @@ -3,59 +3,64 @@ // Local logging tag static const char TAG[] = __FILE__; -#include +#if (HAS_SDS) + +#include "sds011read.h" // UART(2) is unused in this project #if (HAS_IF482) #error cannot use IF482 together with SDS011 (both use UART#2) #endif -static HardwareSerial sdsSerial(2); // so we use it here -static SDS011 sdsSensor; // fine dust sensor + +#ifndef SDS011_SERIAL +#error serial settings for SDS011 connection missing +#endif + +static HardwareSerial sdsSerial(2); // so we use it here +static SDS011 sdsSensor; // fine dust sensor // the results of the sensor: -float pm25; +float pm25; float pm10; boolean isSDS011Active; // init -bool sds011_init() -{ - pm25 = pm10 = 0.0; - sdsSensor.begin (&sdsSerial, ESP_PIN_RX, ESP_PIN_TX); - sds011_sleep(); // we do sleep/wakup by ourselves - return true; +bool sds011_init() { + pm25 = pm10 = 0.0; + sdsSerial.begin(SDS011_SERIAL); + sdsSensor.begin(&sdsSerial); + //sdsSensor.contmode(0); // for safety: no wakeup/sleep by the sensor + sds011_sleep(); // we do it by ourselves + return true; } - // reading data: -void sds011_loop() -{ - if ( isSDS011Active ) { - int sdsErrorCode = sdsSensor.read(&pm25, &pm10); - if (sdsErrorCode) { - pm25 = pm10 = 0.0; - ESP_LOGI(TAG, "SDS011 error: %d", sdsErrorCode); - } - else { - ESP_LOGI(TAG, "fine-dust-values: %5.1f,%4.1f", pm10, pm25); - } - sds011_sleep(); +void sds011_loop() { + if (isSDS011Active) { + int sdsErrorCode = sdsSensor.read(&pm25, &pm10); + if (sdsErrorCode) { + pm25 = pm10 = 0.0; + ESP_LOGI(TAG, "SDS011 error: %d", sdsErrorCode); + } else { + ESP_LOGI(TAG, "fine-dust-values: %5.1f,%4.1f", pm10, pm25); } - return; + sds011_sleep(); + } + return; } // putting the SDS-sensor to sleep -void sds011_sleep(void) -{ - sdsSensor.sleep(); - isSDS011Active = false; +void sds011_sleep(void) { + sdsSensor.sleep(); + isSDS011Active = false; } // start the SDS-sensor // needs 30 seconds for warming up -void sds011_wakeup() -{ - if ( !isSDS011Active ) { - sdsSensor.wakeup(); - isSDS011Active = true; - } +void sds011_wakeup() { + if (!isSDS011Active) { + sdsSensor.wakeup(); + isSDS011Active = true; + } } + +#endif // HAS_SDS From b674b5e1b075ecf29fefe334a3cba3d6bd818d89 Mon Sep 17 00:00:00 2001 From: August Quint <49277349+AugustQu@users.noreply.github.com> Date: Tue, 25 Feb 2020 15:43:54 +0100 Subject: [PATCH 07/20] Update sds011read.cpp --- src/sds011read.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/sds011read.cpp b/src/sds011read.cpp index e6d1c216..a7c84ba6 100644 --- a/src/sds011read.cpp +++ b/src/sds011read.cpp @@ -3,19 +3,12 @@ // Local logging tag static const char TAG[] = __FILE__; -#if (HAS_SDS) - #include "sds011read.h" // UART(2) is unused in this project #if (HAS_IF482) #error cannot use IF482 together with SDS011 (both use UART#2) #endif - -#ifndef SDS011_SERIAL -#error serial settings for SDS011 connection missing -#endif - static HardwareSerial sdsSerial(2); // so we use it here static SDS011 sdsSensor; // fine dust sensor @@ -27,12 +20,14 @@ boolean isSDS011Active; // init bool sds011_init() { pm25 = pm10 = 0.0; - sdsSerial.begin(SDS011_SERIAL); - sdsSensor.begin(&sdsSerial); + sdsSensor.begin (&sdsSerial, ESP_PIN_RX, ESP_PIN_TX); + delay(100); +// sdsSerial.begin(SDS011_SERIAL); //sdsSensor.contmode(0); // for safety: no wakeup/sleep by the sensor - sds011_sleep(); // we do it by ourselves + sds011_sleep(); // we do sleep/wakup by ourselves return true; } + // reading data: void sds011_loop() { if (isSDS011Active) { @@ -62,5 +57,3 @@ void sds011_wakeup() { isSDS011Active = true; } } - -#endif // HAS_SDS From d0ffe9ab7efb1553fba10390d41309787f2aec1a Mon Sep 17 00:00:00 2001 From: August Quint <49277349+AugustQu@users.noreply.github.com> Date: Tue, 25 Feb 2020 15:44:56 +0100 Subject: [PATCH 08/20] Update sdcard.cpp --- src/sdcard.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sdcard.cpp b/src/sdcard.cpp index 780efef9..002cfdf8 100644 --- a/src/sdcard.cpp +++ b/src/sdcard.cpp @@ -24,6 +24,8 @@ bool sdcard_init() { useSDCard = SD.begin(SDCARD_CS, SDCARD_MOSI, SDCARD_MISO, SDCARD_SCLK); if (useSDCard) createFile(); + else + ESP_LOGD(TAG,"SD-card not found"); return useSDCard; } @@ -84,4 +86,3 @@ void createFile(void) { } #endif // (HAS_SDCARD) - From ad3cd8bf9e138ee1f9dfe56064133012955c8e77 Mon Sep 17 00:00:00 2001 From: August Quint <49277349+AugustQu@users.noreply.github.com> Date: Tue, 25 Feb 2020 15:46:13 +0100 Subject: [PATCH 09/20] Update generic.h --- src/hal/generic.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hal/generic.h b/src/hal/generic.h index 5d56e591..658eb7bc 100644 --- a/src/hal/generic.h +++ b/src/hal/generic.h @@ -10,6 +10,10 @@ // Hardware related definitions for generic ESP32 boards // generic.h is kitchensink with all available options +// SDS011 dust sensor settings +// #define HAS_SDS011 1 // use SDS011 +// #define SDS011_SERIAL 9600, SERIAL_8N1, GPIO_NUM_19, GPIO_NUM_23 // SDS011 RX, TX + #define HAS_LORA 1 // comment out if device shall not send data via LoRa or has no LoRa #define HAS_SPI 1 // comment out if device shall not send data via SPI // pin definitions for SPI slave interface @@ -100,4 +104,4 @@ #define MCP_24AA02E64_I2C_ADDRESS 0x50 // I2C address for the 24AA02E64 #define MCP_24AA02E64_MAC_ADDRESS 0xF8 // Memory adress of unique deveui 64 bits -#endif \ No newline at end of file +#endif From f3218b4266c8e2b2f05018656ec27ece31db77be Mon Sep 17 00:00:00 2001 From: August Quint <49277349+AugustQu@users.noreply.github.com> Date: Tue, 25 Feb 2020 15:47:15 +0100 Subject: [PATCH 10/20] Update ttgov21new.h --- src/hal/ttgov21new.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hal/ttgov21new.h b/src/hal/ttgov21new.h index fc0b5036..9fa665f2 100644 --- a/src/hal/ttgov21new.h +++ b/src/hal/ttgov21new.h @@ -11,8 +11,9 @@ // ATTENTION: check your board version! // This settings are for boards labeled v1.6 on pcb, NOT for v1.5 or older */ + // SDS011 dust sensor settings -#define HAS_SDS011 1 // use SDS011 +#define HAS_SDS011 1 // use SDS011 // used pins on the ESP-side: #define ESP_PIN_TX 19 // connect to RX on the SDS011 #define ESP_PIN_RX 23 // connect to TX on the SDS011 From 3dd143f70ac73b5a6873467b71d032e2f47a8001 Mon Sep 17 00:00:00 2001 From: August Quint <49277349+AugustQu@users.noreply.github.com> Date: Tue, 25 Feb 2020 15:53:22 +0100 Subject: [PATCH 12/20] Update sds011read.h --- include/sds011read.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/sds011read.h b/include/sds011read.h index d278a5fd..8c573c0d 100644 --- a/include/sds011read.h +++ b/include/sds011read.h @@ -3,10 +3,6 @@ #include -// used pins on the ESP-side: -#define ESP_PIN_TX 19 // connect to RX on the SDS011 -#define ESP_PIN_RX 23 // connect to TX on the SDS011 - #define SDCARD_FILE_HEADER_SDS011 ", PM10,PM25" bool sds011_init(); From e6ab58ff91acefcfb2c0b1ba5888a572c9cf38c4 Mon Sep 17 00:00:00 2001 From: August Quint <49277349+AugustQu@users.noreply.github.com> Date: Tue, 25 Feb 2020 15:54:03 +0100 Subject: [PATCH 13/20] Update senddata.h --- include/senddata.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/senddata.h b/include/senddata.h index 324f2e1f..5022800c 100644 --- a/include/senddata.h +++ b/include/senddata.h @@ -16,10 +16,6 @@ #include "sdcard.h" #endif -#if (HAS_SDS011) -#include "sds011read.h" -#endif - extern Ticker sendcycler; void SendPayload(uint8_t port, sendprio_t prio); From 497c738405aa5e26f02d6fdb5bcfd6d0114f4492 Mon Sep 17 00:00:00 2001 From: August Quint <49277349+AugustQu@users.noreply.github.com> Date: Tue, 25 Feb 2020 15:56:11 +0100 Subject: [PATCH 14/20] Update sds011read.cpp --- src/sds011read.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sds011read.cpp b/src/sds011read.cpp index a7c84ba6..c29a9a77 100644 --- a/src/sds011read.cpp +++ b/src/sds011read.cpp @@ -5,10 +5,10 @@ static const char TAG[] = __FILE__; #include "sds011read.h" -// UART(2) is unused in this project #if (HAS_IF482) #error cannot use IF482 together with SDS011 (both use UART#2) #endif +// UART(2) is unused in this project static HardwareSerial sdsSerial(2); // so we use it here static SDS011 sdsSensor; // fine dust sensor From 96ab12420feb4294f5f01a16054175d9a8257aa1 Mon Sep 17 00:00:00 2001 From: August Quint <49277349+AugustQu@users.noreply.github.com> Date: Tue, 25 Feb 2020 16:01:02 +0100 Subject: [PATCH 17/20] Update senddata.cpp --- src/senddata.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/senddata.cpp b/src/senddata.cpp index 577748c4..f5b867f6 100644 --- a/src/senddata.cpp +++ b/src/senddata.cpp @@ -18,10 +18,6 @@ void SendPayload(uint8_t port, sendprio_t prio) { MessageBuffer_t SendBuffer; // contains MessageSize, MessagePort, MessagePrio, Message[] -//#if (HAS_SDS011) -// sds011_loop(); -//#endif - SendBuffer.MessageSize = payload.getSize(); SendBuffer.MessagePrio = prio; From cfe877ff70e725e67509d70726fa00ea0ebc3b65 Mon Sep 17 00:00:00 2001 From: August Quint <49277349+AugustQu@users.noreply.github.com> Date: Tue, 25 Feb 2020 17:22:31 +0100 Subject: [PATCH 20/20] Update sds011read.cpp --- src/sds011read.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/sds011read.cpp b/src/sds011read.cpp index f5a781d5..f280fbe6 100644 --- a/src/sds011read.cpp +++ b/src/sds011read.cpp @@ -56,5 +56,3 @@ void sds011_wakeup() { isSDS011Active = true; } } - -#endif // HAS_SDS \ No newline at end of file