X-Git-Url: http://git.home-dn.net/?p=manu%2Farduino-maison.git;a=blobdiff_plain;f=garage%2Fgarage.ino;fp=garage%2Fgarage.ino;h=270d8d04b71be30ce52a8e9f19d6ea1a349d59d0;hp=bb4ecaf82f93f9996a8b2b6d67d7d22c9821589e;hb=e0083a4185a9ddf20bafc5f6c06d85a98cf6f002;hpb=48a1a5c1e0813df169630676e3681f004f3979a9 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))); } }