From 99a57c594c7d1d26b8a1f1fed8505923a43c400d Mon Sep 17 00:00:00 2001 From: Fisch Date: Tue, 3 Nov 2020 20:41:46 +0100 Subject: [PATCH] add sensoresp5 --- platformio.ini | 35 ++++++++++++++++++++++++++++++++++- src/main.cpp | 4 +++- src/tcs34725_agc.cpp | 6 +++++- src/tcs34725_agc.h | 3 +++ 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index 92bbb71..9ffb3fe 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,11 +12,12 @@ [platformio] #For Config upload comment in data_dir line and flash with platformio run -t uploadfs --environment sensorespx -data_dir=data_sensoresp0 +#data_dir=data_sensoresp0 #data_dir=data_sensoresp1 #data_dir=data_sensoresp2 #data_dir=data_sensoresp3 #data_dir=data_sensoresp4 +data_dir=data_sensoresp5 #Outdoor @@ -205,3 +206,35 @@ lib_deps = Homie@3.0.0 +#Kueche +[env:sensoresp5] +platform = espressif8266 +board = d1_mini +framework = arduino + +monitor_port = /dev/ttyUSB0 +monitor_speed = 115200 + +build_flags = + -D SENSOR_DHT22 + -D DHTPIN=D7 + -D dataDHT22_temperature_minchange=0.2 + -D dataDHT22_humidity_minchange=1.0 + + -D SENSOR_PIR + -D PIRPIN=D0 + -D dataPIR_readdelay=100 + -D dataPIR_senddelaymax=1000*60*10 + + -D SENSOR_BH1750 + -D dataBH1750_minchange=10.0 + -D dataBH1750_senddelaymax=1000*60*2 + + +lib_deps = + adafruit/DHT sensor library@1.3.10 + claws/BH1750@1.1.4 + ArduinoJson@6.16.1 #dependency of homie. using older version because of "ambiguous overload for operator|" error + Homie@3.0.0 + + diff --git a/src/main.cpp b/src/main.cpp index 41e592c..c7c56f6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -66,7 +66,7 @@ struct sensordata //SCL=D1, SDA=D2 #include #include - BH1750 lightMeter(0x23); + BH1750 lightMeter(0x23); //0x23 if addr connected to ground (=pin open), 0x5c if addr pulled high bool bh1750init_ok=false; sensordata dataBH1750; float value_lightBH1750=0; @@ -84,6 +84,7 @@ struct sensordata #ifdef SENSOR_PIR // PIR Sensors HC-SR501 (modified to put out shortest pulse time short pins 5 and 6 of ic) //pir sensor needs 5v through an inductor for filtering. output level is 3.3v + //hc-sr501 should also be a few cm away from the esp. interference can cause false triggering sensordata dataPIR; bool value_PIR=false; #endif @@ -175,6 +176,7 @@ struct sensordata //#include "Adafruit_TCS34725.h" #include "tcs34725_agc.h" //class code from example https://github.com/adafruit/Adafruit_TCS34725/blob/master/examples/tcs34725autorange/tcs34725autorange.ino //Connect SCL to D1, SDA to D2, GND and 3v3 + //Maximum measurable light is around 20k Lux. (direct sunlight is easily above 20k Lux) //Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X); //initializer from standart class tcs34725 tcs; //wrapper class with agc bool tcs34725init_ok=false; diff --git a/src/tcs34725_agc.cpp b/src/tcs34725_agc.cpp index ac0b0ff..abbdd9a 100644 --- a/src/tcs34725_agc.cpp +++ b/src/tcs34725_agc.cpp @@ -1,3 +1,5 @@ +#ifdef SENSOR_TCS34725 + //#include //#include "Adafruit_TCS34725.h" #include "tcs34725_agc.h" @@ -82,4 +84,6 @@ void tcs34725::getData(void) { lux = (TCS34725_R_Coef * float(r_comp) + TCS34725_G_Coef * float(g_comp) + TCS34725_B_Coef * float(b_comp)) / cpl; ct = TCS34725_CT_Coef * float(b_comp) / float(r_comp) + TCS34725_CT_Offset; -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/tcs34725_agc.h b/src/tcs34725_agc.h index a16caa1..e5407fb 100644 --- a/src/tcs34725_agc.h +++ b/src/tcs34725_agc.h @@ -1,4 +1,5 @@ //copied from example code: https://github.com/adafruit/Adafruit_TCS34725/blob/master/examples/tcs34725autorange/tcs34725autorange.ino +#ifdef SENSOR_TCS34725 #ifndef _TCS34725_AGC_H_ #define _TCS34725_AGC_H_ @@ -45,4 +46,6 @@ public: float cratio, cpl, ct, lux, maxlux; }; +#endif + #endif \ No newline at end of file