projects
/
manu
/
arduino-maison.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c2318af
)
Use hardwareserial
author
Emmanuel Lacour
<elacour@easter-eggs.com>
Fri, 30 Apr 2021 21:27:01 +0000
(23:27 +0200)
committer
Emmanuel Lacour
<elacour@easter-eggs.com>
Fri, 30 Apr 2021 21:27:01 +0000
(23:27 +0200)
garage/garage.ino
patch
|
blob
|
history
diff --git
a/garage/garage.ino
b/garage/garage.ino
index
bb4ecaf
..
270d8d0
100644
(file)
--- a/
garage/garage.ino
+++ b/
garage/garage.ino
@@
-4,6
+4,7
@@
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
+#include <HardwareSerial.h>
#include "garage-config.h"
#include "garage-config.h"
@@
-25,11
+26,14
@@
WiFiUDP Udp;
#define DHTTYPE DHT22
DHT_Unified dht(DHTPIN, DHTTYPE);
#define DHTTYPE DHT22
DHT_Unified dht(DHTPIN, DHTTYPE);
+HardwareSerial TinfoSerial(1);
+
TInfo tinfo;
void setup() {
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);
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);
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 ) {
}
if ( WiFi.status() == WL_CONNECTED ) {
+ Serial.println("DEBUG");
sensors_event_t event;
dht.temperature().getEvent(&event);
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));
}
} 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();
}
Udp.endPacket();
}
-void NewTinfoFrame(ValueList * me)
+void NewTinfoFrame(ValueList * me
, uint8_t flags
)
{
{
- Serial.print("DEBUG NewFrame");
+ Serial.print
ln
("DEBUG NewFrame");
if ( me ) {
while (me->next) {
me = me->next;
if ( me ) {
while (me->next) {
me = me->next;
- Serial.print("DEBUG value");
+ Serial.print
ln
("DEBUG value");
if (me->value && strlen(me->value)) {
if (me->value && strlen(me->value)) {
- Serial.print("DEBUG name: "+String(me->name)+",value: "+String(me->value));
+ Serial.print
ln
("DEBUG name: "+String(me->name)+",value: "+String(me->value));
boolean isNumber = true;
uint8_t c;
char * p = 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 {
}
// this will remove leading zero on numbers
else {
- Serial.print("DEBUG influx, name: "+String(me->name)+",value: "+String(atol(me->value)));
+ Serial.print
ln
("DEBUG influx, name: "+String(me->name)+",value: "+String(atol(me->value)));
sendToInfluxDB("teleinfo,city="+city, String(me->name), String(atol(me->value)));
}
}
sendToInfluxDB("teleinfo,city="+city, String(me->name), String(atol(me->value)));
}
}