Coder Social home page Coder Social logo

esphome-p1reader's Introduction

esphome-p1reader

ESPHome custom component for reading P1 data from electricity meters. Designed for Swedish meters that implements the specification defined in the Swedish Energy Industry Recommendation For Customer Interfaces version 1.3 and above.

ESPHome version

The current version in main is tested with ESPHome version 2022.12.1. Make sure your ESPHome version is up to date if you experience compile problems.

Verified meter hardware / supplier

Note: There's a bug in older E360 firmware, causing it to stop sending out data after a while. Check this comment for more info: #4 (comment)

Warning: Do not confuse KAIFA MA304H4E with MA304H4D as the latter uses M-Bus instead of P1. Apart from being incompatible protocols, M-Bus pin 1 exerts 27V instead of 5V and will fry your P1 equipment.

Hardware

I have used an ESP-12 based NodeMCU for my circuit, another alternative is the cheaper Wemos D1 mini but most ESP-based controllers would probably work. The P1 port on the meter provides 5V up to 250mA which makes it possible to power the circuit directly from the P1 port.

Parts

  • 1 NodeMCU, Wemos D1 mini or equivalent ESP-12 / ESP-32 microcontroller
  • 1 BC547 / 2N3904 NPN transistor
  • 1 4.7kOhm Resistor
  • 1 10kOhm Resistor
  • 1 RJ12 6P6C port
  • 1 RJ12 to RJ12 cable (6 wires)

Wiring

The circuit is very simple, basically the 5V TX output on the P1 connector is converted to 3.3V and inverted by the transistor and connected to the UART0 RX pin on the microcontroller. The RTS (request to send) pin is pulled high so that data is sent continously and GND and 5V is taken from the P1 connector to drive the microcontroller.

Wiring NodeMCU ESP-12

Wiring Diagram

Wiring Wemos D1 mini

image

Wiring barebone ESP-12 with added voltage regulators and capacitors.

