@ -23,7 +23,7 @@ extern "C" {
# include <RunningAverage.h>
# include <RunningAverage.h>
# include <SDS011 .h>
# include <SdsDustSensor .h>
# include <XD0OTA.h>
# include <XD0OTA.h>
# include "main.h"
# include "main.h"
@ -89,7 +89,7 @@ RunningAverage geigeraverage(10);
Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified ( 10085 ) ;
Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified ( 10085 ) ;
DHT dht ( DHT22_PIN , DHTTYPE ) ;
DHT dht ( DHT22_PIN , DHTTYPE ) ;
SDS011 sds ;
SdsDustSensor sds ( SDS_RX , SDS_TX ) ;
volatile unsigned long geiger_counts = 0 ;
volatile unsigned long geiger_counts = 0 ;
unsigned long geiger_previousMillis ;
unsigned long geiger_previousMillis ;
unsigned long last_dhcp = 0 ;
unsigned long last_dhcp = 0 ;
@ -156,11 +156,15 @@ void ICACHE_FLASH_ATTR sendValues() {
sd . voltage = analogRead ( A0 ) * 0.04285078 - 0.05942125 ; // by linear regression for my(!) voltage divider. else: sd.voltage = analogRead(A0)*3.3*(R1+R2)/(R2*1024)
sd . voltage = analogRead ( A0 ) * 0.04285078 - 0.05942125 ; // by linear regression for my(!) voltage divider. else: sd.voltage = analogRead(A0)*3.3*(R1+R2)/(R2*1024)
# endif
# endif
int sds_error = sds . query ( & ( sd . p25 ) , & ( sd . p10 ) ) ;
// sds.wakeup(); delay(30000); // working 30 seconds
if ( ! sds_error ) {
PmResult pm = sds . queryPm ( ) ;
// DEBUG_MSG("SDS011 updated.\n");
bool sds_updated = false ;
if ( pm . isOk ( ) ) {
sd . p25 = pm . pm25 ;
sd . p10 = pm . pm10 ;
sds_updated = true ;
} else {
} else {
// DEBUG_MSG("SDS011 no new values.\n");
sds_updated = false ;
}
}
// sds.sleep();
// sds.sleep();
@ -178,8 +182,8 @@ void ICACHE_FLASH_ATTR sendValues() {
DEBUG_MSG ( " Humidity : %6.2f%% (DHT22) \n " , sd . humidity ) ;
DEBUG_MSG ( " Humidity : %6.2f%% (DHT22) \n " , sd . humidity ) ;
DEBUG_MSG ( " Temperature : %6.2f°C (BMP180) \n " , sd . temp2 ) ;
DEBUG_MSG ( " Temperature : %6.2f°C (BMP180) \n " , sd . temp2 ) ;
DEBUG_MSG ( " Pressure : %6.2fhPa (BMP180) \n " , sd . pressure ) ;
DEBUG_MSG ( " Pressure : %6.2fhPa (BMP180) \n " , sd . pressure ) ;
if ( ! sds_error ) DEBUG_MSG ( " Particles 10 : %6.2fµg/m³ (SDS011) \n " , sd . p10 ) ;
if ( sds_updated ) DEBUG_MSG ( " Particles 10 : %6.2fµg/m³ (SDS011) \n " , sd . p10 ) ;
if ( ! sds_error ) DEBUG_MSG ( " Particles 2.5: %6.2fµg/m³ (SDS011) \n " , sd . p25 ) ;
if ( sds_updated ) DEBUG_MSG ( " Particles 2.5: %6.2fµg/m³ (SDS011) \n " , sd . p25 ) ;
if ( sd . cpm > 0 ) DEBUG_MSG ( " Radiation : %6.2fµSv/h (J305) \n " , sd . radioactivity ) ;
if ( sd . cpm > 0 ) DEBUG_MSG ( " Radiation : %6.2fµSv/h (J305) \n " , sd . radioactivity ) ;
DEBUG_MSG ( " Voltage : %6.2fV (ESP8266) \n " , sd . voltage ) ;
DEBUG_MSG ( " Voltage : %6.2fV (ESP8266) \n " , sd . voltage ) ;
@ -203,7 +207,7 @@ void ICACHE_FLASH_ATTR sendValues() {
pressureObject [ " value " ] = sd . pressure ;
pressureObject [ " value " ] = sd . pressure ;
root [ " pressure " ] = sd . pressure ;
root [ " pressure " ] = sd . pressure ;
if ( ! sds_error ) {
if ( sds_updated ) {
JsonObject & pm10Object = array . createNestedObject ( ) ;
JsonObject & pm10Object = array . createNestedObject ( ) ;
pm10Object [ " sensor " ] = SENSOR4_ID ;
pm10Object [ " sensor " ] = SENSOR4_ID ;
pm10Object [ " value " ] = sd . p10 ;
pm10Object [ " value " ] = sd . p10 ;
@ -385,9 +389,9 @@ void setup() {
//wifi_status_led_uninstall();
//wifi_status_led_uninstall();
sds . begin ( SDS_TX , SDS_RX ) ;
sds . begin ( ) ;
sds . mode_mon_300 ( ) ;
sds . setCustomWorkingPeriod ( 5 ) ; // sensor sends data every 5 minutes
sds . mode_query ( ) ;
sds . setQueryReportingMode ( ) ; // ensures sensor is in 'query' reporting mode
Wire . begin ( BMP_SDA , BMP_SCL ) ;
Wire . begin ( BMP_SDA , BMP_SCL ) ;
if ( ! bmp . begin ( BMP085_MODE_STANDARD ) ) {
if ( ! bmp . begin ( BMP085_MODE_STANDARD ) ) {