I connected an Adruino UNO to the P1 port of my landis & gyr e350 smart meter. Data is successfully extracted from the meter.
/XMX5LGBBFG1009232820
1-3:0.2.8(42)
0-0:1.0.0(161010004339S)
0-0:96.1.1(4530303330303033313630363237323135)
1-0:1.8.1(000084.040*kWh)
1-0:1.8.2(000000.000*kWh)
1-0:2.8.1(000000.000*kWh)
1-0:2.8.2(000000.000*kWh)
0-0:96.14.0(0001)
1-0:1.7.0(00.960*kW)
1-0:2.7.0(00.000*kW)
0-0:96.7.21(00003)
0-0:96.7.9(00000)
1-0:99.97.0(0)(0-0:96.7.19)
1-0:32.32.0(00000)
1-0:52.32.0(00000)
1-0:72.32.0(00000)
1-0:32.36.0(00000)
1-0:52.36.0(00000)
1-0:72.36.0(00000)
0-0:96.13.1()
0-0:96.13.0()
1-0:31.7.0(002*A)
1-0:51.7.0(000*A)
1-0:71.7.0(003*A)
1-0:21.7.0(00.252*kW)
1-0:41.7.0(00.000*kW)
1-0:61.7.0(00.708*kW)
1-0:22.7.0(00.000*kW)
1-0:42.7.0(00.000*kW)
1-0:62.7.0(00.000*kW)
0-1:24.1.0(003)
0-1:96.1.0(4730303331303033323836353937303135)
0-1:24.2.1(161010000000S)(00038.385*m3)
!00F8
I made a quick test setup to forward the received P1 message to an Ethernet client if it connects to the Adruino. When I use a browser to connect to the Adruino it shows me the above message. The next step is to get this message in Domoticz. When I add "P1 Smart Meter with LAN interface" it connects to the Adruino but it will show the next error in the log "p1 hardware (12) thread seems to have ended unexpectedly".
Code: Select all
#include <Ethernet.h>
// assign a MAC address for the Ethernet controller.
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
// assign an IP address for the controller:
IPAddress ip(192, 168, 1, 20);
EthernetServer server(80);
char inputString[900]; // a string to hold incoming data
int x = 0;
boolean stringComplete = false; // whether the string is complete
boolean lastline = false;
void setup() {
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
// initialize serial:
Serial.begin(115200);
// give the sensor and Ethernet shield time to set up:
delay(1000);
}
void loop() {
// listen for incoming Ethernet connections:
listenForEthernetClients();
}
void listenForEthernetClients() {
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
client.print(inputString);
Serial.println(inputString);
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
} else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1000);
// close the connection:
client.stop();
}
}
void serialEvent() {
while (Serial.available()) {
// get the new byte
char inChar = (char)Serial.read();
// add it to the inputString:
inputString[x]= inChar;
x += 1;
//When ! is received continue until end of line and start over filling the var
if (inChar == '!') {
lastline = true;
}
if (inChar == '\n' && lastline == true){
lastline = false;
x = 0;
}
}
}
So my question is. Is the Domoticz P1 LAN device expecting the same message structure as the Serial version? Or is forwarding the P1 message from serial to LAN not enough?