mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
DHT22 Input support, thermo and esp refactoring
This commit is contained in:
@@ -150,6 +150,7 @@ platformio device monitor -b 115200
|
|||||||
* LAN_INIT_DELAY=2000 // set lan init delay for Wiznet ethernet shield
|
* LAN_INIT_DELAY=2000 // set lan init delay for Wiznet ethernet shield
|
||||||
* ESP_WIFI_AP=MYAP // esp wifi access point name
|
* ESP_WIFI_AP=MYAP // esp wifi access point name
|
||||||
* ESP_WIFI_PWD=MYPWD // esp wifi access point password
|
* ESP_WIFI_PWD=MYPWD // esp wifi access point password
|
||||||
|
* WITHOUT_DHT //disable DHT Input support
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -170,5 +171,6 @@ platformio device monitor -b 115200
|
|||||||
* Defailt MQTT input topic: /myhome/in
|
* Defailt MQTT input topic: /myhome/in
|
||||||
* Default MQTT topic to publish device status: /myhome/s_out
|
* Default MQTT topic to publish device status: /myhome/s_out
|
||||||
* Default Alarm output topic /alarm
|
* Default Alarm output topic /alarm
|
||||||
|
* DHT support enabled
|
||||||
|
|
||||||
If you've using Arduino IDE to compile & flash firmware, it will use Default options above and you will not able to configure additional compilers options except edit "options.h" file
|
If you've using Arduino IDE to compile & flash firmware, it will use Default options above and you will not able to configure additional compilers options except edit "options.h" file
|
||||||
|
|||||||
29
config-examples/c4-3e-11-03-1b-1e.config.json
Normal file
29
config-examples/c4-3e-11-03-1b-1e.config.json
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"mqtt":["garden","192.168.10.115",1883,"test","test"],
|
||||||
|
"ow":{
|
||||||
|
"28FFADCE601705A3":{"emit":"t_soil1","item":"h_relay6"},
|
||||||
|
"286164123FF96F55":{"emit":"t_soil2"},
|
||||||
|
"28FFEF6D60170335":{"emit":"t_soil3"}
|
||||||
|
},
|
||||||
|
"items":{
|
||||||
|
"h_relay1":[6,39,1,1],
|
||||||
|
"h_relay2":[6,38,1,1],
|
||||||
|
"h_relay3":[6,37,1,1],
|
||||||
|
"h_relay4":[6,36,1,1],
|
||||||
|
"h_relay5":[6,35,1,1],
|
||||||
|
"h_relay6":[5,34,27,1],
|
||||||
|
"h_relay7":[6,33,1,1],
|
||||||
|
"h_relay8":[6,32,1,1],
|
||||||
|
"h_auto":[6,29,1,1]
|
||||||
|
},
|
||||||
|
"in":{
|
||||||
|
"40":{"emit":"/myhome/s_out/g_in1","scmd":"CLOSED","rcmd":"OPEN"},
|
||||||
|
"41":{"emit":"/myhome/s_out/g_in2","scmd":"CLOSED","rcmd":"OPEN"},
|
||||||
|
"42":{"emit":"/myhome/s_out/g_in3","scmd":"CLOSED","rcmd":"OPEN"},
|
||||||
|
"43":{"emit":"/myhome/s_out/g_in4","scmd":"CLOSED","rcmd":"OPEN"},
|
||||||
|
"44":{"emit":"/myhome/s_out/g_in5","scmd":"CLOSED","rcmd":"OPEN"},
|
||||||
|
"45":{"emit":"/myhome/s_out/g_in6","scmd":"CLOSED","rcmd":"OPEN"},
|
||||||
|
"46":{"emit":"/myhome/s_out/g_in7","scmd":"CLOSED","rcmd":"OPEN"},
|
||||||
|
"47":{"emit":"/myhome/s_out/g_in8","scmd":"CLOSED","rcmd":"OPEN"}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
config-examples/c4-3e-1f-03-1b-1b.config.json
Executable file
9
config-examples/c4-3e-1f-03-1b-1b.config.json
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"mqtt": ["test_esp","192.168.10.1",1883,"test","test"],
|
||||||
|
"items":{
|
||||||
|
"h_speed0": [6,9],
|
||||||
|
"h_speed1": [6,10]},
|
||||||
|
"in": {
|
||||||
|
"5": {"T":4,"emit": "/myhome/s_out/t_vent_street"}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
{
|
|
||||||
"mqtt":["garden","192.168.10.115",1883,"test","test"],
|
|
||||||
"ow":{
|
|
||||||
"28FFADCE601705A3":{"emit":"t_soil1","item":"h_relay6"},
|
|
||||||
"286164123FF96F55":{"emit":"t_soil2"},
|
|
||||||
"28FFEF6D60170335":{"emit":"t_soil3"}
|
|
||||||
},
|
|
||||||
"items":{
|
|
||||||
"h_relay1":[6,39,1,1],
|
|
||||||
"h_relay2":[6,38,1,1],
|
|
||||||
"h_relay3":[6,37,1,1],
|
|
||||||
"h_relay4":[6,36,1,1],
|
|
||||||
"h_relay5":[6,35,1,1],
|
|
||||||
"h_relay6":[5,34,23],
|
|
||||||
"h_relay7":[6,33,1,1],
|
|
||||||
"h_relay8":[6,32,1,1],
|
|
||||||
"h_auto":[6,29,1,1]
|
|
||||||
},
|
|
||||||
"in":{
|
|
||||||
"40":{"emit":"/garden/s_in/1"},
|
|
||||||
"41":{"emit":"/garden/s_in/2"},
|
|
||||||
"42":{"emit":"/garden/s_in/3"},
|
|
||||||
"43":{"emit":"/garden/s_in/4"},
|
|
||||||
"44":{"emit":"/garden/s_in/5"},
|
|
||||||
"45":{"emit":"/garden/s_in/6"},
|
|
||||||
"46":{"emit":"/garden/s_in/7"},
|
|
||||||
"47":{"emit":"/garden/s_in/8"}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -139,7 +139,7 @@ for (short tch=0; tch<=3 ; tch++)
|
|||||||
{
|
{
|
||||||
D_State |= (1<<tch);
|
D_State |= (1<<tch);
|
||||||
updated=1;
|
updated=1;
|
||||||
//Serial.print("Changed :"); Serial.print(DMXin[tch*4+trh]); Serial.print(" => "); Serial.print(t);Serial.println();
|
//Serial.print("onContactChanged :"); Serial.print(DMXin[tch*4+trh]); Serial.print(" => "); Serial.print(t);Serial.println();
|
||||||
DMXin[base+trh]=t;
|
DMXin[base+trh]=t;
|
||||||
//DMXImmediateUpdate(tch,trh,t);
|
//DMXImmediateUpdate(tch,trh,t);
|
||||||
//break;
|
//break;
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
#include "options.h"
|
|
||||||
#ifdef __ESP__
|
|
||||||
#include "esp.h"
|
|
||||||
|
|
||||||
ESP8266WiFiMulti wifiMulti;
|
|
||||||
WiFiClient ethClient;
|
|
||||||
|
|
||||||
char mqtt_password[16];
|
|
||||||
|
|
||||||
//default custom static IP
|
|
||||||
//char static_ip[16] = "10.0.1.56";
|
|
||||||
//char static_gw[16] = "10.0.1.1";
|
|
||||||
//char static_sn[16] = "255.255.255.0";
|
|
||||||
|
|
||||||
//flag for saving data
|
|
||||||
bool shouldSaveConfig = false;
|
|
||||||
|
|
||||||
//callback notifying us of the need to save config
|
|
||||||
void saveConfigCallback () {
|
|
||||||
Serial.println(F("Should save config"));
|
|
||||||
shouldSaveConfig = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void espSetup () {
|
|
||||||
Serial.println(F("Setting up Wifi"));
|
|
||||||
shouldSaveConfig = true;
|
|
||||||
//WiFiManager
|
|
||||||
|
|
||||||
WiFiManagerParameter custom_mqtt_password("", "mqtt password", mqtt_password, 16);
|
|
||||||
//Local intialization. Once its business is done, there is no need to keep it around
|
|
||||||
WiFiManager wifiManager;
|
|
||||||
|
|
||||||
wifiManager.setSaveConfigCallback(saveConfigCallback);
|
|
||||||
|
|
||||||
wifiManager.addParameter(&custom_mqtt_password);
|
|
||||||
wifiManager.setMinimumSignalQuality();
|
|
||||||
|
|
||||||
if (!wifiManager.autoConnect()) {
|
|
||||||
Serial.println(F("failed to connect and hit timeout"));
|
|
||||||
delay(3000);
|
|
||||||
//reset and try again, or maybe put it to deep sleep
|
|
||||||
ESP.reset();
|
|
||||||
delay(5000);
|
|
||||||
}
|
|
||||||
|
|
||||||
//if you get here you have connected to the WiFi
|
|
||||||
Serial.println(F("connected...yeey :)"));
|
|
||||||
|
|
||||||
//read updated parameters
|
|
||||||
strcpy(mqtt_password, custom_mqtt_password.getValue());
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#include <ESP8266WiFi.h>
|
|
||||||
//needed for library
|
|
||||||
#include <DNSServer.h>
|
|
||||||
#include <ESP8266WebServer.h>
|
|
||||||
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
|
|
||||||
#include <ESP8266WiFiMulti.h>
|
|
||||||
|
|
||||||
extern ESP8266WiFiMulti wifiMulti;
|
|
||||||
extern WiFiClient ethClient;
|
|
||||||
//WiFiManager wifiManager;
|
|
||||||
|
|
||||||
//define your default values here, if there are different values in config.json, they are overwritten.
|
|
||||||
//length should be max size + 1
|
|
||||||
extern char mqtt_password[16];
|
|
||||||
|
|
||||||
//default custom static IP
|
|
||||||
//char static_ip[16] = "10.0.1.56";
|
|
||||||
//char static_gw[16] = "10.0.1.1";
|
|
||||||
//char static_sn[16] = "255.255.255.0";
|
|
||||||
|
|
||||||
//flag for saving data
|
|
||||||
extern bool shouldSaveConfig;
|
|
||||||
|
|
||||||
void espSetup ();
|
|
||||||
@@ -19,11 +19,15 @@ e-mail anklimov@gmail.com
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "inputs.h"
|
#include "inputs.h"
|
||||||
#include "aJSON.h"
|
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
|
|
||||||
|
#ifndef WITHOUT_DHT
|
||||||
|
#include "DHT.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
extern PubSubClient mqttClient;
|
extern PubSubClient mqttClient;
|
||||||
|
//DHT dht();
|
||||||
|
|
||||||
Input::Input(char * name) //Constructor
|
Input::Input(char * name) //Constructor
|
||||||
{
|
{
|
||||||
@@ -60,8 +64,7 @@ void Input::Parse()
|
|||||||
inType = 0;
|
inType = 0;
|
||||||
pin = 0;
|
pin = 0;
|
||||||
|
|
||||||
if (inputObj && (inputObj->type==aJson_Object))
|
if (inputObj && (inputObj->type == aJson_Object)) {
|
||||||
{
|
|
||||||
aJsonObject *s;
|
aJsonObject *s;
|
||||||
|
|
||||||
s = aJson.getObjectItem(inputObj, "T");
|
s = aJson.getObjectItem(inputObj, "T");
|
||||||
@@ -69,9 +72,12 @@ void Input::Parse()
|
|||||||
|
|
||||||
pin = atoi(inputObj->name);
|
pin = atoi(inputObj->name);
|
||||||
|
|
||||||
|
|
||||||
s = aJson.getObjectItem(inputObj, "S");
|
s = aJson.getObjectItem(inputObj, "S");
|
||||||
if (!s) { Serial.print(F("In: "));Serial.print(pin);Serial.print(F("/"));Serial.println(inType);
|
if (!s) {
|
||||||
|
Serial.print(F("In: "));
|
||||||
|
Serial.print(pin);
|
||||||
|
Serial.print(F("/"));
|
||||||
|
Serial.println(inType);
|
||||||
aJson.addNumberToObject(inputObj, "S", 0);
|
aJson.addNumberToObject(inputObj, "S", 0);
|
||||||
s = aJson.getObjectItem(inputObj, "S");
|
s = aJson.getObjectItem(inputObj, "S");
|
||||||
}
|
}
|
||||||
@@ -80,35 +86,68 @@ void Input::Parse()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Input::Poll()
|
int Input::poll() {
|
||||||
{
|
|
||||||
boolean v;
|
|
||||||
if (!isValid()) return -1;
|
if (!isValid()) return -1;
|
||||||
|
if (inType & IN_PUSH_ON)
|
||||||
|
contactPoll();
|
||||||
if (inType & IN_ACTIVE_HIGH)
|
else if (inType & IN_DHT22)
|
||||||
{ pinMode(pin, INPUT);
|
dht22Poll();
|
||||||
v = (digitalRead(pin)==HIGH);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ pinMode(pin, INPUT_PULLUP);
|
|
||||||
v = (digitalRead(pin)==LOW);
|
|
||||||
}
|
|
||||||
if (v!=store->cur) // value changed
|
|
||||||
{
|
|
||||||
if (store->bounce) store->bounce--;
|
|
||||||
else //confirmed change
|
|
||||||
{
|
|
||||||
Changed(v);
|
|
||||||
store->cur=v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // no change
|
|
||||||
store->bounce=3;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::Changed (int val)
|
void Input::dht22Poll() {
|
||||||
|
#ifndef WITHOUT_DHT
|
||||||
|
if (store->nextPollMillis > millis())
|
||||||
|
return;
|
||||||
|
DHT dht(pin, DHT22);
|
||||||
|
float temp = dht.readTemperature();
|
||||||
|
float humidity = dht.readHumidity();
|
||||||
|
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||||
|
Serial.print(F("IN:"));Serial.print(pin);Serial.print(F(" DHT22 type. T="));Serial.print(temp);
|
||||||
|
Serial.print(F("°C H="));Serial.print(humidity);Serial.print(F("%"));
|
||||||
|
if (emit && temp && humidity && temp == temp && humidity == humidity) {
|
||||||
|
char valstr[10];
|
||||||
|
char addrstr[100] = "";
|
||||||
|
strcat(addrstr, emit->valuestring);
|
||||||
|
strcat(addrstr, "T");
|
||||||
|
sprintf(valstr, "%2.1f", temp);
|
||||||
|
mqttClient.publish(addrstr, valstr);
|
||||||
|
addrstr[strlen(addrstr) - 1] = 'H';
|
||||||
|
sprintf(valstr, "%2.1f", humidity);
|
||||||
|
mqttClient.publish(addrstr, valstr);
|
||||||
|
store->nextPollMillis = millis() + DHT_POLL_DELAY_DEFAULT;
|
||||||
|
Serial.print(" NextPollMillis=");Serial.println(store->nextPollMillis);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
store->nextPollMillis = millis() + DHT_POLL_DELAY_DEFAULT/3;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::contactPoll() {
|
||||||
|
boolean currentInputState;
|
||||||
|
uint8_t inputPinMode, inputOnLevel;
|
||||||
|
if (inType & IN_ACTIVE_HIGH) {
|
||||||
|
inputOnLevel = HIGH;
|
||||||
|
inputPinMode = INPUT;
|
||||||
|
} else {
|
||||||
|
inputOnLevel = LOW;
|
||||||
|
inputPinMode = INPUT_PULLUP;
|
||||||
|
}
|
||||||
|
pinMode(pin, inputPinMode);
|
||||||
|
currentInputState = (digitalRead(pin) == inputOnLevel);
|
||||||
|
if (currentInputState != store->currentValue) // value changed
|
||||||
|
{
|
||||||
|
if (store->bounce) store->bounce = store->bounce - 1;
|
||||||
|
else //confirmed change
|
||||||
|
{
|
||||||
|
onContactChanged(currentInputState);
|
||||||
|
store->currentValue = currentInputState;
|
||||||
|
}
|
||||||
|
} else // no change
|
||||||
|
store->bounce = SAME_STATE_ATTEMPTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::onContactChanged(int val)
|
||||||
{
|
{
|
||||||
Serial.print(F("IN:")); Serial.print(pin);Serial.print(F("="));Serial.println(val);
|
Serial.print(F("IN:")); Serial.print(pin);Serial.print(F("="));Serial.println(val);
|
||||||
aJsonObject * item = aJson.getObjectItem(inputObj,"item");
|
aJsonObject * item = aJson.getObjectItem(inputObj,"item");
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ e-mail anklimov@gmail.com
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "aJSON.h"
|
#include <aJSON.h>
|
||||||
|
|
||||||
#define IN_ACTIVE_HIGH 2 // High level = PUSHED/ CLOSED/ ON othervise :Low Level
|
#define IN_ACTIVE_HIGH 2 // High level = PUSHED/ CLOSED/ ON othervise :Low Level
|
||||||
#define IN_ANALOG 64 // Analog input
|
#define IN_ANALOG 64 // Analog input
|
||||||
@@ -26,7 +26,9 @@ e-mail anklimov@gmail.com
|
|||||||
|
|
||||||
#define IN_PUSH_ON 0 // PUSH - ON, Release - OFF (ovverrided by pcmd/rcmd) - DEFAULT
|
#define IN_PUSH_ON 0 // PUSH - ON, Release - OFF (ovverrided by pcmd/rcmd) - DEFAULT
|
||||||
#define IN_PUSH_TOGGLE 1 // Every physicall push toggle logical switch on/off
|
#define IN_PUSH_TOGGLE 1 // Every physicall push toggle logical switch on/off
|
||||||
|
#define IN_DHT22 4
|
||||||
|
|
||||||
|
#define SAME_STATE_ATTEMPTS 3
|
||||||
|
|
||||||
// in syntaxis
|
// in syntaxis
|
||||||
// "pin": { "T":"N", "emit":"out_emit", item:"out_item", "scmd": "ON,OFF,TOGGLE,INCREASE,DECREASE", "rcmd": "ON,OFF,TOGGLE,INCREASE,DECREASE", "rcmd":"repeat_command" }
|
// "pin": { "T":"N", "emit":"out_emit", item:"out_item", "scmd": "ON,OFF,TOGGLE,INCREASE,DECREASE", "rcmd": "ON,OFF,TOGGLE,INCREASE,DECREASE", "rcmd":"repeat_command" }
|
||||||
@@ -57,19 +59,20 @@ e-mail anklimov@gmail.com
|
|||||||
//"pin1": { "T":"0", "emit":"/light1", item:"light1", "scmd": "ON", repcmd:"INCREASE"}
|
//"pin1": { "T":"0", "emit":"/light1", item:"light1", "scmd": "ON", repcmd:"INCREASE"}
|
||||||
//"pin2": { "T":"0", "emit":"/light1", item:"light1", "scmd": "OFF", repcmd:"INCREASE"}
|
//"pin2": { "T":"0", "emit":"/light1", item:"light1", "scmd": "OFF", repcmd:"INCREASE"}
|
||||||
|
|
||||||
|
|
||||||
extern aJsonObject *inputs;
|
extern aJsonObject *inputs;
|
||||||
|
|
||||||
|
|
||||||
typedef union
|
typedef union
|
||||||
{
|
{
|
||||||
long int aslong;
|
long int aslong;
|
||||||
struct
|
struct {
|
||||||
{
|
|
||||||
int8_t reserve;
|
int8_t reserve;
|
||||||
int8_t logicState;
|
int8_t logicState;
|
||||||
int8_t bounce;
|
int8_t bounce;
|
||||||
int8_t cur;
|
int8_t currentValue;
|
||||||
};
|
};
|
||||||
|
unsigned long nextPollMillis;
|
||||||
} inStore;
|
} inStore;
|
||||||
|
|
||||||
class Input
|
class Input
|
||||||
@@ -85,9 +88,14 @@ class Input
|
|||||||
Input(char * name);
|
Input(char * name);
|
||||||
|
|
||||||
boolean isValid ();
|
boolean isValid ();
|
||||||
void Changed (int val);
|
void onContactChanged(int val);
|
||||||
|
|
||||||
int Poll();
|
int poll();
|
||||||
protected:
|
protected:
|
||||||
void Parse();
|
void Parse();
|
||||||
|
|
||||||
|
void contactPoll();
|
||||||
|
|
||||||
|
void dht22Poll();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -741,7 +741,7 @@ OFF
|
|||||||
|
|
||||||
POLL 2101x10
|
POLL 2101x10
|
||||||
[22:27:29] <= Response: 0A 03 14 00 23 00 00 27 10 13 88 0B 9C 00 32 00 F8 00 F2 06 FA 01 3F AD D0
|
[22:27:29] <= Response: 0A 03 14 00 23 00 00 27 10 13 88 0B 9C 00 32 00 F8 00 F2 06 FA 01 3F AD D0
|
||||||
[22:27:29] => Poll: 0A 03 08 34 00 0A 87 18
|
[22:27:29] => poll: 0A 03 08 34 00 0A 87 18
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class Item
|
|||||||
class PooledItem : public Item
|
class PooledItem : public Item
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual int Changed() = 0;
|
virtual int onContactChanged() = 0;
|
||||||
virtual void Idle ();
|
virtual void Idle ();
|
||||||
protected:
|
protected:
|
||||||
int PoolingInterval;
|
int PoolingInterval;
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ ESP32
|
|||||||
PWM Out
|
PWM Out
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
@@ -78,6 +77,12 @@ EthernetClient ethClient;
|
|||||||
EthernetClient ethClient;
|
EthernetClient ethClient;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __ESP__
|
||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <user_interface.h>
|
||||||
|
WiFiClient ethClient;
|
||||||
|
#endif
|
||||||
|
|
||||||
const char outprefix[] PROGMEM = OUTTOPIC;
|
const char outprefix[] PROGMEM = OUTTOPIC;
|
||||||
const char inprefix[] PROGMEM = INTOPIC;
|
const char inprefix[] PROGMEM = INTOPIC;
|
||||||
const char configserver[] PROGMEM = CONFIG_SERVER;
|
const char configserver[] PROGMEM = CONFIG_SERVER;
|
||||||
@@ -91,7 +96,6 @@ aJsonObject *mqttArr = NULL;
|
|||||||
aJsonObject *modbusArr = NULL;
|
aJsonObject *modbusArr = NULL;
|
||||||
aJsonObject *owArr = NULL;
|
aJsonObject *owArr = NULL;
|
||||||
aJsonObject *dmxArr = NULL;
|
aJsonObject *dmxArr = NULL;
|
||||||
aJsonObject *dhtArr = NULL;
|
|
||||||
|
|
||||||
unsigned long nextPollingCheck = 0;
|
unsigned long nextPollingCheck = 0;
|
||||||
unsigned long nextInputCheck = 0;
|
unsigned long nextInputCheck = 0;
|
||||||
@@ -114,6 +118,12 @@ byte mac[6];
|
|||||||
PubSubClient mqttClient(ethClient);
|
PubSubClient mqttClient(ethClient);
|
||||||
|
|
||||||
|
|
||||||
|
bool wifiInitialized;
|
||||||
|
|
||||||
|
bool IsThermostat(const aJsonObject *item);
|
||||||
|
|
||||||
|
bool disabledDisconnected(const aJsonObject *thermoExtensionArray, int thermoLatestCommand);
|
||||||
|
|
||||||
void watchdogSetup(void) {
|
void watchdogSetup(void) {
|
||||||
//Serial.begin(115200);
|
//Serial.begin(115200);
|
||||||
//Serial.println("Watchdog armed.");
|
//Serial.println("Watchdog armed.");
|
||||||
@@ -213,13 +223,25 @@ int lanLoop() {
|
|||||||
case 0: //Ethernet.begin(mac,ip);
|
case 0: //Ethernet.begin(mac,ip);
|
||||||
{
|
{
|
||||||
#ifdef __ESP__
|
#ifdef __ESP__
|
||||||
|
if(!wifiInitialized) {
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
Serial.print(F("WIFI AP/Password:"));
|
Serial.print(F("WIFI AP/Password:"));
|
||||||
Serial.print(QUOTE(ESP_WIFI_AP));
|
Serial.print(QUOTE(ESP_WIFI_AP));
|
||||||
Serial.print(F("/"));
|
Serial.print(F("/"));
|
||||||
Serial.println(QUOTE(ESP_WIFI_PWD));
|
Serial.println(QUOTE(ESP_WIFI_PWD));
|
||||||
wifiMulti.addAP(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
|
wifi_set_macaddr(STATION_IF,mac);
|
||||||
if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
|
WiFi.begin(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
|
||||||
|
wifiInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
|
Serial.println("WiFi connected");
|
||||||
|
Serial.println("IP address: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
lanStatus=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
IPAddress ip;
|
IPAddress ip;
|
||||||
IPAddress dns;
|
IPAddress dns;
|
||||||
@@ -426,7 +448,6 @@ int lanLoop() {
|
|||||||
return lanStatus;
|
return lanStatus;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _owire
|
#ifdef _owire
|
||||||
|
|
||||||
void Changed(int i, DeviceAddress addr, int val) {
|
void Changed(int i, DeviceAddress addr, int val) {
|
||||||
@@ -436,13 +457,9 @@ void Changed(int i, DeviceAddress addr, int val) {
|
|||||||
char *owEmit = NULL;
|
char *owEmit = NULL;
|
||||||
char *owItem = NULL;
|
char *owItem = NULL;
|
||||||
|
|
||||||
//PrintBytes(addr,8);
|
|
||||||
// Serial.print("Emit: ");
|
|
||||||
SetBytes(addr, 8, addrbuf);
|
SetBytes(addr, 8, addrbuf);
|
||||||
addrbuf[17] = 0;
|
addrbuf[17] = 0;
|
||||||
|
|
||||||
//Serial.println(addrbuf);
|
|
||||||
|
|
||||||
aJsonObject *owObj = aJson.getObjectItem(owArr, addrbuf);
|
aJsonObject *owObj = aJson.getObjectItem(owArr, addrbuf);
|
||||||
if (owObj) {
|
if (owObj) {
|
||||||
owEmit = aJson.getObjectItem(owObj, "emit")->valuestring;
|
owEmit = aJson.getObjectItem(owObj, "emit")->valuestring;
|
||||||
@@ -453,56 +470,14 @@ void Changed(int i, DeviceAddress addr, int val) {
|
|||||||
Serial.println(val);
|
Serial.println(val);
|
||||||
}
|
}
|
||||||
owItem = aJson.getObjectItem(owObj, "item")->valuestring;
|
owItem = aJson.getObjectItem(owObj, "item")->valuestring;
|
||||||
} else Serial.println(F("Not find"));
|
} else Serial.println(F("1w-item not found in config"));
|
||||||
|
|
||||||
|
|
||||||
/* No sw support anymore
|
|
||||||
switch (addr[0]){
|
|
||||||
case 0x29: // DS2408
|
|
||||||
snprintf(addrstr,sizeof(addrstr),"%sS0%s",outprefix,addrbuf);
|
|
||||||
// Serial.println(addrstr);
|
|
||||||
client.publish(addrstr, (val & SW_STAT0)?"ON":"OFF");
|
|
||||||
snprintf(addrstr,sizeof(addrstr),"%sS1%s",outprefix,addrbuf);
|
|
||||||
// Serial.println(addrstr);
|
|
||||||
client.publish(addrstr, (val & SW_STAT1)?"ON":"OFF");
|
|
||||||
snprintf(addrstr,sizeof(addrstr),"%sS2%s",outprefix,addrbuf);
|
|
||||||
// Serial.println(addrstr);
|
|
||||||
client.publish(addrstr, (val & SW_AUX0)?"OFF":"ON");
|
|
||||||
snprintf(addrstr,sizeof(addrstr),"%sS3%s",outprefix,addrbuf);
|
|
||||||
// Serial.println(addrstr);
|
|
||||||
client.publish(addrstr, (val & SW_AUX1)?"OFF":"ON");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x28: // Thermomerer
|
|
||||||
|
|
||||||
snprintf(addrstr,sizeof(addrstr),"%s%s",outprefix,addrbuf);
|
|
||||||
sprintf(valstr,"%d",val);
|
|
||||||
//Serial.println(val);
|
|
||||||
//Serial.println(valstr);
|
|
||||||
client.publish(addrstr, valstr);
|
|
||||||
|
|
||||||
if (owItem)
|
|
||||||
{
|
|
||||||
thermoSetCurTemp(owItem,val);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x01:
|
|
||||||
case 0x81:
|
|
||||||
snprintf(addrstr,sizeof(addrstr),"%sDS%s",outprefix,addrbuf);
|
|
||||||
if (val) sprintf(valstr,"%s","ON"); else sprintf(valstr,"%s","OFF");
|
|
||||||
client.publish(addrstr, valstr);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ((val == -127) || (val == 85) || (val == 0)) { //ToDo: 1-w short circuit mapped to "0" celsium
|
if ((val == -127) || (val == 85) || (val == 0)) { //ToDo: 1-w short circuit mapped to "0" celsium
|
||||||
// Serial.print("Temp err ");Serial.println(t);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy_P(addrstr, outprefix);
|
strcpy_P(addrstr, outprefix);
|
||||||
strncat(addrstr, addrbuf, sizeof(addrstr));
|
strncat(addrstr, addrbuf, sizeof(addrstr));
|
||||||
//snprintf(addrstr,sizeof(addrstr),"%s%s",F(outprefix),addrbuf);
|
|
||||||
sprintf(valstr, "%d", val);
|
sprintf(valstr, "%d", val);
|
||||||
mqttClient.publish(addrstr, valstr);
|
mqttClient.publish(addrstr, valstr);
|
||||||
|
|
||||||
@@ -538,9 +513,7 @@ void cmdFunctionKill(int arg_cnt, char **args) {
|
|||||||
|
|
||||||
void applyConfig() {
|
void applyConfig() {
|
||||||
if (!root) return;
|
if (!root) return;
|
||||||
#ifdef DHT_ENABLE
|
|
||||||
dhtArr = aJson.getObjectItem(root, "dht");
|
|
||||||
#endif
|
|
||||||
#ifdef _dmxin
|
#ifdef _dmxin
|
||||||
int itemsCount;
|
int itemsCount;
|
||||||
dmxArr = aJson.getObjectItem(root, "dmxin");
|
dmxArr = aJson.getObjectItem(root, "dmxin");
|
||||||
@@ -630,8 +603,6 @@ void printConfigSummary() {
|
|||||||
printBool(mqttArr);
|
printBool(mqttArr);
|
||||||
Serial.print(F("1-wire "));
|
Serial.print(F("1-wire "));
|
||||||
printBool(owArr);
|
printBool(owArr);
|
||||||
Serial.print(F("dht "));
|
|
||||||
printBool(dhtArr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmdFunctionLoad(int arg_cnt, char **args) {
|
void cmdFunctionLoad(int arg_cnt, char **args) {
|
||||||
@@ -825,27 +796,28 @@ int getConfig(int arg_cnt, char **args)
|
|||||||
Serial.println(URI);
|
Serial.println(URI);
|
||||||
|
|
||||||
#if defined(__AVR__)
|
#if defined(__AVR__)
|
||||||
FILE *result;
|
FILE *configStream;
|
||||||
//byte hserver[] = { 192,168,88,2 };
|
//byte hserver[] = { 192,168,88,2 };
|
||||||
wdt_dis();
|
wdt_dis();
|
||||||
|
|
||||||
HTTPClient hclient(configServer, 80);
|
HTTPClient hclient(configServer, 80);
|
||||||
|
HTTPClient hclientPrint(configServer, 80);
|
||||||
// FILE is the return STREAM type of the HTTPClient
|
// FILE is the return STREAM type of the HTTPClient
|
||||||
result = hclient.getURI(URI);
|
configStream = hclient.getURI(URI);
|
||||||
responseStatusCode = hclient.getLastReturnCode();
|
responseStatusCode = hclient.getLastReturnCode();
|
||||||
wdt_en();
|
wdt_en();
|
||||||
|
|
||||||
if (result != NULL) {
|
if (configStream != NULL) {
|
||||||
if (responseStatusCode == 200) {
|
if (responseStatusCode == 200) {
|
||||||
|
|
||||||
Serial.println(F("got Config"));
|
Serial.println(F("got Config"));
|
||||||
aJsonFileStream as = aJsonFileStream(result);
|
char c;
|
||||||
|
aJsonFileStream as = aJsonFileStream(configStream);
|
||||||
noInterrupts();
|
noInterrupts();
|
||||||
aJson.deleteItem(root);
|
aJson.deleteItem(root);
|
||||||
root = aJson.parse(&as);
|
root = aJson.parse(&as);
|
||||||
interrupts();
|
interrupts();
|
||||||
// Serial.println(F("Parsed."));
|
// Serial.println(F("Parsed."));
|
||||||
hclient.closeStream(result); // this is very important -- be sure to close the STREAM
|
hclient.closeStream(configStream); // this is very important -- be sure to close the STREAM
|
||||||
|
|
||||||
if (!root) {
|
if (!root) {
|
||||||
Serial.println(F("Config parsing failed"));
|
Serial.println(F("Config parsing failed"));
|
||||||
@@ -982,11 +954,6 @@ void setup_main() {
|
|||||||
#ifdef SD_CARD_INSERTED
|
#ifdef SD_CARD_INSERTED
|
||||||
sd_card_w5100_setup();
|
sd_card_w5100_setup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __ESP__
|
|
||||||
espSetup();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
setupMacAddress();
|
setupMacAddress();
|
||||||
loadConfigFromEEPROM(0, NULL);
|
loadConfigFromEEPROM(0, NULL);
|
||||||
|
|
||||||
@@ -1074,6 +1041,15 @@ void printFirmwareVersionAndBuildOptions() {
|
|||||||
#else
|
#else
|
||||||
Serial.println(F("(+)OWIRE"));
|
Serial.println(F("(+)OWIRE"));
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef WITHOUT_DHT
|
||||||
|
Serial.println(F("(+)DHT"));
|
||||||
|
#else
|
||||||
|
Serial.println(F("(-)DHT"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Wiz5500
|
||||||
|
Serial.println(F("(+)Wiz5500"));
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef SD_CARD_INSERTED
|
#ifdef SD_CARD_INSERTED
|
||||||
Serial.println(F("(+)SDCARD"));
|
Serial.println(F("(+)SDCARD"));
|
||||||
@@ -1210,7 +1186,7 @@ void inputLoop(void) {
|
|||||||
while (input) {
|
while (input) {
|
||||||
if ((input->type == aJson_Object)) {
|
if ((input->type == aJson_Object)) {
|
||||||
Input in(input);
|
Input in(input);
|
||||||
in.Poll();
|
in.poll();
|
||||||
}
|
}
|
||||||
input = input->next;
|
input = input->next;
|
||||||
}
|
}
|
||||||
@@ -1238,64 +1214,70 @@ void pollingLoop(void) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool isThermostatWithMinArraySize(aJsonObject *item, int minimalArraySize) {
|
||||||
|
return (item->type == aJson_Array) && (aJson.getArrayItem(item, I_TYPE)->valueint == CH_THERMO) &&
|
||||||
|
(aJson.getArraySize(item) >= minimalArraySize);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool thermoDisabledOrDisconnected(aJsonObject *thermoExtensionArray, int thermoStateCommand) {
|
||||||
|
return thermoStateCommand == CMD_OFF || thermoStateCommand == CMD_HALT ||
|
||||||
|
aJson.getArrayItem(thermoExtensionArray, IET_ATTEMPTS)->valueint == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO: refactoring
|
//TODO: refactoring
|
||||||
|
|
||||||
void thermoLoop(void) {
|
void thermoLoop(void) {
|
||||||
if (millis() < nextThermostatCheck)
|
if (millis() < nextThermostatCheck)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool thermostatCheckPrinted = false;
|
bool thermostatCheckPrinted = false;
|
||||||
aJsonObject *item = items->child;
|
|
||||||
|
|
||||||
while (item) {
|
for (aJsonObject *thermoItem = items->child; thermoItem; thermoItem = thermoItem->next) {
|
||||||
if ((item->type == aJson_Array) && (aJson.getArrayItem(item, 0)->valueint == CH_THERMO) &&
|
if (isThermostatWithMinArraySize(thermoItem, 5)) {
|
||||||
(aJson.getArraySize(item) > 4)) {
|
aJsonObject *thermoExtensionArray = aJson.getArrayItem(thermoItem, I_EXT);
|
||||||
int itemPin = aJson.getArrayItem(item, I_ARG)->valueint;
|
if (thermoExtensionArray && (aJson.getArraySize(thermoExtensionArray) > 1)) {
|
||||||
int itemTempSetting = aJson.getArrayItem(item, I_VAL)->valueint;
|
int thermoPin = aJson.getArrayItem(thermoItem, I_ARG)->valueint;
|
||||||
int itemCommand = aJson.getArrayItem(item, I_CMD)->valueint;
|
int thermoSetting = aJson.getArrayItem(thermoItem, I_VAL)->valueint;
|
||||||
aJsonObject *itemExtensionArray = aJson.getArrayItem(item, I_EXT);
|
int thermoStateCommand = aJson.getArrayItem(thermoItem, I_CMD)->valueint;
|
||||||
|
int curTemp = aJson.getArrayItem(thermoExtensionArray, IET_TEMP)->valueint;
|
||||||
|
|
||||||
if (itemExtensionArray && (aJson.getArraySize(itemExtensionArray) > 1)) {
|
if (!aJson.getArrayItem(thermoExtensionArray, IET_ATTEMPTS)->valueint) {
|
||||||
int curtemp = aJson.getArrayItem(itemExtensionArray, IET_TEMP)->valueint;
|
Serial.print(thermoItem->name);
|
||||||
if (!aJson.getArrayItem(itemExtensionArray, IET_ATTEMPTS)->valueint) {
|
|
||||||
Serial.print(item->name);
|
|
||||||
Serial.println(F(" Expired"));
|
Serial.println(F(" Expired"));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!(--aJson.getArrayItem(itemExtensionArray, IET_ATTEMPTS)->valueint))
|
if (!(--aJson.getArrayItem(thermoExtensionArray, IET_ATTEMPTS)->valueint))
|
||||||
mqttClient.publish("/alarm/snsr", item->name);
|
mqttClient.publish("/alarm/snsr", thermoItem->name);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (curtemp > THERMO_OVERHEAT_CELSIUS) mqttClient.publish("/alarm/ovrht", item->name);
|
if (curTemp > THERMO_OVERHEAT_CELSIUS) mqttClient.publish("/alarm/ovrht", thermoItem->name);
|
||||||
|
|
||||||
thermostatCheckPrinted = true;
|
|
||||||
Serial.print(item->name);
|
Serial.print(thermoItem->name);
|
||||||
Serial.print(F(" Set:"));
|
Serial.print(F(" Set:"));
|
||||||
Serial.print(itemTempSetting);
|
Serial.print(thermoSetting);
|
||||||
Serial.print(F(" Curtemp:"));
|
Serial.print(F(" Cur:"));
|
||||||
Serial.print(curtemp);
|
Serial.print(curTemp);
|
||||||
Serial.print(F(" cmd:"));
|
Serial.print(F(" cmd:"));
|
||||||
Serial.print(itemCommand), pinMode(itemPin, OUTPUT);
|
Serial.print(thermoStateCommand);
|
||||||
if (itemCommand == CMD_OFF || itemCommand == CMD_HALT ||
|
pinMode(thermoPin, OUTPUT);
|
||||||
aJson.getArrayItem(itemExtensionArray, IET_ATTEMPTS)->valueint == 0) {
|
if (thermoDisabledOrDisconnected(thermoExtensionArray, thermoStateCommand)) {
|
||||||
digitalWrite(itemPin, LOW);
|
digitalWrite(thermoPin, LOW);
|
||||||
Serial.println(F(" OFF"));
|
Serial.println(F(" OFF"));
|
||||||
} else {
|
} else {
|
||||||
if (curtemp + THERMO_GIST_CELSIUS < itemTempSetting) {
|
if (curTemp < thermoSetting - THERMO_GIST_CELSIUS) {
|
||||||
digitalWrite(itemPin, HIGH);
|
digitalWrite(thermoPin, HIGH);
|
||||||
Serial.println(F(" ON"));
|
Serial.println(F(" ON"));
|
||||||
} //too cold
|
} //too cold
|
||||||
else if (itemTempSetting <= curtemp) {
|
else if (curTemp >= thermoSetting) {
|
||||||
digitalWrite(itemPin, LOW);
|
digitalWrite(thermoPin, LOW);
|
||||||
Serial.println(F(" OFF"));
|
Serial.println(F(" OFF"));
|
||||||
} //Reached settings
|
} //Reached settings
|
||||||
else Serial.println(F(" --")); // Nothing to do
|
else Serial.println(F(" -target zone-")); // Nothing to do
|
||||||
|
}
|
||||||
|
thermostatCheckPrinted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
item = item->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
nextThermostatCheck = millis() + THERMOSTAT_CHECK_PERIOD;
|
nextThermostatCheck = millis() + THERMOSTAT_CHECK_PERIOD;
|
||||||
|
|
||||||
@@ -1306,15 +1288,13 @@ void thermoLoop(void) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
short thermoSetCurTemp(char *name, short t) {
|
short thermoSetCurTemp(char *name, short t) {
|
||||||
if (items) {
|
if (items) {
|
||||||
aJsonObject *item = aJson.getObjectItem(items, name);
|
aJsonObject *thermoItem = aJson.getObjectItem(items, name);
|
||||||
if (item && (item->type == aJson_Array) && (aJson.getArrayItem(item, I_TYPE)->valueint == CH_THERMO) &&
|
if (isThermostatWithMinArraySize(thermoItem, 4)) {
|
||||||
(aJson.getArraySize(item) >= 4)) {
|
|
||||||
aJsonObject *extArray = NULL;
|
aJsonObject *extArray = NULL;
|
||||||
|
|
||||||
if (aJson.getArraySize(item) == 4) //No thermo extension yet
|
if (aJson.getArraySize(thermoItem) == 4) //No thermo extension yet
|
||||||
{
|
{
|
||||||
extArray = aJson.createArray(); //Create Ext Array
|
extArray = aJson.createArray(); //Create Ext Array
|
||||||
|
|
||||||
@@ -1322,17 +1302,17 @@ short thermoSetCurTemp(char *name, short t) {
|
|||||||
aJsonObject *oattempts = aJson.createItem(T_ATTEMPTS); //Create int
|
aJsonObject *oattempts = aJson.createItem(T_ATTEMPTS); //Create int
|
||||||
aJson.addItemToArray(extArray, ocurt);
|
aJson.addItemToArray(extArray, ocurt);
|
||||||
aJson.addItemToArray(extArray, oattempts);
|
aJson.addItemToArray(extArray, oattempts);
|
||||||
aJson.addItemToArray(item, extArray); //Adding to item
|
aJson.addItemToArray(thermoItem, extArray); //Adding to thermoItem
|
||||||
} //if
|
}
|
||||||
else if (extArray = aJson.getArrayItem(item, I_EXT)) {
|
else if (extArray = aJson.getArrayItem(thermoItem, I_EXT)) {
|
||||||
aJsonObject *att = aJson.getArrayItem(extArray, IET_ATTEMPTS);
|
aJsonObject *att = aJson.getArrayItem(extArray, IET_ATTEMPTS);
|
||||||
aJson.getArrayItem(extArray, IET_TEMP)->valueint = t;
|
aJson.getArrayItem(extArray, IET_TEMP)->valueint = t;
|
||||||
if (att->valueint == 0) mqttClient.publish("/alarmoff/snsr", item->name);
|
if (att->valueint == 0) mqttClient.publish("/alarmoff/snsr", thermoItem->name);
|
||||||
att->valueint = (int) T_ATTEMPTS;
|
att->valueint = (int) T_ATTEMPTS;
|
||||||
} //if
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} //if
|
}
|
||||||
} // if items
|
|
||||||
|
|
||||||
} //proc
|
|
||||||
|
|||||||
@@ -61,7 +61,6 @@
|
|||||||
|
|
||||||
#if defined(__ESP__)
|
#if defined(__ESP__)
|
||||||
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
||||||
#include "esp.h"
|
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#include <ESP8266HTTPClient.h>
|
#include <ESP8266HTTPClient.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -34,6 +34,10 @@
|
|||||||
#define INTERVAL_POLLING 100
|
#define INTERVAL_POLLING 100
|
||||||
#define THERMOSTAT_CHECK_PERIOD 5000
|
#define THERMOSTAT_CHECK_PERIOD 5000
|
||||||
|
|
||||||
|
#ifndef OW_UPDATE_INTERVAL
|
||||||
|
#define OW_UPDATE_INTERVAL 5000
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MODBUS_SERIAL_BAUD
|
#ifndef MODBUS_SERIAL_BAUD
|
||||||
#define MODBUS_SERIAL_BAUD 9600
|
#define MODBUS_SERIAL_BAUD 9600
|
||||||
#endif
|
#endif
|
||||||
@@ -132,3 +136,5 @@
|
|||||||
#ifndef ESP_WIFI_PWD
|
#ifndef ESP_WIFI_PWD
|
||||||
#define ESP_WIFI_PWD mywifipass
|
#define ESP_WIFI_PWD mywifipass
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DHT_POLL_DELAY_DEFAULT 15000
|
||||||
@@ -41,7 +41,7 @@ unsigned long owTimer = 0;
|
|||||||
owChangedType owChanged;
|
owChangedType owChanged;
|
||||||
|
|
||||||
int owUpdate() {
|
int owUpdate() {
|
||||||
unsigned long finish = millis() + 5000;
|
unsigned long finish = millis() + OW_UPDATE_INTERVAL;
|
||||||
short sr;
|
short sr;
|
||||||
|
|
||||||
//net.setStrongPullup();
|
//net.setStrongPullup();
|
||||||
|
|||||||
@@ -10,10 +10,10 @@
|
|||||||
[platformio]
|
[platformio]
|
||||||
src_dir = lighthub
|
src_dir = lighthub
|
||||||
env_default =
|
env_default =
|
||||||
; megaatmega2560
|
megaatmega2560
|
||||||
; due
|
; due
|
||||||
; esp8266
|
; esp8266
|
||||||
megaatmega2560-5500
|
; megaatmega2560-5500
|
||||||
; due-5500
|
; due-5500
|
||||||
; controllino
|
; controllino
|
||||||
|
|
||||||
@@ -40,6 +40,8 @@ lib_deps =
|
|||||||
FastLED
|
FastLED
|
||||||
SD
|
SD
|
||||||
SdFat
|
SdFat
|
||||||
|
Adafruit Unified Sensor
|
||||||
|
DHT sensor library
|
||||||
|
|
||||||
|
|
||||||
[env:megaatmega2560]
|
[env:megaatmega2560]
|
||||||
@@ -64,6 +66,8 @@ lib_deps =
|
|||||||
https://github.com/anklimov/Artnet.git
|
https://github.com/anklimov/Artnet.git
|
||||||
FastLED
|
FastLED
|
||||||
EEPROM
|
EEPROM
|
||||||
|
Adafruit Unified Sensor
|
||||||
|
DHT sensor library
|
||||||
|
|
||||||
|
|
||||||
[env:esp8266]
|
[env:esp8266]
|
||||||
@@ -71,7 +75,7 @@ platform = espressif8266
|
|||||||
framework = arduino
|
framework = arduino
|
||||||
board = nodemcuv2
|
board = nodemcuv2
|
||||||
lib_ldf_mode = chain+
|
lib_ldf_mode = chain+
|
||||||
build_flags = !echo -n "-DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
build_flags = !echo -n "-DMODBUS_DISABLE -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
||||||
;extra_scripts = pre:my_build_flags.py
|
;extra_scripts = pre:my_build_flags.py
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
@@ -84,7 +88,10 @@ lib_deps =
|
|||||||
https://github.com/knolleary/pubsubclient.git
|
https://github.com/knolleary/pubsubclient.git
|
||||||
https://github.com/anklimov/Artnet.git
|
https://github.com/anklimov/Artnet.git
|
||||||
FastLED
|
FastLED
|
||||||
WifiManager
|
Adafruit Unified Sensor
|
||||||
|
DHT sensor library for ESPx
|
||||||
|
DHT sensor library
|
||||||
|
|
||||||
|
|
||||||
[env:megaatmega2560-5500]
|
[env:megaatmega2560-5500]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
@@ -109,6 +116,8 @@ lib_deps =
|
|||||||
https://github.com/anklimov/Artnet.git
|
https://github.com/anklimov/Artnet.git
|
||||||
FastLED
|
FastLED
|
||||||
EEPROM
|
EEPROM
|
||||||
|
Adafruit Unified Sensor
|
||||||
|
DHT sensor library
|
||||||
|
|
||||||
[env:due-5500]
|
[env:due-5500]
|
||||||
platform = atmelsam
|
platform = atmelsam
|
||||||
@@ -134,7 +143,8 @@ lib_deps =
|
|||||||
FastLED
|
FastLED
|
||||||
SD
|
SD
|
||||||
SdFat
|
SdFat
|
||||||
|
Adafruit Unified Sensor
|
||||||
|
DHT sensor library
|
||||||
|
|
||||||
[env:controllino]
|
[env:controllino]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
@@ -159,4 +169,5 @@ lib_deps =
|
|||||||
https://github.com/anklimov/Artnet.git
|
https://github.com/anklimov/Artnet.git
|
||||||
FastLED
|
FastLED
|
||||||
EEPROM
|
EEPROM
|
||||||
|
Adafruit Unified Sensor
|
||||||
|
DHT sensor library
|
||||||
|
|||||||
Reference in New Issue
Block a user