diff --git a/src/hal/generic.h b/src/hal/generic.h index 14c83ff5..fa1d14c7 100644 --- a/src/hal/generic.h +++ b/src/hal/generic.h @@ -10,10 +10,6 @@ // 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 @@ -104,4 +100,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 diff --git a/src/hal/ttgov21new.h b/src/hal/ttgov21new.h index 90f93c7a..9fa665f2 100644 --- a/src/hal/ttgov21new.h +++ b/src/hal/ttgov21new.h @@ -12,6 +12,12 @@ // 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 +54,4 @@ #define LORA_IO1 (33) #define LORA_IO2 (32) -#endif \ No newline at end of file +#endif 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) - diff --git a/src/sds011read.cpp b/src/sds011read.cpp index 71be06d9..f5a781d5 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 - +// UART(2) is unused in this project static HardwareSerial sdsSerial(2); // so we use it here static SDS011 sdsSensor; // fine dust sensor @@ -27,12 +20,13 @@ boolean isSDS011Active; // init 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 +#if (HAS_SDS011) + sdsSensor.begin (&sdsSerial, ESP_PIN_RX, ESP_PIN_TX); +#endif + sds011_sleep(); // we do sleep/wakup by ourselves return true; } + // reading data: void sds011_loop() { if (isSDS011Active) {