Merge branch 'SDS011' into master

This commit is contained in:
August Quint 2020-02-25 17:04:28 +01:00 committed by GitHub
commit 8380f9651e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 19 deletions

View File

@ -10,10 +10,6 @@
// Hardware related definitions for generic ESP32 boards // Hardware related definitions for generic ESP32 boards
// generic.h is kitchensink with all available options // 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_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 #define HAS_SPI 1 // comment out if device shall not send data via SPI
// pin definitions for SPI slave interface // pin definitions for SPI slave interface

View File

@ -12,6 +12,12 @@
// This settings are for boards labeled v1.6 on pcb, NOT for v1.5 or older // 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 HAS_LORA 1 // comment out if device shall not send data via LoRa
#define CFG_sx1276_radio 1 // HPD13A LoRa SoC #define CFG_sx1276_radio 1 // HPD13A LoRa SoC

View File

@ -24,6 +24,8 @@ bool sdcard_init() {
useSDCard = SD.begin(SDCARD_CS, SDCARD_MOSI, SDCARD_MISO, SDCARD_SCLK); useSDCard = SD.begin(SDCARD_CS, SDCARD_MOSI, SDCARD_MISO, SDCARD_SCLK);
if (useSDCard) if (useSDCard)
createFile(); createFile();
else
ESP_LOGD(TAG,"SD-card not found");
return useSDCard; return useSDCard;
} }
@ -84,4 +86,3 @@ void createFile(void) {
} }
#endif // (HAS_SDCARD) #endif // (HAS_SDCARD)

View File

@ -3,19 +3,12 @@
// Local logging tag // Local logging tag
static const char TAG[] = __FILE__; static const char TAG[] = __FILE__;
#if (HAS_SDS)
#include "sds011read.h" #include "sds011read.h"
// UART(2) is unused in this project
#if (HAS_IF482) #if (HAS_IF482)
#error cannot use IF482 together with SDS011 (both use UART#2) #error cannot use IF482 together with SDS011 (both use UART#2)
#endif #endif
// UART(2) is unused in this project
#ifndef SDS011_SERIAL
#error serial settings for SDS011 connection missing
#endif
static HardwareSerial sdsSerial(2); // so we use it here static HardwareSerial sdsSerial(2); // so we use it here
static SDS011 sdsSensor; // fine dust sensor static SDS011 sdsSensor; // fine dust sensor
@ -27,12 +20,13 @@ boolean isSDS011Active;
// init // init
bool sds011_init() { bool sds011_init() {
pm25 = pm10 = 0.0; pm25 = pm10 = 0.0;
sdsSerial.begin(SDS011_SERIAL); #if (HAS_SDS011)
sdsSensor.begin(&sdsSerial); sdsSensor.begin (&sdsSerial, ESP_PIN_RX, ESP_PIN_TX);
//sdsSensor.contmode(0); // for safety: no wakeup/sleep by the sensor #endif
sds011_sleep(); // we do it by ourselves sds011_sleep(); // we do sleep/wakup by ourselves
return true; return true;
} }
// reading data: // reading data:
void sds011_loop() { void sds011_loop() {
if (isSDS011Active) { if (isSDS011Active) {