daniel-jong / esp8266_p1meter Goto Github PK
View Code? Open in Web Editor NEWThis project forked from fliphess/esp8266_p1meter
DSMR5 P1 meter to mqtt using esp8266
License: GNU General Public License v3.0
This project forked from fliphess/esp8266_p1meter
DSMR5 P1 meter to mqtt using esp8266
License: GNU General Public License v3.0
I found some other sources that reading from P1needs hardware inverter. For example:
http://domoticx.com/p1-poort-slimme-meter-uitlezen-hardware
https://www.zuidwijk.com/product/slimmelezer-plus/
I'm wondering how this wiring does not need it?
Hi Daniel,
My nodemcu suddenly won't connect to the wifi I specified anymore. I tried 2 other SSIDs with no success. Does anyone have any experience with this issue?
I also tried removing the wifi credentials and completely reapplying them with no luck..
It has been working succesfully for the last 3 months...
Hi!
First of all, thanks for a great job!
I got an Landis+Gyr E360 installed last week and I am trying to read out information from the P1 port.
I have an Wemos D1 mini ver 1, connected to a R11 cable according to your pictures.
I get an error compiling the code "'TX' was not declared in this scope".
If I change '#define SERIAL_TX TX' to '#define SERIAL_TX D0' in settings.h I can complie the code and upload. But i do not get any response from ther E360 meter. The only action I see is that I get a message over MQTT saying "p1 meter alive: p1meter". But thats it.
The serial monitor does not give anything out of the ordinary.
It confirms that it inverts UART0 RX, connects to WiFi and MQTT.
I am using Arduino IDE 1.8.13 and have downloaded the latest PubSubClient and WifiManager.
Help to resolve this is gladly appriciated.
Thanks,
Gustav
Hi, i have been struggling to get this to work.
When i am having a connection with the meter, i am getting an empty telegram back.
the size of the telegram i am recieving is 1050 long as defined in the settings file.
I have an 'landis gyr e350 zmf110cctfs2' and according the manual it seems to be using SMR5.0
https://www.liander.nl/sites/default/files/meters/Liander-LandisGyr-ELEK-ZMF110CCtFs2_GPRS_v1_1.pdf page 12
i noticed that it did not find any serial connection when wiring it like indicated, in the instructions, however, when i use the wiring schema from http://gejanssen.com/howto/Slimme-meter-uitlezen/ i do get a serial connection with the meter.
i am debugging using MQTT messages and noticed the empty telegram messages by adding the mqtt messages in the function read_p1_hardwareserial.
void read_p1_hardwareserial()
{
// mqtt_client.publish("sensors/power/p1meter/debug_status", "function p1 harwareserial");
if (Serial.available())
{
// mqtt_client.publish("sensors/power/p1meter/debug_status", "serial availible");
memset(telegram, 0, sizeof(telegram));
char output[10];
mqtt_client.publish("sensors/power/p1meter/debug_status", ltoa(sizeof(telegram), output, sizeof(output)));
mqtt_client.publish("sensors/power/p1meter/debug_status", telegram);
while (Serial.available())
{
ESP.wdtDisable();
int len = Serial.readBytesUntil('\n', telegram, P1_MAXLINELENGTH);
ESP.wdtEnable(1);
//mqtt_client.publish("sensors/power/p1meter/debug_status", ltoa(len, output, sizeof(output)));
processLine(len);
}
}
am i missing something?
Thanks
Hi @daniel-jong and @fliphness,
Just wanted to thank you for the much simpler wiring setup and the hardware serial trick 👍🏼
Initially I was using HomeAssistent directly connected to the p1 port and I didn't want to mess to much with this system. So instead of publishing on MQTT (which is nice setup!) I've made a very simple serial-to-tcp server on the esp8266.
The code is here: https://github.com/DavyLandman/p1-esp8266/blob/main/src/main.cpp and roughly allows you to point the HomeAssistent to the IP and port 23 of the esp8266, and home assistent will take care of parsing the output of the P1 port.
Anyway, thanks for the cool work, just want to drop this alternative idea here.
Regards,
Davy
Hi,
im running in the issue of TX not being defined with a Nodemcu,
i cant seem to find the problem in the code?
Im using a nodemcu v3
In file included from esp8266_p1meter-master\esp8266_p1meter\esp8266_p1meter.ino:14:0:
esp8266_p1meter-master\esp8266_p1meter\esp8266_p1meter.ino: In function 'void setup()':
settings.h:14:19: error: 'TX' was not declared in this scope
#define SERIAL_TX TX
^
esp8266_p1meter-master\esp8266_p1meter\esp8266_p1meter.ino:564:54: note: in expansion of macro 'SERIAL_TX'
Serial.begin(BAUD_RATE, SERIAL_8N1, SERIAL_FULL, SERIAL_TX TX, false);
Hi, Daniel,
I also tried it on Iskra AM550, but I only got some garbage data via serial port (looks like "⸮�⸮� ⸮� ⸮� ⸮� ⸮�⸮�⸮� ⸮� ⸮� ⸮�⸮�⸮� ⸮� ⸮�⸮� ⸮� ⸮� ⸮�⸮�⸮� ⸮� ⸮� ⸮�⸮�").
In general it's working (all status messages are OK including MQTT status report), it's seems just unable to interpret the data that it receives.
I've read that you had troubles running it with AM550 too - did you come to any useful solution?
Addition - serial port log:
Swapping UART0 RX to inverted Serial port is ready to recieve. read_eeprom()read_eeprom()read_eeprom()read_eeprom()read_eeprom()*WM: [3] allocating params bytes: 20 *WM: [2] Added Parameter: host *WM: [2] Added Parameter: port *WM: [2] Added Parameter: user *WM: [2] Added Parameter: pass *WM: [1] AutoConnect *WM: [2] Connecting as wifi client... *WM: [3] STA static IP: *WM: [2] setSTAConfig static ip not set, skipping *WM: [1] Connecting to SAVED AP: MYNETWORKNAME *WM: [3] Using Password: MYPASSWORD *WM: [3] WiFi station enable *WM: [3] enableSTA PERSISTENT ON *WM: [1] connectTimeout not set, ESP waitForConnectResult... *WM: [2] Connection result: WL_CONNECTED *WM: [3] lastconxresult: WL_CONNECTED *WM: [1] AutoConnect: SUCCESS *WM: [1] STA IP Address: 192.168.1.98 Connected to WIFI... Arduino OTA activated. Arduino OTA finished Starting MDNS responder service MQTT connecting to: 192.168.1.100:1883 *WM: [3] freeing allocated params! *WM: [3] unloading MQTT connection attempt 1 / 10 ... MQTT connected! MQTT root topic: home/power/p1meter
Hi,
I found your fantastic code and try to understand it.
I want to create a P1 reader and forward it to another device with a P1 interface like an EV charger.
I want to change the messages before sending so try to figure out how the CRC works.
I see you are inverting the serial read interface ? Why are you doing this ?
If I would forward the messages to the TX pin. Would I also need to invert it ? I don't understand this part.
I expect if I forward it on the TX port I will have to avoid println's .
Just wondering: How do you reconfigure the MQTT/ Wifi settings after the initial configuration in case you want to switch over to another MQTT Broker or Wifi access point?
I tried connecting to the DHCP-assigned IP address but the ESP doesn't respond on port 80.
It does reply on a ping request.
(I'm using a D1 mini)
Hi,
For the last 6 weeks i'm running your solution successfully on my old meter (XS21). Today Enexis has migrated my connection from 1 to 3 phases. Because of that i also received a new meter, the Sagemcom T211. Since this swap, i'm unable to receive information. Is the Sagemcom supported? The console shows the following information:
Thank you in advance.
Best regards,
Remon Willems
Hi all,
After installing and succesfull hass/status/p1 meter alive it keeps all quiet....no measurements are sent to mqtt.
Anybody knows where the problem might be? Is there a way to see any logging?
Many thanks for your help!!
Best regards,
Geert-Jan
Is there a way to have this project as an input for the Home Assistant Energy Dashboard? The DSM integration can be used, but it is some sort of Serial over Wifi, and I can't seem to find if the project supports that
mqtt is not a standard source for the Energy Dashboard as far as I can find.
Hi , just wan't to start to say that this code works great for me with an esp8266. Big thanks to you. This is not really an issue but I want to know if its possible to get some values updated more frequently ? Like the "sensors/power/p1meter/actual_consumption". All my values updates in an interwall of 70seconds . The han port sends data every 10 sec if I have understood it right? . Im not so good with arduino code so maybe you know if its possible to get some values to update more frequently. Big thanks again
Is there a guide on how to apply this to home assistant?
I followed your guide and connected my ESP8266 to my meter, setup mqtt on my home assistant and I was hoping there would be a guide somewhere on how to proceed from here (i.e. how to get all the data on my dash)
Hi I have a unifi setup at home with 5 APs, when I reboot them one by one the wemos disconnects from the wifi and never reconnects to the same or another AP. Has this todo with config or is this not implemented?
The MCU won't connect to MQTT. I can't figure out how to access or change the settings.
After a lot of searching, I figured out the option "erase flash: all flash contents" erases all settings, so I can start from a blank config again.
I enabled debugging for as many things as possible, and it doesn't show any relevant data for why MQTT connections fail. Home Assistant's mosquitto log also fails to show anything relevant.
On the serial output I get:
23:14:43.629 -> MQTT connecting to: Homeassistant.local:1883
23:14:43.629 -> MQTT connection attempt 1 / 10 ...
23:14:43.768 -> :ref 1
23:14:46.791 -> :urn 47
23:14:46.791 -> :urd 2, 47, 0
23:14:46.791 -> :urd 1, 47, 2
23:14:46.791 -> :urd 1, 47, 3
23:14:46.791 -> :urd 2, 47, 4
23:14:46.791 -> :urd 2, 47, 6
23:14:46.791 -> :urd 2, 47, 8
23:14:46.791 -> :urd 2, 47, 10
23:14:48.985 -> :ctmo
23:14:48.985 -> :abort
23:14:48.985 -> :ur 1
23:14:48.985 -> :dsrcv 0
23:14:48.985 -> :del
23:14:48.985 -> MQTT Connection failed: rc=-2
Hi, I just updated my code at https://github.com/jellevervloessem/esp8266_p1meter
I have compiled and uploaded the script to my Nodemcu and i see the p1meter announcing itself in MQTT (p1 meter alive: p1meter) but i don't see any topics.
Did i do something wrong?
Used wrong board library maybe? Currently i'm on version 2.7.4 also tried 3.0.2.
Hi Daniel
Very nice project and very well coded. I have a concern wrt configuring process of the board. First time works great.
According the code it re-enters AP mode when connect to the WiFi fails. Two real life issues here:
-When WiFi is down, the board ends up in AP mode. Won't reconnect once the WiFi is back.
-No way to fix or adjust MQTT settings when the WiFi works.
I think adding the DoubleResetDetector library to enter AP config mode when pressing reset twice is better. That's what I'm going to try. Interested in the diff?
Best regards and thx for the great work
Eric
Hello,
I've used the sketch for more than a year without problems. Now, since the night from august 31 to september 1st at midnight I get the CRC invalid error. I tried with new hardware but still the same problem.
/FLU5\253769484_A
0-0:96.1.4(50217)
0-0:96.1.1(3153414733313035313637313630)
0-0:1.0.0(230903131547S)
1-0:1.8.1(005454.121*kWh)
1-0:1.8.2(006581.993*kWh)
1-0:2.8.1(000000.000*kWh)
1-0:2.8.2(000000.003*kWh)
0-0:96.14.0(0002)
1-0:1.4.0(00.217*kW)
1-0:1.6.0(230901161500S)(05.604*kW)
0-0:98.1.0(9)(1-0:1.6.0)(1-0:1.6.0)(230101000000W)(221217173000W)(06.422kW)(230201000000W)(230103060000W)(04.788kW)(230301000000W)(230215174500W)(04.517kW)(230401000000S)(230313180000W)(03.939kW)(230501000000S)(230421173000S)(04.295kW)(230601000000S)(230528113000S)(04.692kW)(230701000000S)(230625111500S)(06.655kW)(230801000000S)(230709131500S)(05.514kW)(230901000000S)(230820170000S)(04.510*kW)
k0.000*kW)
1-0:21.7.0(00.710*kW)
1-0:41.7.0(00.000*kW)
1-0:61.7.0(03.370*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)
1-0:32.7.0(244.1*V)
1-0:52.7.0(000.0*V)
1-0:72.7.0(240.4*V)
1-0:31.7.0(003.40*A)
1-0:51.7.0(015.88*A)
1-0:71.7.0(014.03*A)
0-0:96.3.10(1)
0-0:17.0.0(999.9*kW)
1-0:31.4.0(999*A)
0-0:96.13.0()
!3E82
CRC Invalid!
I cannot figure out how to access the MQTT parameters after the initial setup.
I did flash the D1 Mini again, but it does not suppress wifi and matt initial setting.
What should I do?
According to ESMR 5.0.2 final P1: Number of voltage swells in phase L1 : 1-0:32.36.0.255
You are currently using that as total voltage swells
I get all measurements from my electricity , but nothing at all from gas usage. On my electricity company's app i can see my daily usage from electricity and gas. So why can't i see my gas usage? Is this a bug or something else?
Hi Daniel, first of all thanks for your good work. I am trying to write the lines to a file because i have no wifi at the location of my meter. This is the only way i can test.
In the hardware i connected RTS and the resistor to pin D5 of the nodeMCU. Before reading i make this pin high.
I expected that this would work but i have a strange behaviour. Using your method i always get about the second half of the telegram. No matter what i tried, with delays and a "wait_until_serial_available" method, it is always this. It seems that the meter starts the telegram with that.
So i adapted the software such that at bootup the meter is polled and the resulting telegram is saved in spiffs.
This way i have a testTelegram that i can use to test the other functions.
And this works very well.
please look here
Hi @daniel-jong
great work!
I'm sharing your P1 meter project on my own home automation project repository:
https://github.com/aeonSolutions/PCB-Prototyping-Catalogue/blob/main/Home-Automation/README.md
I found several "SoftwareSerial" libs in platformIO, but all give me a error. Can you tell me witc lib i have to use and declare in platformio.ini
Tx
Srr for poor english
Hi Daniel,
are you planning to implement a webserver to make sensor values visible? It would be great and also very useful if any change of credentials is needed. It would provide a very useful user interface using e.g. a smartphone.
Hi,
To start i'm pretty new with this so expect rookie mistakes.
I had everything working just fine, however after 2 weeks my esp now stops sending data every couple of hours and sometimes it restarts automatically, but nog always.
Below is the log, before, during and after it stopped working.
Thanks in advance for advice
Dear
First of all, thank you for this solution. I have it running since november last year and it works like a charm. At least until a month or so, then the solution stopt working.
I've been trying to understand what is going on, but I'm a bit lost. What should be the content of one telegram? Should this be one line or a complete set of lines?
When check the content of a telegram, I do get mixed results. Sometimes it is just one line and sometimes are some lines or a lot of lines. See here below the set of data I get per telegram
Example 1
0-0:96.1.4(50217)
Example 2
0-0:96.1.1(3153414733313030313737323435)
0-0:1.0.0(230923191021S)
1-0:1.8.1(004556.575*kWh)
1-0:1.8.2(005324.382*kWh)
1-0:2.8.1(000564.096*kWh)
1-0:2.8.2(000195.911*kWh)
0-0:96.14.0(0002)
1-0:1.4.0(00.017*kW)
Example 3
1-0:62.7.0(00.254*kW)
1-0:32.7.0(239.1*V)
1-0:52.7.0(238.7*V)
1-0:72.7.0(239.1*V)
1-0:31.7.0(001.50*A)
1-0:51.7.0(001.44*A)
1-0:71.7.0(001.60*A)
0-0:96.3.10(1)
0-0:17.0.0(999.9*kW)
1-0:31.4.0(999*A)
0-0:96.13.0()
0-1:24.1.0(003)
0-1:96.1.1(37464C4F32313230303131323133)
0-1:24.4.0(1)
0-1:24.2.3(230923191005S)(02273.179*m3)
!78DE
/FLU5\253769484_A
I can't get my head around it.
Looking at the code I would expect one line since the read from serial is until \n
int len = Serial.readBytesUntil('\n', telegram, P1_MAXLINELENGTH);
But it seems like it doesn't recognizes the \n at the end of the lines.
Any help appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.