Merge pull request #556 from AugustQu/SDS011

Sds011
This commit is contained in:
Verkehrsrot 2020-02-25 19:33:41 +01:00 committed by GitHub
commit bbda15d36f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 22 deletions

View File

@ -48,7 +48,7 @@ description = Paxcounter is a device for metering passenger flows in realtime. I
release_version = 1.9.90 release_version = 1.9.90
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! ; 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 ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
debug_level = 5 debug_level = 2
extra_scripts = pre:build.py extra_scripts = pre:build.py
otakeyfile = ota.conf otakeyfile = ota.conf
lorakeyfile = loraconf.h lorakeyfile = loraconf.h

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
@ -104,4 +100,4 @@
#define MCP_24AA02E64_I2C_ADDRESS 0x50 // I2C address for the 24AA02E64 #define MCP_24AA02E64_I2C_ADDRESS 0x50 // I2C address for the 24AA02E64
#define MCP_24AA02E64_MAC_ADDRESS 0xF8 // Memory adress of unique deveui 64 bits #define MCP_24AA02E64_MAC_ADDRESS 0xF8 // Memory adress of unique deveui 64 bits
#endif #endif

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
@ -48,4 +54,4 @@
#define LORA_IO1 (33) #define LORA_IO1 (33)
#define LORA_IO2 (32) #define LORA_IO2 (32)
#endif #endif

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) {
@ -62,5 +56,3 @@ void sds011_wakeup() {
isSDS011Active = true; isSDS011Active = true;
} }
} }
#endif // HAS_SDS