From 151e38dfaf868630582342e499aa5f003f4d7beb Mon Sep 17 00:00:00 2001 From: Emmanuel Lacour Date: Fri, 30 Apr 2021 23:27:01 +0200 Subject: [PATCH] Use hardwareserial --- garage/garage.ino | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/garage/garage.ino b/garage/garage.ino index bb4ecaf..270d8d0 100644 --- a/garage/garage.ino +++ b/garage/garage.ino @@ -4,6 +4,7 @@ #include #include #include +#include #include "garage-config.h" @@ -25,11 +26,14 @@ WiFiUDP Udp; #define DHTTYPE DHT22 DHT_Unified dht(DHTPIN, DHTTYPE); +HardwareSerial TinfoSerial(1); + TInfo tinfo; void setup() { - Serial.begin(9600); + Serial.begin(115200); + TinfoSerial.begin(9600,SERIAL_8N1, 22, 23); WiFi.mode(WIFI_STA); WiFi.begin(WIFI_SSID, WIFI_PASS); @@ -43,7 +47,9 @@ void setup() { dht.humidity().getSensor(&sensor); tinfo.init(TINFO_MODE_STANDARD); - tinfo.attachNewFrame(NewTinfoFrame); + // tinfo.attachNewFrame(NewTinfoFrame); + // tinfo.attachUpdatedFrame(NewTinfoFrame); + tinfo.attachData(NewTinfoFrame); } @@ -63,6 +69,7 @@ void loop() { } if ( WiFi.status() == WL_CONNECTED ) { + Serial.println("DEBUG"); sensors_event_t event; dht.temperature().getEvent(&event); @@ -77,8 +84,9 @@ void loop() { } else { sendToInfluxDB("humidity,city="+city+",location="+location, "value", String(event.relative_humidity)); } - if ( Serial.available() ) { - tinfo.process(Serial.read()); + if ( TinfoSerial.available() ) { + Serial.println("DEBUG: process tinfo"); + tinfo.process(TinfoSerial.read()); } } } @@ -91,15 +99,15 @@ void sendToInfluxDB(String measure, String key, String value) { Udp.endPacket(); } -void NewTinfoFrame(ValueList * me) +void NewTinfoFrame(ValueList * me, uint8_t flags) { - Serial.print("DEBUG NewFrame"); + Serial.println("DEBUG NewFrame"); if ( me ) { while (me->next) { me = me->next; - Serial.print("DEBUG value"); + Serial.println("DEBUG value"); if (me->value && strlen(me->value)) { - Serial.print("DEBUG name: "+String(me->name)+",value: "+String(me->value)); + Serial.println("DEBUG name: "+String(me->name)+",value: "+String(me->value)); boolean isNumber = true; uint8_t c; char * p = me->value; @@ -118,7 +126,7 @@ void NewTinfoFrame(ValueList * me) } // this will remove leading zero on numbers else { - Serial.print("DEBUG influx, name: "+String(me->name)+",value: "+String(atol(me->value))); + Serial.println("DEBUG influx, name: "+String(me->name)+",value: "+String(atol(me->value))); sendToInfluxDB("teleinfo,city="+city, String(me->name), String(atol(me->value))); } } -- 2.11.0