#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
+#include <HardwareSerial.h>
#include "garage-config.h"
#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);
dht.humidity().getSensor(&sensor);
tinfo.init(TINFO_MODE_STANDARD);
- tinfo.attachNewFrame(NewTinfoFrame);
+ // tinfo.attachNewFrame(NewTinfoFrame);
+ // tinfo.attachUpdatedFrame(NewTinfoFrame);
+ tinfo.attachData(NewTinfoFrame);
}
}
if ( WiFi.status() == WL_CONNECTED ) {
+ Serial.println("DEBUG");
sensors_event_t event;
dht.temperature().getEvent(&event);
} 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());
}
}
}
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;
}
// 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)));
}
}