The schematics show a 2SC1815 NPN transistor being used (because that's what I had laying around), will work just fine with either one of the transistors listed under the parts section. Wiring Diagram

PCB and enclosures

Naesstrom

Naesstrom has made a nice PCB layout for the P1 reader using a Wemos D1 mini as the controller along with a 3D printable enclosure.

Check out the PCB here: https://oshwlab.com/Naesstrom/esphome-p1reader and the enclosure here: https://www.thingiverse.com/thing:4961372.

EHjortberg

EHjortberg has made an equally nice PCB layout based on an ESP07 module along with a 3D printable enclosure. Check it out here: https://github.com/ehjortberg/kicad-p1-port-thingie.

Alternate hardware

Since most of the actual specification is, for all practical purposes, identical across Europe/EU (with the exception of Norway) we can use many kinds of different hardware that supports ESPHome and can interface with the P1 port. Both other custom made solutions and some commercial options. The key to using them is to combine them with the code here that handles the Swedish selection of data values sent from the smart meter. The DSMR module in ESPHome follows the Dutch specification for values to be used.

(Finland and Denmark seems to have the exact same configuration as Sweden)

Running on ESP32

The ESP32 requires an external power supply since it cannot be powered by the low amperage available from the P1-port itself. Using the hardware UART on GPIO3 is required.

Use a pull-up resistor (1k) from RXD to 3V3.

uart:
    id: uart_bus
    rx_pin:
      number: GPIO3
      inverted: true
    baud_rate: 115200

image

Image credit: https://github.com/Josverl/micropython-p1meter

Running on SmartyReader P1

Weigu has designed SmartyReader P1 that also can be running with this code and configuration with a few small adaptions.

This hardware runs on ESP8266 Wemos D1 mini pro but with less components.

Basic steps to run this code on SmartyReader P1:

  1. Set the board to Wemos D1 mini pro
board: d1_mini_pro
  1. Adjust the UART section to invert the RX pin (removed TX pin config since it is not used).
uart:
    id: uart_bus
    rx_pin:
      number: 3
      inverted: true
    baud_rate: 115200

Note that the inverted flag is only supported in ESPHome beta as of now. Monitor this PR to follow if it is released to general version. inverted flag feature has been added in ESPHome 2021.12.0 released on 11th December 2021.

Running on Slimmelezer(+)

Marcel Zuidwijk has designed Slimmelezer+ that also can be used with this code and combined with the standard configuration for the Slimmelezer+. (Also the non + version works fine, the software is compatible).

It is designed as a custom board with a P1 interface that is software equivalent with the Wemos D1 Mini.

Basic steps to run this code on the Slimmelezer+:

  1. Set the board to Wemos D1 mini
board: d1_mini
  1. Adjust the UART section to set the rx_pin used by the Slimmelezer
uart:
    id: uart_bus
    baud_rate: 115200
    rx_pin: D7
    rx_buffer_size: 1700    

Sample configuration, uses !secret for all site specific configuration, see below.

Installation

Clone the repository and create a companion secrets.yaml file with the following fields:

If your electricity supplier is using Aidon 6442SE or Aidon 653X, you might also need to change the instantiation of the meter_sensor. As these meters are sometimes using the HDLC-protocol instead of ASCII. Open p1reader.yaml

// Change
auto meter_sensor = new P1Reader(id(uart_bus));
// To
auto meter_sensor = new P1ReaderHDLC(id(uart_bus));

Create a companion secrets.yaml file with the following fields:

wifi_ssid: <your wifi SSID>
wifi_password: <your wifi password>
fallback_password: <fallback AP password>
encryption_key: the encryption key shared with HA
ota_password: <The OTA password>

Check the Native API Component chapter of the ESPHome documentation for more info on the encryption key, this page also let you easily generate an encryption key.

Make sure to place the secrets.yaml file in the root path of the cloned project. The fallback_password and ota_password fields can be set to any password before doing the initial upload of the firmware.

Prepare the microcontroller with ESPHome before you connect it to the circuit:

  • Install the esphome command line tool
  • Plug in the microcontroller to your USB port and run esphome run p1reader.yaml to flash the firmware
  • Remove the USB connection and connect the microcontroller to the rest of the circuit and plug it into the P1 port.
  • If everything works, your Home Assistant will now auto detect your new ESPHome integration.

You can check the logs by issuing esphome p1reader.yaml logs (or use the super awesome ESPHome dashboard available as a Hass.io add-on or standalone). The logs should output data similar to this every 10 seconds when using DEBUG loglevel:

[18:40:01][D][data:264]: /ELL5\253833635_A
[18:40:01][D][data:264]:
[18:40:01][D][data:264]: 0-0:1.0.0(210217184019W)
[18:40:01][D][data:264]: 1-0:1.8.0(00006678.394*kWh)
[18:40:01][D][data:264]: 1-0:2.8.0(00000000.000*kWh)
[18:40:01][D][data:264]: 1-0:3.8.0(00000021.988*kvarh)
[18:40:01][D][data:264]: 1-0:4.8.0(00001020.971*kvarh)
[18:40:01][D][data:264]: 1-0:1.7.0(0001.727*kW)
[18:40:01][D][data:264]: 1-0:2.7.0(0000.000*kW)
[18:40:01][D][data:264]: 1-0:3.7.0(0000.000*kvar)
[18:40:01][D][data:264]: 1-0:4.7.0(0000.309*kvar)
[18:40:01][D][data:264]: 1-0:21.7.0(0001.023*kW)
[18:40:01][D][data:264]: 1-0:41.7.0(0000.350*kW)
[18:40:01][D][data:264]: 1-0:61.7.0(0000.353*kW)
[18:40:01][D][data:264]: 1-0:22.7.0(0000.000*kW)
[18:40:01][D][data:264]: 1-0:42.7.0(0000.000*kW)
[18:40:01][D][data:264]: 1-0:62.7.0(0000.000*kW)
[18:40:01][D][data:264]: 1-0:23.7.0(0000.000*kvar)
[18:40:01][D][data:264]: 1-0:43.7.0(0000.000*kvar)
[18:40:01][D][data:264]: 1-0:63.7.0(0000.000*kvar)
[18:40:01][D][data:264]: 1-0:24.7.0(0000.009*kvar)
[18:40:01][D][data:264]: 1-0:44.7.0(0000.161*kvar)
[18:40:01][D][data:264]: 1-0:64.7.0(0000.138*kvar)
[18:40:01][D][data:264]: 1-0:32.7.0(240.3*V)
[18:40:01][D][data:264]: 1-0:52.7.0(240.1*V)
[18:40:01][D][data:264]: 1-0:72.7.0(241.3*V)
[18:40:01][D][data:264]: 1-0:31.7.0(004.2*A)
[18:40:01][D][data:264]: 1-0:51.7.0(001.6*A)
[18:40:01][D][data:264]: 1-0:71.7.0(001.7*A)
[18:40:01][D][data:264]: !7945
[18:40:01][I][crc:275]: Telegram read. CRC: 7945 = 7945. PASS = YES

The last row contains the CRC check. If you constantly get invalid CRC there might be something wrong with the serial communication.

Technical documentation

esphome-p1reader's People

Contributors

anteus avatar bortek avatar brunas avatar cadwal avatar conorsham avatar danieloldberg avatar danielsvane avatar endor-force avatar fredrikbaberg avatar ghostnr1 avatar jappish84 avatar kalle309 avatar maccan-tech avatar megamannen avatar norrland avatar parski avatar pp-svanstrom avatar psvanstrom avatar pypb avatar strixx76 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esphome-p1reader's Issues

SlimmeLezer+ with HDLC stops working

Hi!

Recently purchased a SlimmeLezer+ v1.2 for my Aidon 6534 electricity meter.
Using the sample config for the slimmelezer works. But when changing the meter_sensor from P1Reader to P1ReaderHDLC it stops working. I cant open the web portal, upload ota or connect using Home Assistant. Re-flashing using ESPHome flasher without HDLC makes everything work again.

Compiled using latest ESPHome v2023.6.3, I've also tried to pin the container to the lastest working according to the readme (2022.12.1) but still the same issue.

When compiling with HDLC enabled i also get this warning:

In file included from src/main.cpp:65:
src/p1reader.h: In member function 'bool P1ReaderHDLC::readHDLCStruct(ParsedMessage*)':
src/p1reader.h:364:21: warning: '.' directive writing 1 byte into a region of size between 0 and 4 [-Wformat-overflow=]
  364 |       sprintf(obis, "%d.%d.%d", buffer[2], buffer[3], buffer[4]);
      |                     ^~~~~~~~~~
src/p1reader.h:364:21: note: directive argument in the range [0, 255]
src/p1reader.h:364:14: note: 'sprintf' output between 6 and 12 bytes into a destination of size 7
  364 |       sprintf(obis, "%d.%d.%d", buffer[2], buffer[3], buffer[4]);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

but it still compiles successfully. But after uploaded the sensor stops responding. My simple guess from some googling is that it might be causing some buffer overflow? Changing line 346 from char obis[8]; to char obis[12]; does remove the warning but the device still does not respond... so i might just caused other issues, or i am looking in the wrong spot.

Strange readings HSP Meter HAN port

Hi i dont know if its an issuie or just use this in wrong meter.

Get this strange error and CRC check PASS after.
Component 204 and 205 error?
The meter is new Smart meter with HAN port,
Not an usual home meter its an industrial HSP meter thats why voltage and amp is strange i think.
Think i incomming voltage is around 60,000volt and meter before transformer.

Can I get better resolution of ampere readings? And what is component 204 and 205 meter spitts out?

[20:52:08][D][sensor:093]: 'Cumulative Active Import': Sending state 678375.37500 kWh with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Cumulative Active Export': Sending state 74831.57031 kWh with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Cumulative Reactive Import': Sending state 357108.71875 kvarh with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Cumulative Reactive Export': Sending state 150.29800 kvarh with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Momentary Active Import': Sending state 17.21300 kW with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Momentary Active Export': Sending state 0.00000 kW with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Momentary Reactive Import': Sending state 4.54700 kvar with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Momentary Reactive Export': Sending state 0.00000 kvar with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Momentary Active Import Phase 1': Sending state 5.31800 kW with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Momentary Active Export Phase 1': Sending state 0.00000 kW with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Momentary Active Import Phase 2': Sending state 6.40700 kW with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Momentary Active Export Phase 2': Sending state 0.00000 kW with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Momentary Active Import Phase 3': Sending state 6.07600 kW with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Momentary Active Export Phase 3': Sending state 0.00000 kW with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Momentary Reactive Import Phase 1': Sending state 1.35400 kvar with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Momentary Reactive Export Phase 1': Sending state 0.00000 kvar with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Momentary Reactive Import Phase 2': Sending state 1.26500 kvar with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Momentary Reactive Export Phase 2': Sending state 0.00000 kvar with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Momentary Reactive Import Phase 3': Sending state 1.96400 kvar with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Momentary Reactive Export Phase 3': Sending state 0.00000 kvar with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Voltage Phase 1': Sending state 61.10000 V with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Voltage Phase 2': Sending state 61.30000 V with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Voltage Phase 3': Sending state 61.20000 V with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Current Phase 1': Sending state 0.00000 A with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Current Phase 2': Sending state 0.10000 A with 3 decimals of accuracy
[20:52:08][D][sensor:093]: 'Current Phase 3': Sending state 0.10000 A with 3 decimals of accuracy
[20:52:08][W][component:204]: Component took a long time for an operation (0.10 s).
[20:52:08][W][component:205]: Components should block for at most 20-30ms.
[20:52:08][I][crc:281]: Telegram read. CRC: ED4F = ED4F. PASS = YES

Move code from codesys to hassio?

Hi.
I wrote a code in codesys that I want to transfer to hassio. Can someone helpme?
It's for decrease current by disconnect some loads.
This code runs once/sek. Example: 26.5Amp, 3600/(10^2.25)= around 13sek before action
Example: 17.5Amp, 3600/(1^2.25)= 3600sek before action

IF strom1.rPayload >= 16.5 THEN
rMem1:=ABS(EXPT((strom1.rPayload - 16.5),2.25));
rMem2:=rMem1 + rMem2;
ELSE
rMem1:=0;
rMem2:=0;
END_IF
bMinne:= (rMem2>3600 OR bMinne) AND NOT memTon.Q;
memTon(IN:= bMinne, PT:=T#60S , Q=> , ET=> );
bVakt:=bMinne;

CRC Pass=no after a while

Hi!
Recently built the P1 reader using the PCB from Naesstrom and using this repo and it works fine for a while but then I start getting CRC PASS = NO and then garbled data and after that nothing.
I have S34U18 (Sanxing SX631) / Vattenfall with P1 active and using D1 mini MCU. Any suggestions?

Logs:
`[11:52:22][I][crc:281]: Telegram read. CRC: F122 = F122. PASS = YES
[11:52:22][D][sensor:093]: 'Cumulative Active Import': Sending state 1626.19897 kWh with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Cumulative Active Export': Sending state 0.00000 kWh with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Cumulative Reactive Import': Sending state 2.60200 kvarh with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Cumulative Reactive Export': Sending state 1235.21204 kvarh with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Momentary Active Import': Sending state 0.76800 kW with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Momentary Active Export': Sending state 0.00000 kW with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Momentary Reactive Import': Sending state 0.00000 kvar with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Momentary Reactive Export': Sending state 0.49600 kvar with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Momentary Active Import Phase 1': Sending state 0.35000 kW with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Momentary Active Export Phase 1': Sending state 0.00000 kW with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Momentary Active Import Phase 2': Sending state 0.26900 kW with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Momentary Active Export Phase 2': Sending state 0.00000 kW with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Momentary Active Import Phase 3': Sending state 0.14800 kW with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Momentary Active Export Phase 3': Sending state 0.00000 kW with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Momentary Reactive Import Phase 1': Sending state 0.00000 kvar with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Momentary Reactive Export Phase 1': Sending state 0.11900 kvar with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Momentary Reactive Import Phase 2': Sending state 0.00000 kvar with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Momentary Reactive Export Phase 2': Sending state 0.14100 kvar with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Momentary Reactive Import Phase 3': Sending state 0.00000 kvar with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Momentary Reactive Export Phase 3': Sending state 0.23400 kvar with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Voltage Phase 1': Sending state 235.30000 V with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Voltage Phase 2': Sending state 236.39999 V with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Voltage Phase 3': Sending state 235.70000 V with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Current Phase 1': Sending state 1.60000 A with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Current Phase 2': Sending state 1.30000 A with 3 decimals of accuracy
[11:52:22][D][sensor:093]: 'Current Phase 3': Sending state 1.20000 A with 3 decimals of accuracy
[11:52:22][W][component:204]: Component took a long time for an operation (0.12 s).
[11:52:22][W][component:205]: Components should block for at most 20-30ms.

[11:52:27][D][data:270]: 1-0:2.8.0(000000.00
[11:52:27][D][data:270]: 1-0:3.8.0(000002.602*kvarh �
[11:52:27][D][data:270]: 1
[11:52:27][D][data:270]: 1-0:1.
[11:52:27][D][data:270]: 1�0:2�7,0(0
[11:52:27][D][data:270]: � :3.7.0(0000.
[11:52:27][D][data:270]: \xb9s\xe5
[11:52:27][D][data:270]: (
[11:52:27][D][data:270]:
[11:52:27][D][data:270]:
[11:52:27][D][data:270]:
[11:52:27][D][data:270]:
[11:52:27][D][data:270]:
[11:52:27][D][data:270]:
[11:52:27][D][data:270]:
[11:52:27][D][data:270]: I�\x8es \xbb\xb0\xff\xfe{\xed\xff\x9b\xbf\xfb\xb0
[11:52:27][D][data:270]: �
[11:52:27][D][data:270]: 4�n\x96��\xea\xfc\xff~\xff\xbf\xbb\xee\xbf\xdd\xfb\xbf\xf7 �\xff\xff\x83\xf3���\xfb\xddò�\xcc\xd9\xff\xff\xff\xff\xf7\xb7\xff\xf7\x97\xbf\xf7\xf7\xffw\xbf\xf7�\xbf\xff\xbf\xf7\xff\xf7\xb7\xbb

[11:52:27][D][data:270]: ,\x95\xe87D\x81\xb2\xc0%
[11:52:27][D][data:270]: �x\xaf\xfb\xf3�\xbe\xeb\xf7_\xdf\xff\xfb\xff7\xbe�
[11:52:27][D][data:270]:
[11:52:27][D][data:270]: \x80\xec\xff\xfew\xe6~O�\x80
[11:52:27][D][data:270]:
[11:52:27][D][data:270]: �@� @�\xd8�
[11:52:27][D][data:270]: $�8
[11:52:27][D][data:270]: 5D<
[11:52:27][D][data:270]: ��
[11:52:27][D][data:270]:
[11:52:27][D][data:270]:
[11:52:27][D][data:270]:
[11:52:27][D][data:270]: \x88
[11:52:27][D][data:270]:
[11:52:27][D][data:270]: �
[11:52:28][D][data:270]: w\xf3\xfe\xdc\xdfn \x94
[11:52:28][D][data:270]: 7
[11:52:28][D][data:270]:
[11:52:28][D][data:270]:
[11:52:28][D][data:270]: @ �@
[11:52:28][D][data:270]: \xfb\xa4�D
[11:52:28][D][data:270]:
[11:52:28][D][data:270]: \x82D\xd3V@ ��N0
[11:52:28][D][data:270]:
[11:52:28][D][data:270]:
[11:52:28][D][data:270]: \x80D;\x80\xc0�V\xc9\xf9\xbf�\x95\x82�R@ �\xfc��\xc3\xee��
[11:52:28][D][data:270]: @$�\xf4\x91�
[11:52:28][D][data:270]:
[11:52:28][D][data:270]: �
[11:52:28][D][data:270]: �
[11:52:28][D][data:270]:
[11:52:28][D][data:270]: �\xb4\xa6\xbf�\xc5\xc9
\xbf\xae\xa3���
[11:52:28][D][data:270]:
[11:52:28][D][data:270]: �;m�\xa1\xa3a\xa3\xff\xff\xff\xfb\xbf\xf7\xaf\xbb\xbbg\xff\xe7\xff
\xb66r\xa8\xb1\xb7\xb7Ȁ\x80
[11:52:28][D][data:270]: #\xf0�
[11:52:28][D][data:270]: \x80|\xff\x83\xfa��
[11:52:28][D][data:270]:
[11:52:28][D][data:270]: \xff\xff
[11:52:28][D][data:270]: u\xfd\xfd�\xff\xf7\xff\xb7\xfb\xfb\xeb\xff_\xa7&3�\xe0�;�\xfdݻ\xff\xfb$a�\xa6\x82
[11:52:28][D][data:270]: \x9a�\xe9\x9f}\xa3
[11:52:28][D][data:270]: \xce�B&\xbf?k9#\xa1@\xc83N�
[11:52:28][D][data:270]:
[11:52:28][D][data:270]:
[11:52:28][D][data:270]: \x81�
[11:52:28][D][data:270]: �
[11:52:28][D][data:270]: �\x90�\xe8\xfc\xca\xfd\xe0\xe0\xff\xff\xff\xbf\xf77'7W
[11:52:28][D][data:270]:
[11:52:28][D][data:270]: >
[11:52:28][D][data:270]: >�
[11:52:28][D][data:270]:
[11:52:28][D][data:270]: \x80
[11:52:28][D][data:270]: �
[11:52:28][D][data:270]: �
[11:52:28][D][data:270]: x
[11:52:28][D][data:270]:
[11:52:28][D][data:270]: \xc2\xf7߂\xd9�-.\xbfe\xff\xfd\xe0\xf7\xfe\xf0\xbf\xf7\xbf\xb7\xb3�6V
[11:52:28][D][data:270]: \x80
[11:52:28][D][data:270]:
[11:52:28][D][data:270]: \xf0\xf0\xc0\xb7\xb3vvv7f$�
[11:52:28][D][data:270]:
[11:52:28][D][data:270]: \x92\xb2\x96\x9b\xfe\xff�\xff\xfe\xff\xe0
[11:52:28][D][data:270]: �
[11:52:28][D][data:270]: \xff\xe0
[11:52:29][D][data:270]: \x81�4�\xd12��\x83F\xfc\xbf*\xf7\xb5
[11:52:29][D][data:270]:
[11:52:29][D][data:270]:
[11:52:29][D][data:270]:
[11:52:29][D][data:270]:
[11:52:29][D][data:270]: �
[11:52:29][D][data:270]: �
[11:52:29][D][data:270]:
[11:52:29][D][data:270]:
[11:52:29][D][data:270]: \xff&\x80TA\x80���\x82
[11:52:29][D][data:270]: \x80\xd0\xff
[11:52:29][D][data:270]:
[11:52:29][D][data:270]:
[11:52:29][D][data:270]: ��
[11:52:29][D][data:270]: \xf0m\xff\xff\xff\xff\xff\xff\xfdo\xff\xe0
[11:52:29][D][data:270]:
[11:52:29][D][data:270]:
[11:52:29][D][data:270]:
[11:52:29][D][data:270]: \xe2?>��\xc0
[11:52:29][D][data:270]: 3\xff\xff\xaf\xbb7\xfe
[11:52:29][D][data:270]: �\x80\xc0�\xfa
[11:52:29][D][data:270]:
[11:52:30][D][data:270]:
[11:52:30][D][data:270]:
[11:52:30][D][data:270]: \xfb
[11:52:30][D][data:270]: �
[11:52:30][D][data:270]: �
[11:52:30][D][data:270]: \xb9@\xd2\xff\xff\xff\x9f\xfe\xff\xfb\xfe\xffQD�\xfe
[11:52:30][D][data:270]: \xf7J\xc0�\xc0\xf4\xfbB\xc0\xff\xff\xfe�\xfe
[11:52:30][D][data:270]:
[11:52:30][D][data:270]:
[11:52:30][D][data:270]:
[11:52:30][D][data:270]: \x96#\xf7\xbd3>�\xef�D\xf8\xff7\xbf\xdf @
[11:52:30][D][data:270]: |�
[11:52:30][D][data:270]:
[11:52:30][D][data:270]: �
[11:52:31][D][data:270]: �
[11:52:31][D][data:270]:
[11:52:31][D][data:270]: \xe3�\xd7u
[11:52:31][D][data:270]: �@�\xc00
[11:52:31][D][data:270]:
[11:52:31][D][data:270]:
[11:52:31][D][data:270]:
[11:52:31][D][data:270]: &\xaa\x80\xb5\xf2\xb1D�\xd91\xff�p\xb1wIS�\x85p
[11:52:31][D][data:270]:
[11:52:31][D][data:270]:
[11:52:31][D][data:270]: \x89�<\xff
[11:52:31][D][data:270]: !"\xe0�N\xfb\x94\xff\xbb\xff\xff\xf0\xf0\xff\xb7w7\xf7\xb7\xbf\xf7\xff\xbb\xff\xff\xff\xff7w\xf7wv;77w\xb7\xb7w7�\xb7\xb7\xb7\xff\xff\xff\xff!\xb7�d65\xcc7\xb7\xff\xbbw

[11:52:31][I][crc:281]: Telegram read. CRC: 107C = 0000. PASS = NO
[11:52:31][D][data:270]: 0@\xe1\xdf�
[11:52:31][D][data:270]: �\xd1�$
[11:52:31][D][data:270]: \xf0
[11:52:31][D][data:270]:
[11:52:31][D][data:270]:
[11:52:31][D][data:270]: \x80
[11:52:31][D][data:270]:
[11:52:31][D][data:270]: \xb9!\xb5\xfe}\xf3v\xed\xff\xbf�2\xf5vs\xbb\xb6\xeb\xfc3\xbf\xeb\xf9\xf7\xf7\xff\xf7\xf7�ۧ7\xfb\xdcd\xef\x94?\xf7\xef\xff\xff\xbf6��
[11:52:31][D][data:270]: \xb6\xb5u\x97\xab\xb5\xb3\xeeٹw$\xb4�/\xfb\xa5�� \x93\xdd��w'л6��\xb7\x80aw6\x8d\x807��w "
[11:52:31][D][data:270]: �Ĝ\x97\xe0\xf0
[11:52:31][D][data:270]: @
[11:52:31][D][data:270]:
[11:52:31][D][data:270]: �
[11:52:31][D][data:270]: �\x80� �r�\xa9
[11:52:31][D][data:270]:
[11:52:31][D][data:270]: ��
[11:52:31][D][data:270]: ?\xf6\xff2&\xf3o\xff
[11:52:31][D][data:270]: �\xff7�
[11:52:31][D][data:270]: n&wL\xa7\xce]
}m\x9f�
[11:52:31][D][data:270]:
[11:52:31][D][data:270]:
[11:52:31][D][data:270]: 0Tݓv?\xed�\x9a�^\xf6\xfdݐQ\xbb\xb7\xfbw\x97s\xfd\xff\xf0\xff� \x93\xe3\xff\xff\xd07\xb77\xbb7\xbf\xff
[11:52:31][D][data:270]: &0\xd9\xf6\x902�\xa0\xadv\xbf\xf53\xf6\xbf˓"\xf0\x8b
[11:52:31][D][data:270]: \xa3�\xf6'\xfd\xb3;�,\xff" w\xff\xa6\xa5
λ��2$�\xb3;\xff�\x95\x83\xff\xfe\xff\xfb\xf7\xf7\xff\xc0\xefj\xaf槳\xb6\xbf\xb7\xd7\xf7\xb7\xb7\xb7\xb7\xb7\xbb7w\xf7\xb7

[11:52:31][D][data:270]: \x9aN\xce�\xb7T\xb1#\x99\x90\xb7\xf8۟\xbb\xb2\xf5\x91\xb5\xe4\xbb�\xfb\x9d
[11:52:31][D][data:270]: �@\x9c\xb3��hG\xd0\xc4�7&\xec_{O\xf8\xf2
[11:52:31][D][data:270]: A
[11:52:31][D][data:270]:
[11:52:31][D][data:270]:
[11:52:31][D][data:270]: B
[11:52:31][D][data:270]: \x91 �@e��`\x81HQ\xcd$\xc4 %\xfcFHؠd\xfd\xff\xff\xff�
[11:52:31][D][data:270]:
[11:52:31][D][data:270]: H
[11:52:31][D][data:270]:
[11:52:31][D][data:270]:
[11:52:31][D][data:270]: \x97\xff�*='\xfe;�
[11:52:31][D][data:270]:
[11:52:31][D][data:270]: ����
[11:52:31][D][data:270]: �\x8bPU!E@
[11:52:31][D][data:270]:
[11:52:31][D][data:270]: \x81
[11:52:31][D][data:270]:
[11:52:31][D][data:270]: P� ���\x80
[11:52:31][D][data:270]:
[11:52:31][D][data:270]:
[11:52:31][D][data:270]:
[11:52:31][D][data:270]: ,��"�
[11:52:31][D][data:270]:
[11:52:31][D][data:270]: %
[11:52:31][D][data:270]: 1V\xe7\x93:��r\xf6o\x99\xffD3r$S\x96�\x858w$仵Gv ?F\x977\xbf\xb7\xb7\xb7\xb7\xb7\xff\xa0\x922�jH��٢7\xb777\xf3\xbf\xff
[11:52:31][D][data:270]: \xd8\xff\xff\xdf17qس\x9f&\xf7\xfe6<j\xd85V\xcd1"\xed\xb3\xf6\xf7\xef\xbf6�\xff\xc0\033\xb3\xb7\xf7\xb7\xb73\x9f\xa0�XQU\x89\x95bB
\xbb\xf3\xff\xf7\xf7\xb7\xf7\xb7\xbf\xbf

[11:52:31][D][data:270]: \xadR\xed?\xff\xb8G\xfb\xdf�\x94\xff�\xb8\xf7w\xc1]\xfd\xd7f\xdf\xf9�\x80\xb7\xb7\xff\xff�\033�\xa3\xa5\xc7#\x8e\xfb\xff\xff\xb7\xff\xbf\xff\xf7\xbf\xff
[11:52:31][D][data:270]: \xa3\xf6\xb7\xbe\x92Ĭw\xcb7\xfb\xff/\xf7/\xfbw~�\xbf\xbb\xc6\xf7\xff\xf3\xc0\xff\xff\xf7\xf7�\xeb\xff\xa3\xf67\xabۓ\xb3\xff\xf7\xff\xff?\xb7\xf7\xff\xbf\xbf\xff\xbf7\xbb\xb7\xf7\xb7\xb7\xb7\xa7

[11:52:31][D][data:270]: 4Dͷ\xec\x88!6\xe5\xf0׷w\xb7n�3
[11:52:31][D][data:270]: �2\xb0\xa9@\xd0&1�\xdc�Db
[11:52:31][D][data:270]: D\x981'@�\x82\x84"�&�\x927 \x9d&i\x815�d \xee� �|\x90�wf�� [11:52:31][D][data:270]: \x99�!�77\xec\xe2v�@\x80S [11:52:31][D][data:270]: � [11:52:31][D][data:270]: ��\x80FH [11:52:31][D][data:270]: P� [11:52:31][D][data:270]: 0 [11:52:31][D][data:270]: 5�\xd86'��\x83@dG \xd0\xe0\x80\xc7\xf7w\x9c\xd2\xfbTR�\xa0(
[11:52:32][D][data:270]: [11:52:32][D][data:270]: �� [11:52:32][D][data:270]: H@�� [11:52:32][D][data:270]: [11:52:32][D][data:270]: \xb0@\xa1\xa3�ٲ@�\xa0��٣�\xb5 [11:52:32][D][data:270]: [11:52:32][D][data:270]: �@\xd8$tH\x88\x9b\x80b\xb7&\xff\xbf\xa7gm\xd1� [11:52:32][D][data:270]: [11:52:32][D][data:270]: � [11:52:32][D][data:270]: '5Y T
[11:52:32][D][data:270]: �
[11:52:32][D][data:270]:
[11:52:32][D][data:270]:
[11:52:32][D][data:270]: �
[11:52:32][D][data:270]:
[11:52:32][D][data:270]: 0
[11:52:32][D][data:270]: �
[11:52:32][D][data:270]: �\x90 %H\x8c�\x84\x81��
[11:52:32][D][data:270]:
[11:52:32][D][data:270]: �
[11:52:32][D][data:270]:
[11:52:32][D][data:270]: @
[11:52:32][D][data:270]:
[11:52:32][D][data:270]: 8
[11:52:32][D][data:270]: @
[11:52:32][D][data:270]: \x84\x86\xed\xe0\xff0
[11:52:32][D][data:270]: t3\xf1\xff\xff
[11:52:32][D][data:270]:
[11:52:32][D][data:270]:
[11:52:32][D][data:270]:
[11:52:32][D][data:270]:
[11:52:32][D][data:270]:
[11:52:32][D][data:270]:
[11:52:32][D][data:270]:
[11:52:32][D][data:270]:
[11:52:32][D][data:270]:
[11:52:32][D][data:270]:
[11:52:32][D][data:270]:
[11:52:32][D][data:270]:
[11:52:32][D][data:270]:
[11:52:33][D][data:270]:
[11:52:33][W][component:204]: Component took a long time for an operation (6.28 s).
[11:52:33][W][component:205]: Components should block for at most 20-30ms.
[11:52:35][D][data:270]: \xff\xff0\xff
[11:52:37][D][data:270]: \xf7'\xf6\xff

[11:52:37][I][crc:281]: Telegram read. CRC: C3DB = AF3B. PASS = NO
[11:52:37][W][component:204]: Component took a long time for an operation (1.63 s).
[11:52:37][W][component:205]: Components should block for at most 20-30ms.
[11:52:42][D][data:270]:
[11:52:42][D][data:270]:
[11:52:42][D][data:270]:
[11:52:42][D][data:270]:
[11:52:42][D][data:270]:
[11:52:42][D][data:270]:
[11:52:42][D][data:270]:
[11:52:42][D][data:270]:
[11:52:42][D][data:270]:
[11:52:42][D][data:270]:
[11:52:42][D][data:270]:
[11:52:42][D][data:270]:
[11:52:43][D][data:270]:
[11:52:43][W][component:204]: Component took a long time for an operation (1.40 s).
[11:52:43][W][component:205]: Components should block for at most 20-30ms.
[11:52:47][D][data:270]:
[11:52:47][D][data:270]:
[11:52:47][D][data:270]:
[11:52:47][D][data:270]:
[11:52:47][D][data:270]:
[11:52:47][D][data:270]:
[11:52:47][D][data:270]:
[11:52:47][D][data:270]:
[11:52:47][D][data:270]:
[11:52:47][D][data:270]:
[11:52:47][D][data:270]:
[11:52:47][D][data:270]:
[11:52:48][D][data:270]:
[11:52:48][W][component:204]: Component took a long time for an operation (1.12 s).
[11:52:48][W][component:205]: Components should block for at most 20-30ms.
[11:52:52][D][data:270]:
[11:52:52][W][component:204]: Component took a long time for an operation (2.21 s).
[11:52:52][W][component:205]: Components should block for at most 20-30ms.
[11:52:52][D][data:270]:
[11:52:52][D][data:270]:
[11:52:52][D][data:270]:
[11:52:52][D][data:270]:
[11:52:52][D][data:270]:
[11:52:52][D][data:270]:
[11:52:52][D][data:270]:
[11:52:52][D][data:270]:
[11:52:52][D][data:270]:
[11:52:52][D][data:270]:
[11:52:52][D][data:270]:
[11:52:52][D][data:270]:
[11:52:53][D][data:270]:
[11:52:53][W][component:204]: Component took a long time for an operation (1.12 s).
[11:52:53][W][component:205]: Components should block for at most 20-30ms.
[11:52:57][D][data:270]:
[11:52:57][D][data:270]:
[11:52:57][D][data:270]:
[11:52:57][D][data:270]:
[11:52:57][D][data:270]:
[11:52:57][D][data:270]:
[11:52:57][D][data:270]:
[11:52:57][D][data:270]:
[11:52:57][D][data:270]:
[11:52:57][D][data:270]:
[11:52:57][D][data:270]:
[11:52:57][D][data:270]: `

Instability Frequent Drop out

I have been using 8266 as P1 reader since 6 months without any issue until now. ESP crashes pretty much every 2nd readings. I replaced with new 8266 and I updated to the latest esphome since then and even moved a WIFI AP literally next to the EL box but nothing fixed the issue. I have now reduced the wifi output_power from default 20 to 17 and this reduced the number of crashes. I am just wondering what might have caused this sudden change in behavior. I also have capacitor at the power line.

Home Assistant configuration

I've been running Home Assistant for some time, but am new to ESPHome and I've ran into some issues with the configuration before flashing my NodeMCU. I understand this is essentially a Home Assistant and/or ESPHome question, but I have not been able to find anything useful when googling, so attempting a post here.

It's the value for hass_api_password in particular I'm having problems understanding. I assume it is an API password for some REST API that can be enabled within home assistant. Is that at all correct? I've tried both the legacy_api_password method and the newer REST API without being able to successfully connect (using curl that is, not esphome-p1reader which I haven't even attempted yet).

I've also considered that hass_api_password could be something ESPHome related, which I have very little knowledge about, but my research has come up blank there as well. I'd greatly appreciate if someone could point me in the right direction with regards to what hass_api_password is and how I can set it up. Thanks!

esphome encryption key instructions

Use encryption key rather than password for api access. Using password is deprecated.

Something like:

api:
  encryption:
    key: !secrets encryption_key

Changes with Slimmelezer and Aidon 6534

First of all, thank a lot for this code. Helped me a lot!
I bought Slimmelezer Plus for my Aidon 6534 just to realise afterwards that the energy meter doesn't follow the standard protocol.
But with your p1reader-code with some modifications I got it to to work. Thanks to Skracke on byggahus forum and jsuanet at HA forums. Let me show you how I got it to work!
The changes I did in order to get the Slimmelezer Plus to work with my Aidon 6534 meter was:

In file "p1reader.h" =

  • #define BUF_SIZE 50 to #define BUF_SIZE 60
  • In every place where "readBytes" occurred I changed to "Serial.readBytes". Was like in 5-6 places, I used the search for "bytes".
  • Also in some placed there was "readBytesUntil" and that I changed to "Serial.readBytesUntil".

And in file "p1reader.yaml" I changed:

  • tx_pin: TX to tx_pin: D8
  • rx_pin: RX to tx_pin: D7
  • I also changed the name from "electricity_meter" to "slimmelezer". Not sure why but jsuanet on the forums said OTA update would fail otherwise. I did the change and have not had any problems yet.
  • Also changed board from "nodemcu" to "d1_mini"
  • I also added:
  • web_server:
  • port: 80
  • In order to be able to surf into the IP number of my Slimmelezer.
  • And lastly I added to the sensor "Cumulative Active Import"
  • state_class: total_increasing
  • device_class: energy
  • So that it could be used as an energy-meter in HA.

I hope this can help someone else in my position with a Slimmelezer Plus and a Aidon 6534 energy meter that doesnt follow standard protocol :)

Aidon meter and slimmelezer-wt32-eth01

Hi! I am trying to install this code on a slimmelezer-wt32-eth01, for being able to read data from my Aidon meter using HDLC. I have modified the code and i find it on the network but i only get "[hdlc:474] Expected 12 bytes, got 0 bytes - out of sync. Returning" in the log. With the original firmware for slimmelezer-wt32-eth01 i get "[dsmr:092] | Timeout while reading data for telegram"

The P1 port is activated, I have connected a Easee Equalizer and that gets correct data

esphome:
  name: esp-p1reader
  includes:
    - p1reader.h

esp32:
  board: esp32dev
  framework:
    type: arduino

ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO0_IN
  phy_addr: 1
  power_pin: GPIO16


# Enable logging
logger:
  level: DEBUG
  baud_rate: 0 # disable logging over uart
  
# Enable Home Assistant API
api:
  encryption:
    key: !secret encryption_key
    
ota:
  password: !secret ota_password
  
web_server:
  port: 80

uart:
  id: uart_bus
  baud_rate: 115200
  rx_pin: GPIO5
 

# If your electricity meter is an Aidon, which use the older
# Branschstandard (1.2) where the data is HDLC-formatted
# Change the first line after lambda to
# auto_meter_sensor = new P1ReaderHDLC(id(uart_bus));
# else
# auto meter_sensor = new P1Reader(id(uart_bus));
sensor:
- platform: custom
  lambda: |-
    auto meter_sensor = new P1ReaderHDLC(id(uart_bus));
    App.register_component(meter_sensor);
    return {
      meter_sensor->cumulativeActiveImport,
      meter_sensor->cumulativeActiveExport,
      meter_sensor->cumulativeReactiveImport,
      meter_sensor->cumulativeReactiveExport,
      meter_sensor->momentaryActiveImport,
      meter_sensor->momentaryActiveExport,
      meter_sensor->momentaryReactiveImport,
      meter_sensor->momentaryReactiveExport,
      meter_sensor->momentaryActiveImportL1,
      meter_sensor->momentaryActiveExportL1,
      meter_sensor->momentaryActiveImportL2,
      meter_sensor->momentaryActiveExportL2,
      meter_sensor->momentaryActiveImportL3,
      meter_sensor->momentaryActiveExportL3,
      meter_sensor->momentaryReactiveImportL1,
      meter_sensor->momentaryReactiveExportL1,
      meter_sensor->momentaryReactiveImportL2,
      meter_sensor->momentaryReactiveExportL2,
      meter_sensor->momentaryReactiveImportL3,
      meter_sensor->momentaryReactiveExportL3,
      meter_sensor->voltageL1,
      meter_sensor->voltageL2,
      meter_sensor->voltageL3,
      meter_sensor->currentL1,
      meter_sensor->currentL2,
      meter_sensor->currentL3
    };
  sensors:
  - name: "Cumulative Active Import"
    unit_of_measurement: kWh
    accuracy_decimals: 3
    state_class: "total_increasing"
    device_class: "energy"
  - name: "Cumulative Active Export"
    unit_of_measurement: kWh
    accuracy_decimals: 3
    state_class: "total_increasing"
    device_class: "energy"
  - name: "Cumulative Reactive Import"
    unit_of_measurement: kvarh
    accuracy_decimals: 3
  - name: "Cumulative Reactive Export"
    unit_of_measurement: kvarh
    accuracy_decimals: 3
  - name: "Momentary Active Import"
    unit_of_measurement: kW
    accuracy_decimals: 3
    state_class: "measurement"
    device_class: "power"
  - name: "Momentary Active Export"
    unit_of_measurement: kW
    accuracy_decimals: 3
    state_class: "measurement"
    device_class: "power"
  - name: "Momentary Reactive Import"
    unit_of_measurement: kvar
    accuracy_decimals: 3
  - name: "Momentary Reactive Export"
    unit_of_measurement: kvar
    accuracy_decimals: 3
  - name: "Momentary Active Import Phase 1"
    unit_of_measurement: kW
    accuracy_decimals: 3
    state_class: "measurement"
    device_class: "power"
  - name: "Momentary Active Export Phase 1"
    unit_of_measurement: kW
    accuracy_decimals: 3
    state_class: "measurement"
    device_class: "power"
  - name: "Momentary Active Import Phase 2"
    unit_of_measurement: kW
    accuracy_decimals: 3
    state_class: "measurement"
    device_class: "power"
  - name: "Momentary Active Export Phase 2"
    unit_of_measurement: kW
    accuracy_decimals: 3
    state_class: "measurement"
    device_class: "power"
  - name: "Momentary Active Import Phase 3"
    unit_of_measurement: kW
    accuracy_decimals: 3
    state_class: "measurement"
    device_class: "power"
  - name: "Momentary Active Export Phase 3"
    unit_of_measurement: kW
    accuracy_decimals: 3
    state_class: "measurement"
    device_class: "power"
  - name: "Momentary Reactive Import Phase 1"
    unit_of_measurement: kvar
    accuracy_decimals: 3
  - name: "Momentary Reactive Export Phase 1"
    unit_of_measurement: kvar
    accuracy_decimals: 3
  - name: "Momentary Reactive Import Phase 2"
    unit_of_measurement: kvar
    accuracy_decimals: 3
  - name: "Momentary Reactive Export Phase 2"
    unit_of_measurement: kvar
    accuracy_decimals: 3
  - name: "Momentary Reactive Import Phase 3"
    unit_of_measurement: kvar
    accuracy_decimals: 3
  - name: "Momentary Reactive Export Phase 3"
    unit_of_measurement: kvar
    accuracy_decimals: 3
  - name: "Voltage Phase 1"
    unit_of_measurement: V
    accuracy_decimals: 3
    state_class: "measurement"
    device_class: "voltage"
  - name: "Voltage Phase 2"
    unit_of_measurement: V
    accuracy_decimals: 3
    state_class: "measurement"
    device_class: "voltage"
  - name: "Voltage Phase 3"
    unit_of_measurement: V
    accuracy_decimals: 3
    state_class: "measurement"
    device_class: "voltage"
  - name: "Current Phase 1"
    unit_of_measurement: A
    accuracy_decimals: 3
    state_class: "measurement"
    device_class: "current"
  - name: "Current Phase 2"
    unit_of_measurement: A
    accuracy_decimals: 3
    state_class: "measurement"
    device_class: "current"
  - name: "Current Phase 3"
    unit_of_measurement: A
    accuracy_decimals: 3
    state_class: "measurement"
    device_class: "current"

All CRC checks fail when log level is INFO, but work at log level DEBUG

I had no problem setting up a D1-mini according to the instructions (except i inverted the signal in the configuration instead of using the transistor) and everything worked right away, so a big thanks for everything!

Except when I changed the log level to INFO instead of DEBUG, all CRC checks would fail. Rebuilt ESPHome with DEBUG and everything works again.

There is a comment in the code about restoring the newline character because it is needed by the CRC calculations. Is that because the logging removes it, but only if DEBUG logging is enabled? That would explain the behavior I am seeing...

Will this work for Landis Gyr E250?

I have a landis gyr e250 net meter at my house. It has the Rj11 port but which is visible from the outside through the transparent covering. But I believe the pins of RJ port are different from the circuit diagram provided along this project. Instead of 5v, RTS Data GND, N.C, TX and GND as in the circuit diagram of this project. It is labelled like below.

image

What change should I make to the below standard circuit diagram to make this work with E250?
image

Iskra AM550 - Data not published, CRC error

Hi is there anyway of troubleshooting issues with the crc checksum - looking at the log the received data indeed seems off however it doesn't seem quite like just poor wiring given how the positions where we see invalid data seems to be following a pattern... well at least a bit.

The meter is an Iskra AM550. I tried tweaking the delay and buffer size but no effect...

[09:41:26][D][data:305]: /ISk5\2M550T-2006
[09:41:26][D][data:305]:
[09:41:26][D][data:305]: 1-0:0.9.1(094127)
[09:41:26][D][data:305]: 1-0:0.9.2(220130)
[09:41:26][D][data:305]: 0-0:96.1.0(77516889)
[09:41:26][D][data:305]: 0-2:25.6.0(ER23)
[09:41:26][D][data:305]: 0-0:25.1.0(ER23)
[09:41:26][D][data:305]: 1-0:1.8.0(027257.748kWh)
[09:41:26][D][data:305]: 1-0:2.8.0(000000.000
kWh)
[09:41:26][D][data:305]: 1-0:3.8.0(004565.274kvarh)
[09:41:26][D][data:305]: kW)
[09:41:26][D][data:305]: 1-0:41.7.0(01.422
kW)
[09:41:26][D][data:305]: 1-0:42.7.0(00.000
kW)
[09:41:26][D][data:305]: 1-0:61.7.0(00.842kW)
[09:41:26][D][data:305]: 1-0:62.7.0(00.000
kW)
[09:41:26][D][data:305]: 1-0:31.7.0(011A)
[09:41:26][D][data:305]: 1-0:32.7.0(228.9
V)
[09:41:26][D][data:305]: 1-0:51.7.0(006A)
[09:41:26][D][data:305]: 1-0:52.7.0(231.3
V)
[09:41:26][D][data:305]: 1-0:71.7.0(003A)
[09:41:26][D][data:305]: 1-0:72.7.0(234.0
V)
[09:41:26][D][data:305]: 1-0:0.2.0((ER11))
[09:41:26][D][data:305]: 1-0:0.2.8((ER11))
[09:41:26][D][data:305]: !F8D6
[09:41:26][I][crc:317]: Telegram read. CRC: BF63 = F8D6. PASS = NO
[09:41:36][D][data:305]: /ISk5\2M550T-2006
[09:41:36][D][data:305]:
[09:41:36][D][data:305]: 1-0:0.9.1(094137)
[09:41:36][D][data:305]: 1-0:0.9.2(220130)
[09:41:36][D][data:305]: 0-0:96.1.0(77516889)
[09:41:36][D][data:305]: 0-2:25.6.0(ER23)
[09:41:36][D][data:305]: 0-0:25.1.0(ER23)
[09:41:36][D][data:305]: 1-0:1.8.0(027257.762kWh)
[09:41:36][D][data:305]: 1-0:2.8.0(000000.000
kWh)
[09:41:36][D][data:305]: 1-0:3.8.0(004565.277kvarh)
[09:41:36][D][data:305]: 1-0:4.8.0(001459.254
kvarh)
[09:41:36][D][data:305]: 000kW)
[09:41:36][D][data:305]: 1-0:41.7.0(01.430
kW)
[09:41:36][D][data:305]: 1-0:42.7.0(00.000kW)
[09:41:36][D][data:305]: 1-0:61.7.0(01.576
kW)
[09:41:36][D][data:305]: 1-0:62.7.0(00.000kW)
[09:41:36][D][data:305]: 1-0:31.7.0(015
A)
[09:41:36][D][data:305]: 1-0:32.7.0(228.1V)
[09:41:36][D][data:305]: 1-0:51.7.0(006
A)
[09:41:36][D][data:305]: 1-0:52.7.0(231.3V)
[09:41:36][D][data:305]: 1-0:71.7.0(006
A)
[09:41:36][D][data:305]: 1-0:72.7.0(233.4V)
[09:41:36][D][data:305]: 1-0:0.2.0((ER11))
[09:41:36][D][data:305]: 1-0:0.2.8((ER11))
[09:41:36][D][data:305]: !F1BC
[09:41:36][I][crc:317]: Telegram read. CRC: D65B = F1BC. PASS = NO
[09:41:46][D][data:305]: /ISk5\2M550T-2006
[09:41:46][D][data:305]:
[09:41:46][D][data:305]: 1-0:0.9.1(094147)
[09:41:46][D][data:305]: 1-0:0.9.2(220130)
[09:41:46][D][data:305]: 0-0:96.1.0(77516889)
[09:41:46][D][data:305]: 0-2:25.6.0(ER23)
[09:41:46][D][data:305]: 0-0:25.1.0(ER23)
[09:41:46][D][data:305]: 1-0:1.8.0(027257.780
kWh)
[09:41:46][D][data:305]: 1-0:2.8.0(000000.000kWh)
[09:41:46][D][data:305]: 1-0:3.8.0(004565.280
kvarh)
[09:41:46][D][data:305]: 1-0:4.8.0(001459.254kvarh)
[09:41:46][D][data:305]: 1-0:1.7.0(06.368
kW)
[09:41:46][D][data:305]: )
[09:41:46][D][data:305]: 1-0:41.7.0(01.442kW)
[09:41:46][D][data:305]: 1-0:42.7.0(00.000
kW)
[09:41:46][D][data:305]: 1-0:61.7.0(01.580kW)
[09:41:46][D][data:305]: 1-0:62.7.0(00.000
kW)
[09:41:46][D][data:305]: 1-0:31.7.0(015A)
[09:41:46][D][data:305]: 1-0:32.7.0(228.2
V)
[09:41:46][D][data:305]: 1-0:51.7.0(006A)
[09:41:46][D][data:305]: 1-0:52.7.0(231.3
V)
[09:41:46][D][data:305]: 1-0:71.7.0(006A)
[09:41:46][D][data:305]: 1-0:72.7.0(233.5
V)
[09:41:46][D][data:305]: 1-0:0.2.0((ER11))
[09:41:46][D][data:305]: 1-0:0.2.8((ER11))
[09:41:46][D][data:305]: !8190
[09:41:46][I][crc:317]: Telegram read. CRC: 630E = 8190. PASS = NO
[09:41:56][D][data:305]: /ISk5\2M550T-2006
[09:41:56][D][data:305]:
[09:41:56][D][data:305]: 1-0:0.9.1(094157)
[09:41:56][D][data:305]: 1-0:0.9.2(220130)
[09:41:56][D][data:305]: 0-0:96.1.0(77516889)
[09:41:56][D][data:305]: 0-2:25.6.0(ER23)
[09:41:56][D][data:305]: 0-0:25.1.0(ER23)
[09:41:56][D][data:305]: 1-0:1.8.0(027257.797kWh)
[09:41:56][D][data:305]: 0:41.7.0(01.446
kW)
[09:41:56][D][data:305]: 1-0:42.7.0(00.000kW)
[09:41:56][D][data:305]: 1-0:61.7.0(01.581
kW)
[09:41:56][D][data:305]: 1-0:62.7.0(00.000kW)
[09:41:56][D][data:305]: 1-0:31.7.0(015
A)
[09:41:56][D][data:305]: 1-0:32.7.0(228.3V)
[09:41:56][D][data:305]: 1-0:51.7.0(006
A)
[09:41:56][D][data:305]: 1-0:52.7.0(231.2V)
[09:41:56][D][data:305]: 1-0:71.7.0(006
A)
[09:41:56][D][data:305]: 1-0:72.7.0(233.4*V)
[09:41:56][D][data:305]: 1-0:0.2.0((ER11))
[09:41:56][D][data:305]: 1-0:0.2.8((ER11))
[09:41:56][D][data:305]: !24AB

Problem with Wemos using ch340

I tried to use a Wemos Mini (Banggood) in combination with a ZIV smart meter.
The WeMos did go offline after initiating startup.
Checking the signal on the transistor collector (connected to rx) I noticed it is not getting the proper "low" signal.
In this, I did not connect to the ZIV meter, but checked the TX line at the RJ12 connector as being "high" (i.e. pulled high to 5V).
Is this failing signal value a known issue due to sharing the rx input with the CH340 line?
If so, is there a solution to this?
Looking forward to any reply.

Compilation error with latest esphome 2021.10.0

In file included from src/main.cpp:52:0:
src/p1reader.h: In member function 'void P1Reader::readP1Message()':
src/p1reader.h:261:58: error: 'readBytesUntil' was not declared in this scope
int len = readBytesUntil('\n', buffer, BUF_SIZE);
^
Compiling /data/energy/.pioenvs/energy/lib67b/ESP8266WiFi/CertStoreBearSSL.cpp.o
*** [/data/energy/.pioenvs/energy/src/main.cpp.o] Error 1
========================= [FAILED] Took 24.46 seconds =========================

UnicodeDecodeError

Hi!

Installed and wired according to the instructions. When starting the "esphome p1reader.yaml logs" I always get the following:

INFO Reading configuration p1reader.yaml...
INFO Starting log output from electricity_meter.local using esphome API
INFO Connecting to electricity_meter.local:6053 (192.168.100.59)
INFO Successfully connected to electricity_meter.local
[21:17:33][I][app:105]: ESPHome version 1.16.2 compiled on Apr 8 2021, 14:17:57
[21:17:33][C][wifi:443]: WiFi:
[21:17:33][C][wifi:303]: SSID: 'Ekebacken_IoT'
[21:17:33][C][wifi:304]: IP Address: 192.168.100.59
[21:17:33][C][wifi:306]: BSSID: 74:83:C2:DA:2E:49
[21:17:33][C][wifi:307]: Hostname: 'electricity_meter'
[21:17:33][C][wifi:311]: Signal strength: -59 dB ▂▄▆█
[21:17:33][C][wifi:315]: Channel: 11
[21:17:33][C][wifi:316]: Subnet: 255.255.255.0
[21:17:33][C][wifi:317]: Gateway: 192.168.100.1
[21:17:33][C][wifi:318]: DNS1: 192.168.100.100
[21:17:33][C][wifi:319]: DNS2: 1.1.1.1
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/usr/lib/python3.9/site-packages/esphome/api/client.py", line 391, in run
self._run_once()
File "/usr/lib/python3.9/site-packages/esphome/api/client.py", line 381, in _run_once
msg.ParseFromString(raw_msg)
File "/usr/lib/python3.9/site-packages/google/protobuf/message.py", line 199, in ParseFromString
return self.MergeFromString(serialized)
File "/usr/lib/python3.9/site-packages/google/protobuf/internal/python_message.py", line 1145, in MergeFromString
if self._InternalParse(serialized, 0, length) != length:
File "/usr/lib/python3.9/site-packages/google/protobuf/internal/python_message.py", line 1212, in InternalParse
pos = field_decoder(buffer, new_pos, end, self, field_dict)
File "/usr/lib/python3.9/site-packages/google/protobuf/internal/decoder.py", line 619, in DecodeField
field_dict[key] = _ConvertToUnicode(buffer[pos:new_pos])
File "/usr/lib/python3.9/site-packages/google/protobuf/internal/decoder.py", line 572, in _ConvertToUnicode
value = local_unicode(byte_str, 'utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc6 in position 33: 'utf-8' codec can't decode byte 0xc6 in position 33: invalid continuation byte in field: SubscribeLogsResponse.message
WARNING Disconnected from API: Timeout while waiting for message response!
INFO Connecting to electricity_meter.local:6053 (192.168.100.59)
WARNING Couldn't connect to API (Timeout while waiting for message response!). Trying to reconnect in 1 seconds
INFO Connecting to electricity_meter.local:6053 (192.168.100.59)
WARNING Couldn't connect to API (Timeout while waiting for message response!). Trying to reconnect in 1 seconds
INFO Connecting to electricity_meter.local:6053 (192.168.100.59)
WARNING Couldn't connect to API (Timeout while waiting for message response!). Trying to reconnect in 2 seconds
INFO Connecting to electricity_meter.local:6053 (192.168.100.59)
WARNING Couldn't connect to API (Timeout while waiting for message response!). Trying to reconnect in 3 seconds
INFO Connecting to electricity_meter.local:6053 (192.168.100.59)
WARNING Couldn't connect to API (Timeout while waiting for message response!). Trying to reconnect in 5 seconds
INFO Connecting to electricity_meter.local:6053 (192.168.100.59)
WARNING Couldn't connect to API (Timeout while waiting for message response!). Trying to reconnect in 7 seconds
INFO Connecting to electricity_meter.local:6053 (192.168.100.59)
WARNING Couldn't connect to API (Timeout while waiting for message response!). Trying to reconnect in 11 seconds

I wired the transistor incorrectly the first time which means that the signal inverter was not working and I didn't get any data on the RX-pin at all. When I checked the logs it was just idle so this leads me to suspect that I am getting some kind of garbage data "0xc6" that the python script doesn't like. Any suggestions?

My meter: https://brittedal.se/a/manual-till-elmatare-star

Please help!

P1 Decryption key for Luxembourgish Meters

Hi,
where can I enter the P1 decryption key for Luxembourgish Meters?
In WeiGus Code it is writen like so:
//Key for SAG1030700089067
uint8_t KEY_SMARTY[] = {0xAE, 0xBD, 0x21, 0xB7, 0x69, 0xA6, 0xD1, 0x3C, 0x0D, 0xF0, 0x64, 0xE3, 0x83, 0x68, 0x2E, 0xFF};

sorry, I am a beginner in all of this.

Thank you

Trouble installing node

Hey, ESPhome is all new to me. I use the addon in homeassistant. I copied the content from your p1reader.yaml pasted to my yaml file that was auto generated and created a new secrets.yaml with my data in the same directory (/config/esphome) but when I try to install I always get the same error log. What am I doing wrong?

Compiling /data/p1reader/.pioenvs/p1reader/src/main.cpp.o
/config/esphome/p1reader.yaml: In lambda function:
/config/esphome/p1reader.yaml:38:31: error: expected type-specifier before 'P1Reader'
auto meter_sensor = new P1Reader(id(uart_bus));
^
/config/esphome/p1reader.yaml:67:7: error: could not convert '{, , , , , , , , , , , , , , , , , , , , , , , , , }' from '' to 'std::vectoresphome::sensor::Sensor*'
};
^
/config/esphome/p1reader.yaml:68:3: warning: control reaches end of non-void function [-Wreturn-type]
sensors:
^
*** [/data/p1reader/.pioenvs/p1reader/src/main.cpp.o] Error 1
========================== [FAILED] Took 1.97 seconds ==========================

Add XIAO ESP32C3 to hardware section of readme.md

I have been running the Seeed Studio XIAO ESP32C3 device with p1reader for a few days now. I've had no glitches what so ever since my first successful compile and upload. Cold boot, WIFi connection and communication have all been perfect so far.
I assume this setup also could be used with many other ESP32 C3 boards as well.

The hardware setup is really minimal. The only needed external component is a 4.7 kohm pull-up resistor for the RX line. I chose to connect it to the standard TX pin (= GPIO20 or D7).

d1reader xiao esp32c3

I have deliberately omitted an extra capacitor on the input power lines. The Seeed Studio XIAO ESP32C3 already have 4.5 µF on-board on its 5V power input, and I believe that is sufficient.
Adding capacitance will inevitably increase the risk of cold boot problems. Especially when used with a power source with less current capacity than the intended USB port. As we must expect with P1 ports.

Other boards with less on-board capacitance might benefit from some external capacitance, but I would be careful adding more than 10µF, and watch out for cold boot problems.

Here is the yaml config that makes it work:

esp32:
  board: esp32-c3-devkitm-1
  variant: esp32c3
  framework:
    type: arduino

! IMPORTANT: - Do not use: board: seeed_xiao_esp32c3
or compilation will fail...

uart:
  id: uart_bus
  baud_rate: 115200
  rx_pin:
    number: 20   #  = GPIO20, D7, RX
    inverted: true

And some picks of my implementation:

DSC_0448
DSC_0450
DSC_0453

Missing data

Thanks for your nice 'project'. I've build your esphome p1 reader and it seems it works because I receive data in the logs:

[12:45:52][I][crc:276]: Telegram read. CRC: 5895 = 5895. PASS = YES
[12:45:52][D][sensor:113]: 'Cumulative Active Import': Sending state 0.00000 kWh with 3 decimals of accuracy
[12:45:52][D][sensor:113]: 'Cumulative Active Export': Sending state 0.00000 kWh with 3 decimals of accuracy
[12:45:52][D][sensor:113]: 'Cumulative Reactive Import': Sending state 0.00000 kvarh with 3 decimals of accuracy
[12:45:52][D][sensor:113]: 'Cumulative Reactive Export': Sending state 0.00000 kvarh with 3 decimals of accuracy
[12:45:52][D][sensor:113]: 'Momentary Active Import': Sending state 0.43500 kW with 3 decimals of accuracy
[12:45:52][D][sensor:113]: 'Momentary Active Export': Sending state 0.00000 kW with 3 decimals of accuracy
[12:45:52][D][sensor:113]: 'Momentary Reactive Import': Sending state 0.00000 kvar with 3 decimals of accuracy
[12:45:52][D][sensor:113]: 'Momentary Reactive Export': Sending state 0.00000 kvar with 3 decimals of accuracy
[12:45:52][D][sensor:113]: 'Momentary Active Import Phase 1': Sending state 0.43500 kW with 3 decimals of accuracy
[12:45:52][D][sensor:113]: 'Momentary Active Export Phase 1': Sending state 0.00000 kW with 3 decimals of accuracy
[12:45:52][D][sensor:113]: '': Sending state 0.00000 with 0 decimals of accuracy
[12:45:52][D][sensor:113]: '': Sending state 0.00000 with 0 decimals of accuracy
[12:45:52][D][sensor:113]: '': Sending state 0.00000 with 0 decimals of accuracy
[12:45:52][D][sensor:113]: '': Sending state 0.00000 with 0 decimals of accuracy
[12:45:52][D][sensor:113]: 'Momentary Reactive Import Phase 1': Sending state 0.00000 kvar with 3 decimals of accuracy
[12:45:52][D][sensor:113]: 'Momentary Reactive Export Phase 1': Sending state 0.00000 kvar with 3 decimals of accuracy
[12:45:52][D][sensor:113]: '': Sending state 0.00000 with 0 decimals of accuracy
[12:45:52][D][sensor:113]: '': Sending state 0.00000 with 0 decimals of accuracy
[12:45:52][D][sensor:113]: '': Sending state 0.00000 with 0 decimals of accuracy
[12:45:52][D][sensor:113]: '': Sending state 0.00000 with 0 decimals of accuracy
[12:45:52][D][sensor:113]: 'Voltage Phase 1': Sending state 232.80000 V with 3 decimals of accuracy
[12:45:52][D][sensor:113]: '': Sending state 0.00000 with 0 decimals of accuracy
[12:45:52][D][sensor:113]: '': Sending state 0.00000 with 0 decimals of accuracy
[12:45:52][D][sensor:113]: 'Current Phase 1': Sending state 3.66000 A with 3 decimals of accuracy
[12:45:52][D][sensor:113]: '': Sending state 0.00000 with 0 decimals of accuracy

As you see most entries contain the value 0.00000 except Momentary Active Import, Voltage Phase 1 and Current Phase 1.
Any idea why the other information does not appear.
My smart meter is type Sagemcom S211 (same as T211 but for 1 single phase)

I live in Belgium and based what I found on https://jensd.be/1205/linux/data-lezen-van-de-belgische-digitale-meter-met-de-p1-poort the data on the P1 ports seems different:

0-0:96.1.4(xxxxx)
0-0:96.1.1(xxxxxxxxxxxxxxxxxxxxxxxxxxxx)
0-0:1.0.0(210204163628W)
1-0:1.8.1(000439.094kWh)
1-0:1.8.2(000435.292kWh)
1-0:2.8.1(000035.805kWh)
1-0:2.8.2(000012.156kWh)
0-0:96.14.0(0001)
1-0:1.7.0(00.233kW)
1-0:2.7.0(00.000kW)
1-0:21.7.0(00.233kW)
1-0:22.7.0(00.000kW)
1-0:32.7.0(236.2V)
1-0:31.7.0(002.04A)
0-0:96.3.10(1)
0-0:17.0.0(999.9kW)
1-0:31.4.0(999A)
0-0:96.13.0()
0-1:24.1.0(003)
0-1:96.1.1(xxxxxxxxxxxxxxxxxxxxxxxxxxxx)
0-1:24.4.0(1)
0-1:24.2.3(210204163500W)(00343.925*m3)
!1374
/FLU5\253xxxxxx_A

The obiscodes are corresponding with:
"0-0:1.0.0": "Timestamp",
"0-0:96.3.10": "Switch electricity",
"0-1:24.4.0": "Switch gas",
"0-0:96.1.1": "Meter serial electricity",
"0-1:96.1.1": "Meter serial gas",
"0-0:96.14.0": "Current rate (1=day,2=night)",
"1-0:1.8.1": "Rate 1 (day) - total consumption",
"1-0:1.8.2": "Rate 2 (night) - total consumption",
"1-0:2.8.1": "Rate 1 (day) - total production",
"1-0:2.8.2": "Rate 2 (night) - total production",
"1-0:21.7.0": "L1 consumption",
"1-0:41.7.0": "L2 consumption",
"1-0:61.7.0": "L3 consumption",
"1-0:1.7.0": "All phases consumption",
"1-0:22.7.0": "L1 production",
"1-0:42.7.0": "L2 production",
"1-0:62.7.0": "L3 production",
"1-0:2.7.0": "All phases production",
"1-0:32.7.0": "L1 voltage",
"1-0:52.7.0": "L2 voltage",
"1-0:72.7.0": "L3 voltage",
"1-0:31.7.0": "L1 current",
"1-0:51.7.0": "L2 current",
"1-0:71.7.0": "L3 current",
"0-1:24.2.3": "Gas consumption"

Debug not showing expected output.

So i just installed this on my new meter, with a D1 mini.

This is the output I'm getting. Any idéa on what could be the issue? The meter is an Aidon.

With pin not inverted:

[14:25:21][D][data:265]: 
[14:25:21][D][data:265]: 
[14:25:21][D][data:265]: 
[14:25:30][D][data:265]: ~\xa2CA�\x83�\x85\xeb\xe6\xe7
[14:25:30][D][data:265]: ��
[14:25:30][D][data:265]: �����
[14:25:30][D][data:265]: ��\xff�!��	��
[14:25:30][D][data:265]: �#��	��
[14:25:30][D][data:265]: ��
\xee���
[14:25:30][D][data:265]: �
[14:25:30][D][data:265]: �
[14:25:31][D][data:265]: �

And with pin invted:

[14:28:20][D][data:265]: \xa0\x97\xf5\xbd\xf9v=
[14:28:20][D][data:265]: \x86\xf8\xe1�\xff\xff\xff\xff\xfd\xc9\xfb\xfb\xed\xf3\xff\xff\xfd\xff\xff�{^3_\xf5\xe5\xc7\xd7�\xfe�\xbf\xed\xf3\xfd\xff\xfd\xf1\xff�\xbe\xff\xff\xff\xfb\xfb\xe1\xff\xd3\xc9\xfb\xf9\xed\xf3\xfd\xff\xfb\xf1\xff�

[14:28:20][D][data:265]: \xbe\xffӻ\xbf\xbf\xff\xd3\xc9\xfb\xf9\xed\xf3\xfd\xff\xf9\xf1\xff�\xbe\xff\xff\xff\xfb\xfb\xe1\xff\xd3\xc5\xfb\xf9\xed\xf3\xfd\xff\xf7\xf1\xff�\xbe\xff\xeb\xb9\xfb\xfb\xe1\xff\xd3\xc5\xfb\xf9\xed\xf3\xfd\xff\xc1\xf1\xff��

[14:28:20][D][data:265]: \xcc\xfb\xe1�\xba\xdb\xf9\xed\xf3\xfd\xff\x99\xf1\xff��\x94\xbf\xbf�\xba\xdb\xf9\xed\xf3\xfd\xffq\xf1\xff��e\xfb\xe1�\xba\xdb\xf9\xed\xf3\xfd\xff\xbf\xf1\xff�\xbb\xef\xb6\xfb\xe1�\xba\xdb\xf9\xed\xf3\xfd\xff

[14:28:20][D][data:265]: \x97\xf1\xff�\xbb/\xfb\xfb\xe1�\xba\xdb\xf9\xed\xf3\xfd\xffo\xf1\xff�\xbb/\xb6\xfb\xe1�\xba\xdb\xf9\xed\xf3\xfd\xff\xd5\xf1\xff�\xbe\xff\xff\xff\xfb\xfb\xe1\xff\xd3\xc9\xfb\xf9\xed\xf3\xfd\xff\xd3\xf1\xff�\xbe\xff

[14:28:20][D][data:265]: ﭿ\xbf\xff\xd3\xc9\xfb\xf9\xed\xf3\xfd\xff\xd1\xf1\xff�\xbe\xff\xff\xff\xfb\xfb\xe1\xff\xd3\xc5\xfb\xf9\xed\xf3\xfd\xff\xcf\xf1\xff�\xbe\xff\xf9\xa3\xfb\xfb\xe1\xff\xd3\xc5\xfb\xf9\xed\xf3\xfd\xff\xad\xf1\xff�\xbe\xff\xff

[14:28:20][D][data:265]: \xff\xfb\xfb\xe1\xff\xd3\xc9\xfb\xf9\xed\xf3\xfd\xff\xab\xf1\xff�\xbe\xff\xf3�\xfb\xfb\xe1\xff\xd3\xc9\xfb\xf9\xed\xf3\xfd\xff\xa9\xf1\xff�\xbe\xff\xff\xff\xfb\xfb\xe1\xff\xd3\xc5\xfb\xf9\xed\xf3\xfd\xff\xa7\xf1\xff�\xbe\xff\xf9

[14:28:20][D][data:265]: g\xbf\xbf\xff\xd3\xc5\xfb\xf9\xed\xf3\xfd\xff\x85\xf1\xff�\xbe\xff\xff\xff\xfb\xfb\xe1\xff\xd3\xc9\xfb\xf9\xed\xf3\xfd\xff\x83\xf1\xff�\xbe\xff\xf1鿿\xff\xd3\xc9\xfb\xf9\xed\xf3\xfd\xff\x81\xf1\xff�\xbe\xff\xff\xff\xfb

Z\xbf\xbf

[14:28:21][D][data:265]: \xff\xd3\xc3\xfb\xf9\xed\xf3\xfd\xff\xf9\xef\xff�\xbe\xff\xff\xff\xfb\xfb\xe1\xffӿ\xfb\xf9\xed\xf3\xfd\xff\xf7\xef\xff�\xbe\xf1uj\xbf\xbf\xffӿ\xe1+

PCB

So I got inspired with the new energy dashboard, found this repo when searching for alternatives to the dutch P1 system.

Redid your schematic to use a wemos d1 mini instead
image

And ofc a matching PCB
image

PCB is open for anyone to copy, download etc. here https://oshwlab.com/Naesstrom/esphome-p1reader

Now I just need to wait for the PCB's to design the 3d printed case :D

No data from S34U18 on Slimmelezer+

Hi

I have flashed my unit (Slimmelezer+) according to #45 .
When connecting it to my Vattenfall meter S34U18 I get no data at all.

Is it possible to debug the unit? And se what's happening?

ESP32

Needed to add rx_buffer_size: 4096 to get it to work. Can drive ESP32 from meter power supply.
uart:
id: uart_bus
rx_pin:
number: GPIO3
inverted: true
baud_rate: 115200
rx_buffer_size: 4096

Extend the esp to act as active repeater to connect additional P1 device

A small addition to the code will make the p1reader to repeat the signal to the TX pin. This enables additional devices to connect and use the p1 port and no need to buy a separate active r12 splitter.

The following is successfully implemented with a Tibber Pulse and a NodeMCU as p1reader/repeater:

  1. Set TX pin to inverted p1reader.yaml:
# Set TX pin to inverted to repeat signal correctly
uart:
  id: uart_bus
  tx_pin:
    number: GPIO1
    inverted: yes
  rx_pin: RX
  baud_rate: 115200
  1. In the p1reader.h add a line to write the received signal back to the uart_bus, add Serial.write(buffer); after the newline is put back:
            // put newline back as it is required for CRC calculation
            buffer[len] = '\n';
            buffer[len + 1] = '\0';
			
            // Write back the message to TX pin as a repeater: 
            Serial.write(buffer);

            // if we've reached the CRC checksum, calculate last CRC and compare
            if (buffer[0] == '!') {
  1. Wiring for next device:
    Connect a new r12 port or cable and connect +5V, GND, Data_GND accordingly and Data_OUT is connected to ESP TX pin.
    Leave the Data_Request unconnected (at least Tibber Pulse will not process if this is pulled high).

Landis Gyr e360 lte

Hey, just get the Landis Gyr e360 lte today. Is that thing also working with esphome-p1reader??
It´s seems to be the 2023 Version

Best

dual tariff

Hello,

Here in the Netherlands we can have a dual tariff subscription in which we have a peak and off peak tariff.
Can this code handle that and have 2 different sensors for both import and export (meaning 4 in total)

Add documentation for ESP32

The code works great on the NodeMCU ESP32, but because the documentation doesn't cover it, there are some pitfalls.

First, the NodeMCU ESP32 is too power hungry for the P1 port, which seemingly only outputs 5V 250mA, so an external power source is required. This means the VIN line can be omitted. (I'm fairly certain of this fact, but it's possible you can get away with just 250mA. I don't feel like finding out the hard way though.)

Second, the NodeMCU ESP32 has three separate UARTs, with different pin configurations. The RX pin of UART0 is pin 3, and this fact wasn't very easy to find. ESPHome documentation simply declares it "Internal".

I therefore suggest, for the sake of all users of the NodeMCU ESP32, that the documentation is updated to support them.

All this being said, because the ESP32 is both more expensive and requires an external power source, I recommend new users use a Wemos D1 Mini if possible.

D1 Mini suddenly needs external power to start

Running this on D1 Mini and has always been powered only from the P1 port (Vattenfall). Everything has been working flawlessly until I updated ESP HA addon and flashed devices with latest ESP fw (2022.12.3)
After successful flash, the device did not start and after hours of investigation I realized that after update my D1 mini needs external power to "jump start". After up and running I can remove external power and it keeps alive from P1 port.

Is there any breaking change I've totally missed?

Add mqtt support

Hello! Would it be possible to add mqtt support for us that use something other than home assist?

SlimmeLezer support [no issue]

Hi Pär,

Great work on the code! I've got many customers in Sweden for my device and some customers referred me to this code of yours.

My device has an integrated hardware inverter and I'm using the 2nd uart of the esp12f. Therefore the uart is changed in my below yaml code:

esphome:
  name: slimmelezer-se
  platform: ESP8266
  board: d1_mini
  includes:
    - p1reader.h

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "slimmelezer-se"

captive_portal:

# Enable logging
logger:
  level: DEBUG
  baud_rate: 0 # disable logging over uart
  
# Enable Home Assistant API
api:

ota:

web_server:
  port: 80

uart:
  id: uart_bus
  rx_pin: D7
  baud_rate: 115200
  
sensor:
- platform: custom
  lambda: |-
    auto meter_sensor = new P1Reader(id(uart_bus));
    App.register_component(meter_sensor);
    return {
      meter_sensor->cumulativeActiveImport,
      meter_sensor->cumulativeActiveExport,
      meter_sensor->cumulativeReactiveImport,
      meter_sensor->cumulativeReactiveExport,
      meter_sensor->momentaryActiveImport,
      meter_sensor->momentaryActiveExport,
      meter_sensor->momentaryReactiveImport,
      meter_sensor->momentaryReactiveExport,
      meter_sensor->momentaryActiveImportL1,
      meter_sensor->momentaryActiveExportL1,
      meter_sensor->momentaryActiveImportL2,
      meter_sensor->momentaryActiveExportL2,
      meter_sensor->momentaryActiveImportL3,
      meter_sensor->momentaryActiveExportL3,
      meter_sensor->momentaryReactiveImportL1,
      meter_sensor->momentaryReactiveExportL1,
      meter_sensor->momentaryReactiveImportL2,
      meter_sensor->momentaryReactiveExportL2,
      meter_sensor->momentaryReactiveImportL3,
      meter_sensor->momentaryReactiveExportL3,
      meter_sensor->voltageL1,
      meter_sensor->voltageL2,
      meter_sensor->voltageL3,
      meter_sensor->currentL1,
      meter_sensor->currentL2,
      meter_sensor->currentL3
    };
  sensors:
  - name: "Cumulative Active Import"
    unit_of_measurement: kWh
    accuracy_decimals: 3
    state_class: "total_increasing"
    device_class: "energy"
  - name: "Cumulative Active Export"
    unit_of_measurement: kWh
    accuracy_decimals: 3
    state_class: "total_increasing"
    device_class: "energy"
  - name: "Cumulative Reactive Import"
    unit_of_measurement: kvarh
    accuracy_decimals: 3
  - name: "Cumulative Reactive Export"
    unit_of_measurement: kvarh
    accuracy_decimals: 3
  - name: "Momentary Active Import"
    unit_of_measurement: kW
    accuracy_decimals: 3
  - name: "Momentary Active Export"
    unit_of_measurement: kW
    accuracy_decimals: 3
  - name: "Momentary Reactive Import"
    unit_of_measurement: kvar
    accuracy_decimals: 3
  - name: "Momentary Reactive Export"
    unit_of_measurement: kvar
    accuracy_decimals: 3
  - name: "Momentary Active Import Phase 1"
    unit_of_measurement: kW
    accuracy_decimals: 3
  - name: "Momentary Active Export Phase 1"
    unit_of_measurement: kW
    accuracy_decimals: 3
  - name: "Momentary Active Import Phase 2"
    unit_of_measurement: kW
    accuracy_decimals: 3
  - name: "Momentary Active Export Phase 2"
    unit_of_measurement: kW
    accuracy_decimals: 3
  - name: "Momentary Active Import Phase 3"
    unit_of_measurement: kW
    accuracy_decimals: 3
  - name: "Momentary Active Export Phase 3"
    unit_of_measurement: kW
    accuracy_decimals: 3
  - name: "Momentary Reactive Import Phase 1"
    unit_of_measurement: kvar
    accuracy_decimals: 3
  - name: "Momentary Reactive Export Phase 1"
    unit_of_measurement: kvar
    accuracy_decimals: 3
  - name: "Momentary Reactive Import Phase 2"
    unit_of_measurement: kvar
    accuracy_decimals: 3
  - name: "Momentary Reactive Export Phase 2"
    unit_of_measurement: kvar
    accuracy_decimals: 3
  - name: "Momentary Reactive Import Phase 3"
    unit_of_measurement: kvar
    accuracy_decimals: 3
  - name: "Momentary Reactive Export Phase 3"
    unit_of_measurement: kvar
    accuracy_decimals: 3
  - name: "Voltage Phase 1"
    unit_of_measurement: V
    accuracy_decimals: 3
  - name: "Voltage Phase 2"
    unit_of_measurement: V
    accuracy_decimals: 3
  - name: "Voltage Phase 3"
    unit_of_measurement: V
    accuracy_decimals: 3
  - name: "Current Phase 1"
    unit_of_measurement: A
    accuracy_decimals: 3
  - name: "Current Phase 2"
    unit_of_measurement: A
    accuracy_decimals: 3
  - name: "Current Phase 3"
    unit_of_measurement: A
    accuracy_decimals: 3

Update interval

I have a weird issue.
My values updates every second. I believe it used to update every 10 seconds before?
I been running this since without change for 2,5years.

Is there a way to change update intervall?

Reading from UART timed out at byte 0!

I am getting this error:

Aidon meter with Rj12 (activated) NodeMcu V3. Wiring as suggested!

[17:31:09][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:09][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:09][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:09][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:09][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:10][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:10][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:10][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:10][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:10][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:19][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:19][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:19][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:19][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:19][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:20][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:20][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:20][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:20][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:20][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:29][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:29][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:29][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:29][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:29][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:30][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:30][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:30][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:30][E][uart_esp8266:167]: Reading from UART timed out at byte 0!
[17:31:30][E][uart_esp8266:167]: Reading from UART timed out at byte 0!

ESP8266 I/O 5V restistant

is the NPN-transistor really needed?
Shouldn't it be possible to connect TX directly to RX without level shifting?
Would make the entire wireing alot easier.

sh: 1: xtensa-lx106-elf-g++: not found

Anybody else getting errors while compiling on esphome 2021.9.3 from HA?

Works fine locally but not through HA. Tried removing the addon and files and reinstalling but no luck.

sh: 1: xtensa-lx106-elf-g++: not found

INFO Reading configuration /config/esphome/p1reader.yaml...
WARNING 'electricity_meter': Using the '_' (underscore) character in the hostname is discouraged as it can cause problems with some DHCP and local name services. For more information, see https://esphome.io/guides/faq.html#why-shouldn-t-i-use-underscores-in-my-device-name
INFO Generating C++ source...
INFO Compiling app...
INFO Running:  platformio run -d /config/esphome/electricity_meter
Processing electricity_meter (board: nodemcu; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
Tool Manager: Installing toolchain-xtensa @ ~2.40802.191122
Tool Manager: Warning! More than one package has been found by toolchain-xtensa @ ~2.40802.191122 requirements:
 - platformio/toolchain-xtensa @ 2.100300.210717
 - mcspr/toolchain-xtensa @ 5.100300.210830
 - tasmota/toolchain-xtensa @ 5.100200.210303
Tool Manager: Please specify detailed REQUIREMENTS using package owner and version (showed above) to avoid name conflicts
Downloading  [####################################]  100%          
Unpacking  [####################################]  100%          
Tool Manager: toolchain-xtensa @ 2.40802.200502 has been installed!
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES: 
 - framework-arduinoespressif8266 3.20704.0 (2.7.4) 
 - tool-esptool 1.413.0 (4.13) 
 - tool-esptoolpy 1.20800.0 (2.8.0) 
 - toolchain-xtensa 2.40802.200502 (4.8.2)
Library Manager: Installing Update
Library Manager: Already installed, built-in library
Dependency Graph
|-- <ESPAsyncTCP-esphome> 1.2.3
|   |-- <ESP8266WiFi> 1.0
|-- <ESPAsyncWebServer-esphome> 1.3.0
|   |-- <ESPAsyncTCP-esphome> 1.2.3
|   |   |-- <ESP8266WiFi> 1.0
|   |-- <Hash> 1.0
|   |-- <ESP8266WiFi> 1.0
|-- <ESP8266WiFi> 1.0
|-- <ESP8266mDNS> 1.2
|   |-- <ESP8266WiFi> 1.0
|-- <noise-c> 0.1.3
|   |-- <libsodium> 1.10018.1
|-- <DNSServer> 1.1.1
|   |-- <ESP8266WiFi> 1.0
Compiling /data/electricity_meter/.pioenvs/electricity_meter/src/esphome/components/api/api_connection.cpp.o
sh: 1: xtensa-lx106-elf-g++: not found
Compiling /data/electricity_meter/.pioenvs/electricity_meter/src/esphome/components/api/api_frame_helper.cpp.o
sh: 1: xtensa-lx106-elf-g++: not found
Compiling /data/electricity_meter/.pioenvs/electricity_meter/src/esphome/components/api/api_pb2.cpp.o
*** [/data/electricity_meter/.pioenvs/electricity_meter/src/esphome/components/api/api_connection.cpp.o] Error 127
sh: 1: xtensa-lx106-elf-g++: not found
Compiling /data/electricity_meter/.pioenvs/electricity_meter/src/esphome/components/api/api_pb2_service.cpp.o
*** [/data/electricity_meter/.pioenvs/electricity_meter/src/esphome/components/api/api_frame_helper.cpp.o] Error 127
*** [/data/electricity_meter/.pioenvs/electricity_meter/src/esphome/components/api/api_pb2.cpp.o] Error 127
sh: 1: xtensa-lx106-elf-g++: not found
*** [/data/electricity_meter/.pioenvs/electricity_meter/src/esphome/components/api/api_pb2_service.cpp.o] Error 127
========================= [FAILED] Took 19.87 seconds =========================

esp-01 only takes 3.3v?

I was wondering if it would be possible to add a description of how to use the esp-01 for this?
It only takes 3.3v but is small enough to fit inside the Kamstrup p1 module.

No signal D1 mini and Landis+Gyr E360

I was reading thru the #4 and they was talking about using a 1K resistor. Did you change anything from the schamatics that is shown here or is it the same. When I'm looking at the signal it looks like I only get around 1V signal from the data pin so was wounding if I need to lowering the resistor from 5V from 4.7K to 1K.

P1 Splitter for two or more devices

Hi

Has anyone tried to use P1 splitter or connect two devices to a single P1 port? I need to connect two devices to my meter. One devices is obviously this esphome reader and another one is a load balancer for EV car charging called "Easee Equalizer".

I have found these P1 splitters which claim to work . Anyone has any experience or know if they will or will not work?

https://www.homewizard.com/shop/active-p1-splitter/
https://webshop.cedel.nl/P1-Kabel-Splitter#
https://www.bol.com/nl/nl/p/p1-splitter-voor-laadpalen/9300000021044239/#modal_open

Would rather build myself one but cannot find any working DIY solution.

Issue compiling

I get the following when installing, i get 1 device and no entities.
Wired with the custom PCB and a wemos d1 mini.
Running ESPHome 2021.10.3

`INFO Reading configuration /config/esphome/p1-reader.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing p1-reader (board: nodemcu; framework: arduino; platform: platformio/espressif8266 @ 2.6.3)

HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
Dependency Graph
|-- 1.2.3
| |-- 1.0
|-- 2.0.0
| |-- 1.2.3
| | |-- 1.0
| |-- 1.0
| |-- 1.0
|-- 1.0
|-- 1.2
| |-- 1.0
|-- 0.1.4
| |-- 1.10018.1
|-- 1.1.1
| |-- 1.0
Compiling /data/p1-reader/.pioenvs/p1-reader/src/main.cpp.o
Compiling /data/p1-reader/.pioenvs/p1-reader/lib67b/ESP8266WiFi/WiFiClientSecureBearSSL.cpp.o
Compiling /data/p1-reader/.pioenvs/p1-reader/lib67b/ESP8266WiFi/WiFiServer.cpp.o
Compiling /data/p1-reader/.pioenvs/p1-reader/lib67b/ESP8266WiFi/WiFiServerSecureAxTLS.cpp.o
In file included from src/main.cpp:53:0:
src/p1reader.h:97:3: error: stray '\302' in program

<title>esphome-p1reader/p1reader.h at main · psvanstrom/esphome-p1reader · GitHub</title> ^ src/p1reader.h:97:3: error: stray '\267' in program src/p1reader.h:97:3: error: stray '\302' in program src/p1reader.h:97:3: error: stray '\267' in program In file included from src/main.cpp:53:0: src/p1reader.h:366:10: warning: missing terminating ' character [enabled by default] ^ src/p1reader.h:366:5: error: missing terminating ' character ^ src/p1reader.h:423:7: error: stray '\342' in program ^ src/p1reader.h:423:7: error: stray '\206' in program src/p1reader.h:423:7: error: stray '\265' in program src/p1reader.h:428:7: error: stray '\342' in program ^ src/p1reader.h:428:7: error: stray '\206' in program src/p1reader.h:428:7: error: stray '\265' in program src/p1reader.h:470:7: error: stray '\342' in program ^ src/p1reader.h:470:7: error: stray '\206' in program src/p1reader.h:470:7: error: stray '\265' in program src/p1reader.h:475:7: error: stray '\342' in program ^ src/p1reader.h:475:7: error: stray '\206' in program src/p1reader.h:475:7: error: stray '\265' in program src/p1reader.h:508:7: error: stray '\342' in program ^ src/p1reader.h:508:7: error: stray '\206' in program src/p1reader.h:508:7: error: stray '\265' in program src/p1reader.h:513:7: error: stray '\342' in program ^ src/p1reader.h:513:7: error: stray '\206' in program src/p1reader.h:513:7: error: stray '\265' in program src/p1reader.h:546:7: error: stray '\342' in program ^ src/p1reader.h:546:7: error: stray '\206' in program src/p1reader.h:546:7: error: stray '\265' in program src/p1reader.h:551:7: error: stray '\342' in program ^ src/p1reader.h:551:7: error: stray '\206' in program src/p1reader.h:551:7: error: stray '\265' in program In file included from src/main.cpp:53:0: src/p1reader.h:950:25: warning: missing terminating " character [enabled by default] data-action=" ^ src/p1reader.h:950:13: error: missing terminating " character data-action=" ^ src/p1reader.h:951:41: error: stray '#' in program input-entered:ref-selector#inputEntered ^ src/p1reader.h:952:40: error: stray '#' in program tab-selected:ref-selector#tabSelected ^ src/p1reader.h:953:38: error: stray '#' in program focus-list:ref-selector#focusFirstListMember ^ src/p1reader.h:954:13: warning: missing terminating " character [enabled by default] " ^ src/p1reader.h:954:13: error: missing terminating " character src/p1reader.h:973:80: warning: missing terminating ' character [enabled by default] ^ src/p1reader.h:973:13: error: missing terminating ' character ^ src/p1reader.h:1002:25: warning: missing terminating " character [enabled by default] data-action=" ^ src/p1reader.h:1002:13: error: missing terminating " character data-action=" ^ src/p1reader.h:1003:41: error: stray '#' in program input-entered:ref-selector#inputEntered ^ src/p1reader.h:1004:40: error: stray '#' in program tab-selected:ref-selector#tabSelected ^ src/p1reader.h:1005:38: error: stray '#' in program focus-list:ref-selector#focusFirstListMember ^ src/p1reader.h:1006:13: warning: missing terminating " character [enabled by default] " ^ src/p1reader.h:1006:13: error: missing terminating " character In file included from src/main.cpp:53:0: src/p1reader.h:1380:72: error: stray '#' in program #include "esphome.h" ^ src/p1reader.h:1389:72: error: stray '#' in program #define BUF_SIZE 50 ^ src/p1reader.h:1868:207: error: too many decimal points in number if (strncmp(obisCode, "1.8.0", 5) == 0) { ^ src/p1reader.h:1881:240: error: too many decimal points in number } else if (strncmp(obisCode, "2.8.0", 5) == 0) { ^ src/p1reader.h:1894:240: error: too many decimal points in number } else if (strncmp(obisCode, "3.8.0", 5) == 0) { ^ src/p1reader.h:1907:240: error: too many decimal points in number } else if (strncmp(obisCode, "4.8.0", 5) == 0) { ^ src/p1reader.h:1920:240: error: too many decimal points in number } else if (strncmp(obisCode, "1.7.0", 5) == 0) { ^ src/p1reader.h:1933:240: error: too many decimal points in number } else if (strncmp(obisCode, "2.7.0", 5) == 0) { ^ src/p1reader.h:1946:240: error: too many decimal points in number } else if (strncmp(obisCode, "3.7.0", 5) == 0) { ^ src/p1reader.h:1959:240: error: too many decimal points in number } else if (strncmp(obisCode, "4.7.0", 5) == 0) { ^ src/p1reader.h:1972:240: error: too many decimal points in number } else if (strncmp(obisCode, "21.7.0", 6) == 0) { ^ src/p1reader.h:1985:240: error: too many decimal points in number } else if (strncmp(obisCode, "22.7.0", 6) == 0) { ^ src/p1reader.h:1998:240: error: too many decimal points in number } else if (strncmp(obisCode, "41.7.0", 6) == 0) { ^ src/p1reader.h:2011:240: error: too many decimal points in number } else if (strncmp(obisCode, "42.7.0", 6) == 0) { ^ src/p1reader.h:2024:240: error: too many decimal points in number } else if (strncmp(obisCode, "61.7.0", 6) == 0) { ^ src/p1reader.h:2037:240: error: too many decimal points in number } else if (strncmp(obisCode, "62.7.0", 6) == 0) { ^ src/p1reader.h:2050:240: error: too many decimal points in number } else if (strncmp(obisCode, "23.7.0", 6) == 0) { ^ src/p1reader.h:2063:240: error: too many decimal points in number } else if (strncmp(obisCode, "24.7.0", 6) == 0) { ^ src/p1reader.h:2076:240: error: too many decimal points in number } else if (strncmp(obisCode, "43.7.0", 6) == 0) { ^ src/p1reader.h:2089:240: error: too many decimal points in number } else if (strncmp(obisCode, "44.7.0", 6) == 0) { ^ src/p1reader.h:2102:240: error: too many decimal points in number } else if (strncmp(obisCode, "63.7.0", 6) == 0) { ^ src/p1reader.h:2115:240: error: too many decimal points in number } else if (strncmp(obisCode, "64.7.0", 6) == 0) { ^ src/p1reader.h:2128:240: error: too many decimal points in number } else if (strncmp(obisCode, "32.7.0", 6) == 0) { ^ src/p1reader.h:2141:240: error: too many decimal points in number } else if (strncmp(obisCode, "52.7.0", 6) == 0) { ^ src/p1reader.h:2154:240: error: too many decimal points in number } else if (strncmp(obisCode, "72.7.0", 6) == 0) { ^ src/p1reader.h:2167:240: error: too many decimal points in number } else if (strncmp(obisCode, "31.7.0", 6) == 0) { ^ src/p1reader.h:2180:240: error: too many decimal points in number } else if (strncmp(obisCode, "51.7.0", 6) == 0) { ^ src/p1reader.h:2193:240: error: too many decimal points in number } else if (strncmp(obisCode, "71.7.0", 6) == 0) { ^ src/p1reader.h:2415:209: error: stray '#' in program int len = Serial.readBytesUntil('\n', buffer, BUF_SIZE); ^ src/p1reader.h:2415:11: error: stray '\' in program int len = Serial.readBytesUntil('\n', buffer, BUF_SIZE); ^ src/p1reader.h:2415:272: error: stray '#' in program int len = Serial.readBytesUntil('\n', buffer, BUF_SIZE); ^ src/p1reader.h:2441:140: error: stray '#' in program buffer[len] = '\n'; ^ src/p1reader.h:2441:11: error: stray '\' in program buffer[len] = '\n'; ^ src/p1reader.h:2441:203: error: stray '#' in program buffer[len] = '\n'; ^ src/p1reader.h:2445:171: error: stray '#' in program buffer[len + 1] = '\0'; ^ src/p1reader.h:2445:11: error: stray '\' in program buffer[len + 1] = '\0'; ^ src/p1reader.h:2445:234: error: stray '#' in program buffer[len + 1] = '\0'; ^ src/p1reader.h:2458:196: error: stray '#' in program if (buffer[0] == '!') { ^ src/p1reader.h:2458:230: error: stray '#' in program if (buffer[0] == '!') { ^ In file included from src/main.cpp:53:0: src/p1reader.h:2520:198: error: stray '#' in program if (strchr(buffer, '(') != NULL) { ^ src/p1reader.h:2520:232: error: stray '#' in program if (strchr(buffer, '(') != NULL) { ^ In file included from src/main.cpp:53:0: src/p1reader.h:2672:12: warning: missing terminating ' character [enabled by default] ^ src/p1reader.h:2672:7: error: missing terminating ' character ^ In file included from src/main.cpp:53:0: src/p1reader.h:2738:5: error: stray '\342' in program You can’t perform that action at this time. ^ src/p1reader.h:2738:5: error: stray '\200' in program src/p1reader.h:2738:5: error: stray '\231' in program Compiling /data/p1-reader/.pioenvs/p1-reader/lib67b/ESP8266WiFi/WiFiServerSecureBearSSL.cpp.o Compiling /data/p1-reader/.pioenvs/p1-reader/lib67b/ESP8266WiFi/WiFiUdp.cpp.o In file included from src/main.cpp:53:0: src/p1reader.h:7:1: error: expected unqualified-id before '<' token ^ In file included from src/main.cpp:53:0: src/p1reader.h:223:27: error: 'up' does not name a type Sign up ^ src/p1reader.h:262:270: error: expected unqualified-id before '<' token Features ^ src/p1reader.h:266:248: error: expected unqualified-id before '<' token
  • Mobile
  • ^ src/p1reader.h:267:259: error: expected unqualified-id before '<' token
  • Actions
  • ^ src/p1reader.h:268:265: error: expected unqualified-id before '<' token
  • Codespaces
  • ^ src/p1reader.h:269:261: error: expected unqualified-id before '<' token
  • Packages
  • ^ src/p1reader.h:270:261: error: expected unqualified-id before '<' token
  • Security
  • ^ src/p1reader.h:271:268: error: expected unqualified-id before '<' token
  • Code review
  • ^ src/p1reader.h:272:258: error: expected unqualified-id before '<' token
  • Issues
  • ^ src/p1reader.h:273:269: error: expected unqualified-id before '<' token
  • Integrations
  • ^ src/p1reader.h:279:318: error: expected unqualified-id before '<' token
  • GitHub Sponsors
  • ^ src/p1reader.h:280:334: error: expected unqualified-id before '<' token
  • Customer stories
  • ^ src/p1reader.h:303:302: error: expected unqualified-id before '<' token
  • Explore GitHub
  • ^ src/p1reader.h:308:294: error: expected unqualified-id before '<' token
  • Topics
  • ^ src/p1reader.h:309:311: error: expected unqualified-id before '<' token
  • Collections
  • ^ src/p1reader.h:310:300: error: expected unqualified-id before '<' token
  • Trending
  • ^ src/p1reader.h:311:322: error: expected unqualified-id before '<' token
  • Learning Lab
  • ^ src/p1reader.h:312:335: error: expected unqualified-id before '<' token
  • Open source guides
  • ^ src/p1reader.h:317:274: error: expected unqualified-id before '<' token
  • The ReadME Project
  • ^ src/p1reader.h:318:312: error: expected unqualified-id before '<' token
  • Events
  • ^ src/p1reader.h:319:329: error: expected unqualified-id before '<' token
  • Community forum
  • ^ src/p1reader.h:320:335: error: expected unqualified-id before '<' token
  • GitHub Education
  • ^ src/p1reader.h:321:344: error: expected unqualified-id before '<' token
  • GitHub Stars program
  • ^ src/p1reader.h:341:265: error: expected unqualified-id before '<' token Plans ^ src/p1reader.h:344:328: error: expected unqualified-id before '<' token
  • Compare plans
  • ^ src/p1reader.h:345:338: error: expected unqualified-id before '<' token
  • Contact Sales
  • ^ src/p1reader.h:349:338: error: expected unqualified-id before '<' token
  • Education
  • ^ *** [/data/p1-reader/.pioenvs/p1-reader/src/main.cpp.o] Error 1 ========================= [FAILED] Took 22.21 seconds =========================`

    corrupt data?

    I am getting this error from Log

    data
    Aidon electricity meters.........

    Data not published, CRC error

    I am using Landis E360 meter and see that the data is coming but not published in HASS. I see in the logs that CRC checksum is failing.

    [19:01:21][D][data:259]: Program Started
    [19:01:21][D][data:263]: Read 24 bytes from UART
    [19:01:21][D][data:293]: [22.7.0]: 0000.000 kW
    [19:01:21][D][data:263]: Read 24 bytes from UART
    [19:01:21][D][data:293]: [41.7.0]: 0001.019 kW
    [19:01:21][D][data:263]: Read 24 bytes from UART
    [19:01:21][D][data:293]: [42.7.0]: 0000.000 kW
    [19:01:21][D][data:263]: Read 24 bytes from UART
    [19:01:21][D][data:293]: [61.7.0]: 0001.110 kW
    [19:01:21][D][data:263]: Read 24 bytes from UART
    [19:01:21][D][data:293]: [62.7.0]: 0000.000 kW
    [19:01:21][D][data:263]: Read 26 bytes from UART
    [19:01:21][D][data:293]: [23.7.0]: 0000.210 kVAr
    [19:01:21][D][data:263]: Read 26 bytes from UART
    [19:01:21][D][data:293]: [24.7.0]: 0000.000 kVAr
    [19:01:21][D][data:263]: Read 26 bytes from UART
    [19:01:21][D][data:293]: [43.7.0]: 0000.200 kVAr
    [19:01:21][D][data:263]: Read 26 bytes from UART
    [19:01:21][D][data:293]: [44.7.0]: 0000.000 kVAr
    [19:01:21][D][data:263]: Read 26 bytes from UART
    [19:01:21][D][data:293]: [63.7.0]: 0000.274 kVAr
    [19:01:21][D][data:263]: Read 26 bytes from UART
    [19:01:21][D][data:293]: [64.7.0]: 0000.000 kVAr
    [19:01:21][D][data:263]: Read 20 bytes from UART
    [19:01:21][D][data:293]: [32.7.0]: 235.9 V
    [19:01:21][D][data:263]: Read 20 bytes from UART
    [19:01:21][D][data:293]: [52.7.0]: 238.9 V
    [19:01:21][D][data:263]: Read 20 bytes from UART
    [19:01:21][D][data:293]: [72.7.0]: 240.2 V
    [19:01:21][D][data:263]: Read 20 bytes from UART
    [19:01:21][D][data:293]: [31.7.0]: 004.7 A
    [19:01:21][D][data:263]: Read 20 bytes from UART
    [19:01:21][D][data:293]: [51.7.0]: 004.3 A
    [19:01:21][D][data:263]: Read 20 bytes from UART
    [19:01:21][D][data:293]: [71.7.0]: 004.7 A
    [19:01:21][D][data:263]: Read 6 bytes from UART
    [19:01:21][D][crc:275]: CRC: 1490 = ADF2. PASS = NO

    Sometimes I see this in the logs

    [19:01:11][V][app:081]: A component took a long time in a loop() cycle (0.30 s).
    [19:01:11][V][app:082]: Components should block for at most 20-30ms in loop().

    And this as well but it is discusses in issue #3

    [19:00:52][E][uart_esp8266:167]: Reading from UART timed out at byte 0!

    Any ide what could be wrong. Perhaps checksum is calculated differently on E360?

    I use short cable like 8cm from the port to the board and it is a shielded cable with shield on the ground so the data loss due to is should not be a cause.

    Vattenfall S34U18 (Sanxing SX631) change

    For the S23U18 model (Sanxing SX631) that Vattenfall is distributing now you have to increase the buffer slightly.
    I tried with #define BUF_SIZE 60 and it seems sufficent.

    Hungarian Sanxing SX631 Read issue

    I tried to use this ESPHome P1 reader on Wemos D1 mini, unfortunately it does not parse the serial communication.

    This is what I got on Serial port (originally I was able to capture it with Tasmota)

    "0-0:17.0.0(90.000*kW)\r"
    
    "1-0:1.8.0(001540.369*kWh)\r"
    
    "1-0:1.8.1(000695.519*kWh)\r"
    
    "1-0:1.8.2(000844.850*kWh)\r"
    
    "1-0:1.8.3(000000.000*kWh)\r"
    
    "1-0:1.8.4(000000.000*kWh)\r"
    
    "1-0:2.8.0(005431.496*kWh)\r"
    
    "1-0:2.8.1(003888.665*kWh)\r"
    
    "1-0:2.8.2(001542.831*kWh)\r"
    
    "1-0:2.8.3(000000.000*kWh)\r"
    
    "1-0:2.8.4(000000.000*kWh)\r"
    
    "1-0:3.8.0(000274.046*kvarh)\r"
    
    "1-0:4.8.0(000732.779*kvarh)\r"
    
    "1-0:5.8.0(000154.115*kvarh)\r"
    
    "1-0:6.8.0(000119.931*kvarh)\r"
    
    "1-0:7.8.0(000248.954*kvarh)\r"
    
    "1-0:8.8.0(000483.825*kvarh)\r"
    
    "1-0:15.8.0(006971.872*kWh)\r"
    
    "1-0:32.7.0(234.0*V)\r"
    
    "1-0:52.7.0(232.4*V)\r"
    
    "1-0:72.7.0(229.9*V)\r"
    
    "1-0:31.7.0(000*A)\r"
    
    "1-0:51.7.0(000*A)\r"
    
    "1-0:71.7.0(000*A)\r"
    
    "1-0:13.7.0(0.992)\r"
    
    "1-0:33.7.0(0.781)\r"
    
    "1-0:53.7.0(0.989)\r"
    
    "1-0:73.7.0(0.646)\r"
    
    "1-0:14.7.0(50.02*Hz)\r"
    
    "1-0:1.7.0(00.000*kW)\r"
    
    "1-0:2.7.0(00.256*kW)\r"
    
    "1-0:5.7.0(00.000*kvar)\r"
    
    "1-0:6.7.0(00.051*kvar)\r"
    
    "1-0:7.7.0(00.083*kvar)\r"
    
    "1-0:8.7.0(00.000*kvar)\r"
    
    "0-0:98.1.0(221001000000S)(001522.200*kWh)(000694.331*kWh)(000827.869*kWh)(005400.112*kWh)(003880.377*kWh)(001519.735*kWh)(000272.325*kvarh)(000722.372*kvarh)(000153.011*kvarh)(000119.314*kvarh)(000246.253*kvarh)(000476.119*kvarh)(006922.318*kWh)(03.968*kW)(03.968*kW)(02.676*kW)(04.960*kW)(04.960*kW)(04.304*kW)\r"
    
    ")\r"
    
    "!75B4\r"
    

    Because of the long string in 0-0:98.1.0 OBIS code on Tasmota I had to apply seriall buffer to 1700. I have tried to add this to configuration but did not recevice correct information.

    uart:
      id: uart_bus
      rx_pin: RX
      rx_buffer_size: 1700
    

    I saw the following in the logs:

    `INFO Reading configuration /config/esphome/p1-esphome.yaml...
    INFO Starting log output from 192.168.0.149 using esphome API
    INFO Successfully connected to 192.168.0.149
    [20:11:24][I][app:102]: ESPHome version 2022.9.4 compiled on Oct 8 2022, 20:05:20
    [20:11:24][C][wifi:502]: WiFi:
    [20:11:24][C][wifi:360]: Local MAC: C8:C9:A3:XX:XX:XX
    [20:11:24][C][wifi:361]: SSID: 'Jtarjanyi-HA'[redacted]
    [20:11:24][C][wifi:362]: IP Address: 192.168.x.x
    [20:11:24][C][wifi:363]: BSSID: D0:6E:DE:5A:3C:50[redacted]
    [20:11:24][C][wifi:365]: Hostname: 'p1-esphome'
    [20:11:24][C][wifi:367]: Signal strength: -77 dB ▂▄▆█
    [20:11:24][C][wifi:371]: Channel: 4
    [20:11:24][C][wifi:372]: Subnet: 255.255.255.0
    [20:11:24][C][wifi:373]: Gateway: 192.168.x.x
    [20:11:24][C][wifi:374]: DNS1: 0.0.0.0
    [20:11:24][C][wifi:375]: DNS2: 0.0.0.0
    [20:11:24][C][logger:275]: Logger:
    [20:11:24][C][logger:276]: Level: DEBUG
    [20:11:24][C][logger:277]: Log Baud Rate: 0
    [20:11:24][C][logger:278]: Hardware UART: UART0
    [20:11:24][C][uart.arduino_esp8266:102]: UART Bus:
    [20:11:24][C][uart.arduino_esp8266:104]: RX Pin: GPIO3
    [20:11:24][C][uart.arduino_esp8266:106]: RX Buffer Size: 1700
    [20:11:24][C][uart.arduino_esp8266:108]: Baud Rate: 115200 baud
    [20:11:24][C][uart.arduino_esp8266:109]: Data Bits: 8
    [20:11:24][C][uart.arduino_esp8266:110]: Parity: NONE
    [20:11:24][C][uart.arduino_esp8266:111]: Stop bits: 1
    [20:11:24][C][uart.arduino_esp8266:113]: Using hardware serial interface.
    [20:11:24][C][captive_portal:088]: Captive Portal:
    [20:11:24][C][mdns:100]: mDNS:
    [20:11:24][C][mdns:101]: Hostname: p1-esphome
    [20:11:24][C][ota:089]: Over-The-Air Updates:
    [20:11:24][C][ota:090]: Address: 192.168.x.x:8266
    [20:11:24][C][ota:093]: Using Password.
    [20:11:24][C][api:138]: API Server:
    [20:11:24][C][api:139]: Address: 192.168.x.x:6053
    [20:11:24][C][api:141]: Using noise encryption: YES

    [20:11:27][D][data:265]: 0-0:98.1.0(221001000000S)(001522.200kWh)(000694.331kWh)(00

    [20:11:27][D][data:265]: 0827.869kWh)(005400.112kWh)(003880.377kWh)(001519.735kWh

    [20:11:27][D][data:265]: )(000272.325kvarh)(000722.372kvarh)(000153.011*kvarh)(0001

    [20:11:27][D][data:265]: 19.314kvarh)(000246.253kvarh)(000476.119*kvarh)(006922.318

    [20:11:27][D][data:265]: kWh)(03.968kW)(03.968kW)(02.676kW)(04.960kW)(04.960kW)

    [20:11:27][D][data:265]: 0-0:96.13.0(\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][D][data:265]: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][D][data:265]: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][D][data:265]: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][D][data:265]: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][D][data:265]: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][D][data:265]: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][D][data:265]: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][D][data:265]: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][D][data:265]: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][D][data:265]: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][D][data:265]: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][D][data:265]: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][D][data:265]: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][D][data:265]: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][D][data:265]: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][D][data:265]: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff

    [20:11:27][I][crc:276]: Telegram read. CRC: 4528 = BF59. PASS = NO`

    Any iseda what should I try ?

    No data from Kamstrup Omnipower

    Hi!
    I'm using a Slimelezer+ configured as #45 together with an Kamstrup Omnipower. The Kamstrup Omnipower has new updated firmware and the setting "HAN push list" set to "HAN P1 (värde 2)".

    I get data every 10 second but only this:

    [10:04:56][D][data:265]: /KAM5
    [10:04:57][D][data:265]:
    [10:05:06][D][data:265]: /KAM5
    [10:05:07][D][data:265]:
    [10:05:16][D][data:265]: /KAM5
    [10:05:17][D][data:265]:
    

    Is it something I can change to debug this? Or can it be a bug in the firmware of the Kamstrup Omnipower?

    Problem compiling for esphome and slimmelezer

    I'm getting this error when compiling in ESPhome using #45 configuration and copying the p1reader.h file to the config directory of esphome:

    INFO Reading configuration /config/esphome/slimmelezer.yaml...
    INFO Generating C++ source...
    INFO Compiling app...
    Processing slimmelezer-se (board: d1_mini; framework: arduino; platform: platformio/espressif8266 @ 3.2.0)

    HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
    LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
    Dependency Graph
    |-- 1.2.3
    |-- 2.1.0
    | |-- 1.2.3
    | |-- 1.0
    | |-- 1.0
    |-- 1.1.1
    |-- 1.0
    |-- 1.2
    |-- 6.18.5
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/api/api_connection.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/api/api_frame_helper.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/api/api_pb2.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/api/api_pb2_service.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/api/api_server.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/api/list_entities.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/api/proto.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/api/subscribe_state.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/api/user_services.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/captive_portal/captive_portal.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/custom/sensor/custom_sensor.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/esp8266/core.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/esp8266/gpio.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/esp8266/preferences.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/json/json_util.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/logger/logger.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/md5/md5.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/mdns/mdns_component.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/mdns/mdns_esp32_arduino.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/mdns/mdns_esp8266.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/mdns/mdns_esp_idf.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/network/util.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/ota/ota_backend_arduino_esp32.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/ota/ota_backend_arduino_esp8266.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/ota/ota_backend_esp_idf.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/ota/ota_component.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/sensor/automation.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/sensor/filter.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/sensor/sensor.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/socket/bsd_sockets_impl.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/socket/lwip_raw_tcp_impl.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/socket/socket.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/uart/uart.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/uart/uart_component.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/uart/uart_component_esp32_arduino.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/uart/uart_component_esp8266.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/uart/uart_component_esp_idf.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/uart/uart_debugger.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/web_server/list_entities.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/web_server/web_server.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/web_server_base/web_server_base.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/wifi/wifi_component.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/wifi/wifi_component_esp32_arduino.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/wifi/wifi_component_esp8266.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/components/wifi/wifi_component_esp_idf.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/core/application.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/core/color.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/core/component.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/core/component_iterator.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/core/controller.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/core/entity_base.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/core/helpers.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/core/log.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/core/scheduler.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/esphome/core/util.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/src/main.cpp.o
    Generating LD script /data/slimmelezer-se/.pioenvs/slimmelezer-se/ld/local.eagle.app.v6.common.ld
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/lib975/ESPAsyncTCP-esphome/AsyncPrinter.cpp.o
    Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/lib975/ESPAsyncTCP-esphome/ESPAsyncTCP.cpp.o
    In file included from src/main.cpp:56:
    src/p1reader.h:419:10: warning: missing terminating ' character
    419 |


    | ^
    src/p1reader.h:419:10: error: missing terminating ' character
    419 |
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/p1reader.h:476:75: error: extended character ↵ is not valid in an identifier
    476 |
    | ^
    src/p1reader.h:481:56: error: extended character ↵ is not valid in an identifier
    481 |
    | ^
    src/p1reader.h:523:75: error: extended character ↵ is not valid in an identifier
    523 |
    | ^
    src/p1reader.h:528:56: error: extended character ↵ is not valid in an identifier
    528 |
    | ^
    src/p1reader.h:561:75: error: extended character ↵ is not valid in an identifier
    561 |
    | ^
    src/p1reader.h:566:56: error: extended character ↵ is not valid in an identifier
    566 |
    | ^
    src/p1reader.h:599:75: error: extended character ↵ is not valid in an identifier
    599 |
    | ^
    src/p1reader.h:604:56: error: extended character ↵ is not valid in an identifier
    604 |
    | ^
    In file included from src/main.cpp:56:
    src/p1reader.h:989:25: warning: missing terminating " character
    989 | data-action="
    | ^
    src/p1reader.h:989:25: error: missing terminating " character
    src/p1reader.h:990:41: error: stray '#' in program
    990 | input-entered:ref-selector#inputEntered
    | ^
    src/p1reader.h:991:40: error: stray '#' in program
    991 | tab-selected:ref-selector#tabSelected
    | ^
    src/p1reader.h:992:38: error: stray '#' in program
    992 | focus-list:ref-selector#focusFirstListMember
    | ^
    src/p1reader.h:993:13: warning: missing terminating " character
    993 | "
    | ^
    src/p1reader.h:993:13: error: missing terminating " character
    src/p1reader.h:1040:25: warning: missing terminating " character
    1040 | data-action="
    | ^
    src/p1reader.h:1040:25: error: missing terminating " character
    src/p1reader.h:1041:41: error: stray '#' in program
    1041 | input-entered:ref-selector#inputEntered
    | ^
    src/p1reader.h:1042:40: error: stray '#' in program
    1042 | tab-selected:ref-selector#tabSelected
    | ^
    src/p1reader.h:1043:38: error: stray '#' in program
    1043 | focus-list:ref-selector#focusFirstListMember
    | ^
    src/p1reader.h:1044:13: warning: missing terminating " character
    1044 | "
    | ^
    src/p1reader.h:1044:13: error: missing terminating " character
    In file included from src/main.cpp:56:
    src/p1reader.h:1451:72: error: stray '#' in program
    1451 | #include "esphome.h"
    | ^
    src/p1reader.h:1460:72: error: stray '#' in program
    1460 | #define BUF_SIZE 60
    | ^
    src/p1reader.h:1939:207: error: too many decimal points in number
    1939 | if (strncmp(obisCode, "1.8.0", 5) == 0) {
    | ^~~~~
    src/p1reader.h:1952:240: error: too many decimal points in number
    1952 | } else if (strncmp(obisCode, "2.8.0", 5) == 0) {
    | ^~~~~
    src/p1reader.h:1965:240: error: too many decimal points in number
    1965 | } else if (strncmp(obisCode, "3.8.0", 5) == 0) {
    | ^~~~~
    src/p1reader.h:1978:240: error: too many decimal points in number
    1978 | } else if (strncmp(obisCode, "4.8.0", 5) == 0) {
    | ^~~~~
    src/p1reader.h:1991:240: error: too many decimal points in number
    1991 | } else if (strncmp(obisCode, "1.7.0", 5) == 0) {
    | ^~~~~
    src/p1reader.h:2004:240: error: too many decimal points in number
    2004 | } else if (strncmp(obisCode, "2.7.0", 5) == 0) {
    | ^~~~~
    src/p1reader.h:2017:240: error: too many decimal points in number
    2017 | } else if (strncmp(obisCode, "3.7.0", 5) == 0) {
    | ^~~~~
    src/p1reader.h:2030:240: error: too many decimal points in number
    2030 | } else if (strncmp(obisCode, "4.7.0", 5) == 0) {
    | ^~~~~
    src/p1reader.h:2043:240: error: too many decimal points in number
    2043 | } else if (strncmp(obisCode, "21.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2056:240: error: too many decimal points in number
    2056 | } else if (strncmp(obisCode, "22.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2069:240: error: too many decimal points in number
    2069 | } else if (strncmp(obisCode, "41.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2082:240: error: too many decimal points in number
    2082 | } else if (strncmp(obisCode, "42.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2095:240: error: too many decimal points in number
    2095 | } else if (strncmp(obisCode, "61.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2108:240: error: too many decimal points in number
    2108 | } else if (strncmp(obisCode, "62.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2121:240: error: too many decimal points in number
    2121 | } else if (strncmp(obisCode, "23.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2134:240: error: too many decimal points in number
    2134 | } else if (strncmp(obisCode, "24.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2147:240: error: too many decimal points in number
    2147 | } else if (strncmp(obisCode, "43.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2160:240: error: too many decimal points in number
    2160 | } else if (strncmp(obisCode, "44.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2173:240: error: too many decimal points in number
    2173 | } else if (strncmp(obisCode, "63.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2186:240: error: too many decimal points in number
    2186 | } else if (strncmp(obisCode, "64.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2199:240: error: too many decimal points in number
    2199 | } else if (strncmp(obisCode, "32.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2212:240: error: too many decimal points in number
    2212 | } else if (strncmp(obisCode, "52.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2225:240: error: too many decimal points in number
    2225 | } else if (strncmp(obisCode, "72.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2238:240: error: too many decimal points in number
    2238 | } else if (strncmp(obisCode, "31.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2251:240: error: too many decimal points in number
    2251 | } else if (strncmp(obisCode, "51.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2264:240: error: too many decimal points in number
    2264 | } else if (strncmp(obisCode, "71.7.0", 6) == 0) {
    | ^~~~~~
    src/p1reader.h:2486:209: error: stray '#' in program
    2486 | int len = Serial.readBytesUntil('\n', buffer, BUF_SIZE);
    | ^
    src/p1reader.h:2486:241: error: stray '' in program
    2486 | int len = Serial.readBytesUntil('\n', buffer, BUF_SIZE);
    | ^
    src/p1reader.h:2486:272: error: stray '#' in program
    2486 | int len = Serial.readBytesUntil('\n', buffer, BUF_SIZE);
    | ^
    src/p1reader.h:2512:140: error: stray '#' in program
    2512 | buffer[len] = '\n';
    | ^
    src/p1reader.h:2512:172: error: stray '' in program
    2512 | buffer[len] = '\n';
    | ^
    src/p1reader.h:2512:203: error: stray '#' in program
    2512 | buffer[len] = '\n';
    | ^
    src/p1reader.h:2516:171: error: stray '#' in program
    2516 | buffer[len + 1] = '\0';
    | ^
    src/p1reader.h:2516:203: error: stray '' in program
    2516 | buffer[len + 1] = '\0';
    | ^
    src/p1reader.h:2516:234: error: stray '#' in program
    2516 | buffer[len + 1] = '\0';
    | ^
    src/p1reader.h:2529:196: error: stray '#' in program
    2529 | if (buffer[0] == '!') {
    | ^
    src/p1reader.h:2529:230: error: stray '#' in program
    2529 | if (buffer[0] == '!') {
    | ^
    In file included from src/main.cpp:56:
    src/p1reader.h:2591:198: error: stray '#' in program
    2591 | if (strchr(buffer, '(') != NULL) {
    | ^
    src/p1reader.h:2591:232: error: stray '#' in program
    2591 | if (strchr(buffer, '(') != NULL) {
    | ^
    In file included from src/main.cpp:56:
    src/p1reader.h:2743:12: warning: missing terminating ' character
    2743 |
    | ^
    src/p1reader.h:2743:12: error: missing terminating ' character
    2743 |
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/p1reader.h:2768:13: warning: character constant too long for its type
    2768 |

    Footer


    | ^~~~~~~~~
    In file included from src/main.cpp:56:
    src/p1reader.h:2783:21: warning: character constant too long for its type
    2783 |
    | ^~~~~~~~
    src/p1reader.h:2784:17: warning: character constant too long for its type
    2784 |
    | ^~~~~~~~~
    src/p1reader.h:2784:30: warning: character constant too long for its type
    2784 |
    | ^~~~~~~~~~~~~~~~~~~
    In file included from src/main.cpp:56:
    src/p1reader.h:2785:132: warning: character constant too long for its type
    2785 |

      | ^~~~~~~~~~~~~~~~~~~
      In file included from src/main.cpp:56:
      src/p1reader.h:2818:9: error: extended character ’ is not valid in an identifier
      2818 | You can’t perform that action at this time.
      | ^
      Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/lib975/ESPAsyncTCP-esphome/ESPAsyncTCPbuffer.cpp.o
      Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/lib975/ESPAsyncTCP-esphome/SyncClient.cpp.o
      Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/lib975/ESPAsyncTCP-esphome/tcp_axtls.c.o
      Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/libaf0/Hash/Hash.cpp.o
      Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/lib67b/ESP8266WiFi/BearSSLHelpers.cpp.o
      Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/lib67b/ESP8266WiFi/CertStoreBearSSL.cpp.o
      Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/lib67b/ESP8266WiFi/ESP8266WiFi.cpp.o
      Archiving /data/slimmelezer-se/.pioenvs/slimmelezer-se/libaf0/libHash.a
      Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/lib67b/ESP8266WiFi/ESP8266WiFiAP.cpp.o
      In file included from src/main.cpp:56:
      src/p1reader.h:8:1: error: expected unqualified-id before '<' token
      8 |
      | ^
      In file included from src/main.cpp:56:
      src/p1reader.h:187:25: error: 'up' does not name a type; did you mean 'u8'?
      187 | Sign up
      | ^~
      | u8
      src/p1reader.h:663:25: error: expected unqualified-id before '<' token
      663 |
      {{ message }}

      | ^
      In file included from src/main.cpp:56:
      src/p1reader.h:1026:97: error: expected unqualified-id before '<' token
      1026 | {{ refName }}
      | ^
      src/p1reader.h:1066:97: error: expected unqualified-id before '<' token
      1066 | {{ refName }}
      | ^
      In file included from src/main.cpp:56:
      src/p1reader.h:1160:61: error: expected unqualified-id before '<' token
      1160 |
       

      | ^
      src/p1reader.h:1164:56: error: expected unqualified-id before '<' token
      1164 |
       

      | ^
      In file included from src/main.cpp:56:
      src/p1reader.h:1451:153: error: expected unqualified-id before '<' token
      1451 | #include "esphome.h"
      | ^
      src/p1reader.h:1451:196: error: expected unqualified-id before '<' token
      1451 | #include "esphome.h"
      | ^
      src/p1reader.h:1645:74: error: expected unqualified-id before '<' token
      1645 | };
      | ^
      In file included from src/main.cpp:56:
      src/p1reader.h:2701:75: error: expected unqualified-id before '<' token
      2701 | };
      | ^
      In file included from src/main.cpp:56:
      src/p1reader.h:2778:16: error: expected unqualified-id before numeric constant
      2778 | © 2022 GitHub, Inc.
      | ^~~~
      Archiving /data/slimmelezer-se/.pioenvs/slimmelezer-se/lib975/libESPAsyncTCP-esphome.a
      Compiling /data/slimmelezer-se/.pioenvs/slimmelezer-se/lib67b/ESP8266WiFi/ESP8266WiFiGeneric.cpp.o
      *** [/data/slimmelezer-se/.pioenvs/slimmelezer-se/src/main.cpp.o] Error 1
      ========================= [FAILED] Took 40.18 seconds =========================

    Compile Error with esp-idf Framework

    Compiling p1reader for a SeeedStudio XIAO ESP32C3 with the "esp-idf" framework fails.

    I recently got a Wemos D1 device up and running fine with your p1eader. Very nice... But I want a device with external antenna, so I wanted to try to make this work with a XIAO ESP32C3.
    I got this error when compiling using the "esp-idf" framework. I first tried to compile with the default arduino framework, but it it doesn't seem to support the UART component for ESP32C3.

    I get the following error when compiling: (log file attached)

    In file included from src/main.cpp:54:
    src/p1reader.h: In member function 'void P1Reader::readP1Message()':
    src/p1reader.h:262:21: error: 'Serial' was not declared in this scope
               int len = Serial.readBytesUntil('\n', buffer, BUF_SIZE);
                         ^~~~~~
    src/p1reader.h:262:21: note: suggested alternative: 'erfl'
               int len = Serial.readBytesUntil('\n', buffer, BUF_SIZE);
                         ^~~~~~
    

    The essential parts of my config: (yaml file attached)

    esphome:
      name: ${device_name}
      includes:
        - p1reader.h    
    esp32:
      board: esp32-c3-devkitm-1
      variant: esp32c3
      framework:
        type: esp-idf
    
    uart:
      id: uart_bus
      baud_rate: 115200
      rx_pin:
        number: 20  # GPIO20, D7, RX
        inverted: true
    

    I'm running this with ESPhome "stand alone", without Home Assistant on a Debian 11 system. My Home Assistant is running on a raspberry Pi 3b+, and it has issues with incompatible compiler for ESP32C3 in the "esp-idf" framework (riscv32-esp-elf-gcc -- broken)

    Compiling with just the UART component but without p1reader.h, works fine.

    log-esp32c3-p1reader_esp-idf.txt
    elmataren_yaml.txt

    Investigate failsafe for incrementing sensors

    Yesterday i discovered a peak of ~3500kwh during one hour.
    It turns out that the sensor value received or parsed in to home assistant was 0 and then the following state was ~3500kwh from the cumulative active import sensor. This caused the strange error of the usage data in electricity sensor in home assistant.
    Needed to clean up and fix values in states and statistics table in home assistant to correct the problem.

    Check if failsafe can be added i.e. do not send sensor value if it is null or 0 to avoid this error.

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. 📊📈🎉

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google ❤️ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.