daniel-jong / esp8266_p1meter

DSMR5 P1 meter to mqtt using esp8266
GNU General Public License v3.0
157 stars 55 forks source link

esp8266_p1meter

Software for the ESP2866 that sends P1 smart meter data to an mqtt broker (with OTA firmware updates)

about this fork

This fork (tries) to add support for the Landys and Gyr E360 smartmeter (DSMR5.0)

The original source has issues with DSMR5.0 meters who like to send telegrams every 1 second at a high 115200 baud rate. This causes the used SoftwareSerial to struggle to keep up and thus only receives corrupted messages. This fork switches to using the main Hardware serial port (RX) for communication with the meter.

Getting started

This setup requires:

Compiling up using Arduino IDE:

Compiling up using PlatformIO:

Finishing off:

Connecting to the P1 meter

Connect the esp8266 to an RJ11 cable/connector following the diagram.

Note: when using a 4-pin RJ11 connector (instead of a 6-pin connector), pin 1 and 6 are the pins that are not present, so the first pin is pin 2 and the last pin is pin 5

P1 pin ESP8266 Pin
2 - RTS 3.3v
3 - GND GND
4 -
5 - RXD (data) RX (gpio3)

On most Landys and Gyr models a 10K resistor should be used between the ESP's 3.3v and the p1's DATA (RXD) pin. Many howto's mention RTS requires 5V (VIN) to activate the P1 port, but for me 3V3 suffices.

Wiring

Optional: Powering the esp8266 using your DSMR5+ meter

Expand to see wiring description

When using a 6 pin cable you can use the power source provided by the meter. | P1 pin | ESP8266 Pin | | ---- | ---- | | 1 - 5v out | 5v or Vin | | 2 - RTS | 3.3v | | 3 - GND | GND | | 4 - | | | 5 - RXD (data) | RX (gpio3) | | 6 - GND | GND | ![Wiring powered by meter](https://raw.githubusercontent.com/daniel-jong/esp8266_p1meter/master/assets/esp8266_p1meter_bb_PoweredByMeter.png)

Data Sent

All metrics are send to their own MQTT topic. The software sends out to the following MQTT topics:

sensors/power/p1meter/consumption_low_tarif 2209397
sensors/power/p1meter/consumption_high_tarif 1964962
sensors/power/p1meter/returndelivery_low_tarif 2209397
sensors/power/p1meter/returndelivery_high_tarif 1964962
sensors/power/p1meter/actual_consumption 313
sensors/power/p1meter/actual_returndelivery 0
sensors/power/p1meter/l1_instant_power_usage 313
sensors/power/p1meter/l2_instant_power_usage 0
sensors/power/p1meter/l3_instant_power_usage 0
sensors/power/p1meter/l1_instant_power_current 1000
sensors/power/p1meter/l2_instant_power_current 0
sensors/power/p1meter/l3_instant_power_current 0
sensors/power/p1meter/l1_voltage 233
sensors/power/p1meter/l2_voltage 0
sensors/power/p1meter/l3_voltage 0
sensors/power/p1meter/gas_meter_m3 968922
sensors/power/p1meter/actual_tarif_group 2
sensors/power/p1meter/short_power_outages 3
sensors/power/p1meter/long_power_outages 1
sensors/power/p1meter/short_power_drops 0
sensors/power/p1meter/short_power_peaks 0

Home Assistant Configuration

Use this example for home assistant's sensor.yaml

The automatons are yours to create. And always remember that sending alerts in case of a power outtage only make sense when you own a UPS battery :)

Thanks to

This sketch is mostly copied and pasted from several other projects. Standing on the heads of giants, big thanks and great respect to the writers and/or creators of: