From f198dc1b95e1132e68a978fb234200f5f655aeb1 Mon Sep 17 00:00:00 2001 From: lexa Date: Thu, 19 Nov 2020 20:53:01 +0300 Subject: [PATCH 1/3] Msg --- ExtSens/src/main.cpp | 4 ++-- MainDoorMyS/src/main.cpp | 45 ++++++++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/ExtSens/src/main.cpp b/ExtSens/src/main.cpp index d445731..e771935 100644 --- a/ExtSens/src/main.cpp +++ b/ExtSens/src/main.cpp @@ -24,7 +24,7 @@ void setup() { analogReference(INTERNAL); sensorValue = analogRead(BATTERY_SENSE_PIN); v = sensorValue * 0.004659498; - batteryPcnt = (v * 100) / 4.2; + batteryPcnt = (v-3.0 * 100) / 1.2; while (myAHT10.begin() != true) { Serial.println(F("AHT10 not connected or fail to load calibration coefficient")); //(F()) save string to flash & keeps dynamic memory free @@ -53,7 +53,7 @@ void loop() { send(msgMillis.set(cRun)); sensorValue = analogRead(BATTERY_SENSE_PIN); v = sensorValue * 0.004659498; - batteryPcnt = (v-3 * 100) / 1.2; + batteryPcnt = (v-3.0 * 100) / 1.2; sendBatteryLevel(batteryPcnt); send(msgVolts.set(v, 2)); //} diff --git a/MainDoorMyS/src/main.cpp b/MainDoorMyS/src/main.cpp index 781dc73..1c72553 100644 --- a/MainDoorMyS/src/main.cpp +++ b/MainDoorMyS/src/main.cpp @@ -18,8 +18,8 @@ #define TOP_LOCK A0 #define INT_LOCK A1 -#define DOWN_LOCK A2 -#define SMALL_LOCK A3 +#define DOWN_LOCK A3 +#define SMALL_LOCK A2 #define DOOR A4 #define TOP_LOCK_ID 0 @@ -58,47 +58,56 @@ void presentation() present(SMALL_LOCK_ID, S_LOCK, "Small"); present(DOOR_ID, S_LOCK, "Door"); present(CUSTOM_ID, S_CUSTOM); - sendData(msgDoor, digitalRead(DOOR)); - wait(100); - sendData(msgTop, digitalRead(TOP_LOCK)); - wait(100); - sendData(msgInt, digitalRead(INT_LOCK)); - wait(100); - sendData(msgDown, digitalRead(DOWN_LOCK)); - wait(100); - sendData(msgSmall, digitalRead(SMALL_LOCK)); } void setup() { - // put your setup code here, to run once: + bpDoor = !digitalRead(DOOR); + bpTop = !digitalRead(TOP_LOCK); + bpInt = !digitalRead(INT_LOCK); + bpSmall = !digitalRead(SMALL_LOCK); + bpDown = !digitalRead(DOWN_LOCK); + sendData(msgDoor, bpDoor); + wait(100); + sendData(msgTop, bpTop); + wait(100); + sendData(msgInt, bpInt); + wait(100); + sendData(msgDown, bpDown); + wait(100); + sendData(msgSmall, bpSmall); } void loop() { static uint32_t cRun = millis(); bool bTop, bInt, bDown, bSmall, bDoor; - bTop = digitalRead(TOP_LOCK); - bInt = digitalRead(INT_LOCK); - bDown = digitalRead(DOWN_LOCK); - bSmall = digitalRead(SMALL_LOCK); - bDoor = digitalRead(DOOR); + bTop = !digitalRead(TOP_LOCK); + bInt = !digitalRead(INT_LOCK); + bDown = !digitalRead(DOWN_LOCK); + bSmall = !digitalRead(SMALL_LOCK); + bDoor = !digitalRead(DOOR); if(bTop != bpTop){ bpTop = bTop; - sendData(msgTop, bDoor); + Serial.print(F("Top Lock-"));Serial.println(bTop); + sendData(msgTop, bTop); } if(bInt != bpInt){ bpInt = bInt; + Serial.print(F("Int Lock-"));Serial.println(bInt); sendData(msgInt, bInt); } if(bDown != bpDown){ bpDown = bDown; + Serial.print(F("Down Lock-"));Serial.println(bDown); sendData(msgDown, bDown); } if(bSmall != bpSmall){ bpSmall = bSmall; + Serial.print(F("Small Lock-"));Serial.println(bSmall); sendData(msgSmall, bSmall); } if(bDoor != bpDoor){ bpDoor = bDoor; + Serial.print(F("Door-"));Serial.println(bDoor); sendData(msgDoor, bDoor); } if((cRun + 29999) < millis()){ From 42b8d64c0dfad29b3ce0288ea943ade9c9c804dc Mon Sep 17 00:00:00 2001 From: lexa Date: Thu, 19 Nov 2020 21:23:01 +0300 Subject: [PATCH 2/3] Msg --- ExtSens/src/main.cpp | 2 +- VT_ESP8266/platformio.ini | 7 ++++--- VT_ESP8266/src/main.cpp | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ExtSens/src/main.cpp b/ExtSens/src/main.cpp index e771935..7d0af8a 100644 --- a/ExtSens/src/main.cpp +++ b/ExtSens/src/main.cpp @@ -53,7 +53,7 @@ void loop() { send(msgMillis.set(cRun)); sensorValue = analogRead(BATTERY_SENSE_PIN); v = sensorValue * 0.004659498; - batteryPcnt = (v-3.0 * 100) / 1.2; + batteryPcnt = ((v-3.0) * 100) / 1.2; sendBatteryLevel(batteryPcnt); send(msgVolts.set(v, 2)); //} diff --git a/VT_ESP8266/platformio.ini b/VT_ESP8266/platformio.ini index c1b8d2a..4f42a90 100644 --- a/VT_ESP8266/platformio.ini +++ b/VT_ESP8266/platformio.ini @@ -16,6 +16,7 @@ monitor_speed = 115200 upload_protocol = espota upload_port = 192.168.1.134 lib_deps = - # RECOMMENDED - # Accept new functionality in a backwards compatible manner and patches - closedcube/ClosedCube HDC1080 @ ^1.3.2 \ No newline at end of file + closedcube/ClosedCube HDC1080 @ ^1.3.2 + mathertel/RotaryEncoder @ ^1.3.0 + robtillaart/PCF8574 @ ^0.2.1 + robtillaart/I2C_EEPROM @ ^1.3.0 diff --git a/VT_ESP8266/src/main.cpp b/VT_ESP8266/src/main.cpp index 857bff6..91808b0 100644 --- a/VT_ESP8266/src/main.cpp +++ b/VT_ESP8266/src/main.cpp @@ -653,8 +653,13 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties ee.writeBlock(8, (uint8_t*)&wUstavki, sizeof(wCounter)); itoa(wUstavki.hDB, v, 10); mqttClient.publish("/home/vt/hdb", 1, false, v); + } else + if(strcmp(topic, "/home/vt/flood") == 0){ + pcf.write(LED_RED, !atoi(payload)); + c_flood = atoi(payload); } } + void onMqttPublish(uint16_t packetId) { //Serial1.println("Publish acknowledged."); //Serial1.print(" packetId: "); From 43d1cf5ff7c11e34d28892f2359492ca49fe643e Mon Sep 17 00:00:00 2001 From: lexa Date: Thu, 19 Nov 2020 21:29:40 +0300 Subject: [PATCH 3/3] VT --- VT_ESP8266/src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/VT_ESP8266/src/main.cpp b/VT_ESP8266/src/main.cpp index 91808b0..c5351f5 100644 --- a/VT_ESP8266/src/main.cpp +++ b/VT_ESP8266/src/main.cpp @@ -574,8 +574,10 @@ void onMqttConnect(bool sessionPresent) { mqttClient.subscribe("/home/vt/hdb_set", 1); sprintf(v, "%.2f", wCounter.QH); mqttClient.publish("/home/vt/qhot", 1, false, v); + mqttClient.publish("/home/vt/qhot_set", 1, false, v); sprintf(v, "%.2f", wCounter.QC); mqttClient.publish("/home/vt/qcold", 1, false, v); + mqttClient.publish("/home/vt/qcold_set", 1, false, v); itoa(wUstavki.hDB, v, 10); mqttClient.publish("/home/vt/hdb", 1, false, v); itoa(wUstavki.hSP, v, 10);