diff --git a/data/homie/config.json b/data/homie/config.json index 2c023f5..41d78d5 100644 --- a/data/homie/config.json +++ b/data/homie/config.json @@ -1,12 +1,12 @@ { -"name": "sensoresp3", -"device_id": "sensoresp3", +"name": "sensorespx", +"device_id": "sensorespx", "wifi": { -"ssid": "ssid", +"ssid": "wifissid", "password": "password" }, "mqtt": { -"host": "10.0.0.1", +"host": "MQTTBROKER", "port": 1883, "auth": false, "base_topic": "" diff --git a/platformio.ini b/platformio.ini index 7c90cb6..696a1df 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,7 +8,8 @@ ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html -[env:d1_mini] +#Wohnzimmer +[env:sensoresp3] platform = espressif8266 board = d1_mini framework = arduino @@ -16,6 +17,23 @@ framework = arduino monitor_port = /dev/ttyUSB0 monitor_speed = 115200 +data_dir=data_sensoresp3 +upload_port=/dev/ttyUSB0 + +build_flags = + -D SENSOR_DHT22 + -D DHTPIN=D7 + -D dataDHT22_temperature_minchange=0.1 + -D dataDHT22_humidity_minchange=1.0 + + -D SENSOR_PIR + -D PIRPIN=D6 + -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 diff --git a/src/main.cpp b/src/main.cpp index 10ba5d4..8a85191 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,6 @@ //#define DEBUG +/* Listed below are all possible defines with comments. Defines are done in platformio.ini under the sensors environment // DHT22 #define SENSOR_DHT22 #define DHTPIN D7 // Digital pin connected to the DHT sensor. // dht pins: 1=power, 2=data, 3=NC, 4=GND. 10k from data to power needed @@ -10,6 +11,7 @@ //BH1750 Lux Sensor #define SENSOR_BH1750 +*/ //GPIO2 is blue led on wemos_d1 @@ -92,8 +94,12 @@ void setup() { #ifdef SENSOR_DHT22 Serial.println("initializing dht"); dht.begin(); - dataDHT22_temperature.minchange=0.1; - dataDHT22_humidity.minchange=1.0; + #ifdef dataDHT22_temperature_minchange + dataDHT22_temperature.minchange=dataDHT22_temperature_minchange; + #endif + #ifdef dataDHT22_humidity_minchange + dataDHT22_humidity.minchange=dataDHT22_humidity.minchange; + #endif #endif #ifdef SENSOR_BH1750 @@ -104,15 +110,23 @@ void setup() { } else { Serial.println(F("Error initialising BH1750")); } - dataBH1750.minchange=10.0; - dataBH1750.senddelaymax=1000*60*2; + #ifdef dataBH1750_minchange + dataBH1750.minchange=dataBH1750_minchange; + #endif + #ifdef dataBH1750_senddelaymax + dataBH1750.senddelaymax=dataBH1750_senddelaymax; + #endif #endif #ifdef SENSOR_PIR pinMode(PIRPIN, INPUT_PULLUP); - dataPIR.readdelay=100; - dataPIR.senddelaymax=1000*60*10; + #ifdef dataPIR_readdelay + dataPIR.readdelay=dataPIR_readdelay; + #endif + #ifdef dataPIR_senddelaymax + dataPIR.senddelaymax=dataPIR_senddelaymax; + #endif #endif Serial.println("connecting..");