I thought i would share some findings and my solution on reading data from my energy meter using the HAN / P1 port.
I found a hardware kit “SmartyReader” from weigu which i purchased. It is based on Wemos D1 Mini Pro and can be extended in many variations.
The code weigu uses is for encrypted data, which is not active in Swedish meters.
The hardware from weigu is a bit different and rather minimalistic (which is good) so it is dependant on setting the flag inverted on the serial port instead of relying on a transistor to invert.
This setting was just made available in esphome version 2021.12.0 for ESP8266 devices.
Instructions
Download the code for esphome-p1reader follow the steps to set up the secrets as described in the instructions for p1reader then do the following adjustments in the yaml file for SmartyReader P1:
Set the board to Wemos D1 mini pro
board: d1_mini_pro
Adjust the UART section to invert the RX pin (removed TX pin config since it is not used).
In some cases for cold startup of the wemos card there seem to be too little power output to boot fully.
This could be showing up that the wemos is not booting nor connecting, or connecting to wifi but not parsing and passing the data received on the rx pin…
My power meter is the infamous Landis Gyr E360. But i do not experience any issues that it stop sending data after a period of time, as some users has reported.
I managed to override this by plugging in a usb powerbank to the micro usb port on the wemos and then hit the reset button. Once it is up and running i can unplug the powerbank and it continues to run without problems OTA and normal reboots works fine with the power provided from the meter.
I noticed in weigu:s code that he has a 2-second delay in the setup function of the arduino code.
I have added a delay in the on_boot section in to my esphome yaml file, but i have not been able to test if it makes any difference for this problem.
I followed your description above with the hardware from weigu and your code. I had the same problem with unreliable cold start but it works fine after a kick from a powerbank. No problems with OTA or reboots.
Many thanks for sharing your design and experiences.
This looks really tempting but a few hours of tinkering cannot get the code to work with a Kamstrup module that uses an RJ-45 for connector and only two pins. 1 comm and 2 gnd. Any tips would be appreciated.
When running this with rj12 connector we have a specific pin config with more wires.
When i read about rj45 implementation, it is using pin 1 for data and power and you probably need different hardware to act as a mbus slave and divide the voltage to esp signal levels. The risk is that you may have blown some components if you send mbus power levels to smartymeter.
Rj12 pin config, should not be confused to rj45 implementation.
pin 1, voltage +5v
pin 2, connected/jumped with pin 1 to activate data output
pin 5, comm (data out from meter)
pin6 (gnd) and pin3 (data gnd) jumped together to gnd
This is my understand as well, after some further digging. I came across the project Hardware · UtilitechAS/amsreader-firmware Wiki · GitHub (not esphome though) but that would still require some mbus bridge in my case since the RJ-45 data pin is pushing 24v.
It seems kamstrup customer interface can be replaced and is available with p1 rj12 port as well.
Maybe that could be an easier way if you wish to use p1 hardware…