How to Use Modbus and ESPHome to Connect to the SINOTIMER DSS519MR Electric Meter for Usage Monitoring
Share
How to Use Modbus and ESPHome to Connect to the SINOTIMER DSS519MR Electric Meter for Usage Monitoring
In this guide, we'll walk you through how to use Modbus communication and ESPHome to interface with the SINOTIMER DSS519MR Electric Meter. With this setup, you can monitor your power usage and integrate it with your smart home automation system. I'll provide all the necessary steps, code, and some helpful insights to get you started.
What You’ll Need
Before diving into the setup, here’s what you’ll need:
- SINOTIMER DSS519MR Electric Meter
- Modbus Board (This will allow you to communicate between the electric meter and your ESP device.)
- ESP Device (I am using the ESP DEVKIT ESP32.)
- ESPHome (A firmware that allows easy configuration of your smart devices.)
- Wires for Modbus connections
Wiring the Modbus Board to the SINOTIMER DSS519MR
The SINOTIMER DSS519MR Electric Meter communicates using Modbus RTU over RS-485. This requires a Modbus RTU to TTL converter board that will interface with your ESP device.
Wiring Overview
1. Connect the Modbus Board to the SINOTIMER DSS519MR:
-
- A (RS-485 +) to A pin on the meter
- B (RS-485 -) to B pin on the meter
- GND to GND on the meter
2. Connect the Modbus Board to the ESP Device:
-
- TX (Transmit) from the Modbus board to the RX pin on the ESP.
- RX (Receive) from the Modbus board to the TX pin on the ESP.
- VCC to 5V or 3.3V depending on your ESP board.
- GND to GND on the ESP.
(Adjust the wiring as necessary for your Modbus board and ESP device.)
Configuring ESPHome
Now that your hardware is wired up, it’s time to configure ESPHome. If you don’t have ESPHome installed, you can follow their documentation to get it set up.
In your ESPHome configuration file (typically in .yaml
format), you’ll need to configure the Modbus RTU interface and specify the meter’s parameters.
Example ESPHome Configuration:
esphome:
name: dds519mr
friendly_name: electric meter
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "KEY"
ota:
password: "KEY"
wifi:
ssid: WIFI_NAME
password: WIFI_PASSWORD
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Dds519Mr-Eletricmeter"
password: "BACKUP_WIFI_PASSWORD"
captive_portal:
uart:
id: mod_bus
tx_pin: 17
rx_pin: 5
rx_buffer_size: 256
data_bits: 8
parity: "NONE"
stop_bits: 1
baud_rate: 9600
modbus:
#flow_control_pin: 22
id: dds519mr_modbus1
send_wait_time: 250ms
disable_crc: false
modbus_controller:
- id: energymon
address: 0x08
modbus_id: dds519mr_modbus1
update_interval: 15s
sensor:
- platform: modbus_controller
modbus_controller_id: energymon
id: supply_voltage
name: "AC_VOLTAGE"
address: 0x0
unit_of_measurement: "V"
register_type: read
value_type: FP32
accuracy_decimals: 1
- platform: modbus_controller
modbus_controller_id: energymon
id: supply_current
name: "Current"
address: 0x08
unit_of_measurement: "A"
register_type: read
value_type: FP32
accuracy_decimals: 1
- platform: modbus_controller
modbus_controller_id: energymon
id: supply_active_power
name: "Active Power"
address: 0x12
unit_of_measurement: "kWh"
register_type: read
value_type: FP32
accuracy_decimals: 1
- platform: modbus_controller
modbus_controller_id: energymon
id: supply_power_factor
name: "Power Factor"
address: 0x2A
unit_of_measurement: "COS"
register_type: read
value_type: FP32
accuracy_decimals: 1
- platform: modbus_controller
modbus_controller_id: energymon
id: supply_frequency
name: "AC Freqency"
address: 0x36
unit_of_measurement: "Hz"
register_type: read
value_type: FP32
accuracy_decimals: 1
- platform: modbus_controller
modbus_controller_id: energymon
id: supply_total_active_power
name: "Total Active Power"
address: 0x100
unit_of_measurement: "kWh"
register_type: read
value_type: FP32
accuracy_decimals: 1
- platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
name: "WiFi Signal dB"
id: wifi_signal_db
update_interval: 60s
entity_category: "diagnostic"
- platform: copy # Reports the WiFi signal strength in %
source_id: wifi_signal_db
name: "WiFi Signal Percent"
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "Signal %"
entity_category: "diagnostic"
device_class: ""
- platform: uptime
name: Uptime Sensor
entity_category: "diagnostic"
text_sensor:
- platform: wifi_info
ip_address:
name: IP Address
entity_category: "diagnostic"
ssid:
name: SSID
entity_category: "diagnostic"
mac_address:
name: Wifi MAC Address
entity_category: "diagnostic"
dns_address:
name: DNS Address
entity_category: "diagnostic"
web_server:
port: 80
- Modbus UART Configuration:
-
- Make sure the
tx_pin
andrx_pin
are set to match your ESP board’s GPIO pins. - The
baud_rate
is set to9600
, which is commonly used by Modbus devices, but double-check your meter's documentation.
- Make sure the
-
Sensor Configuration:
- The
address
refers to the Modbus register address where the meter’s data is stored. -
count: 2
refers to the number of registers needed to store the value. - The
data_type
ofU_FLOAT
is used to read a floating-point value from the registers.
- The
Testing the Setup
Once you’ve uploaded the configuration to your ESP device, go ahead and restart it. Your ESP device should now be communicating with the SINOTIMER DSS519MR Electric Meter over Modbus, and you should start seeing the usage data reported in the ESPHome dashboard.
If you want to view the data in Home Assistant, you can set up an MQTT integration or use the native API integration to pull the sensor data into your home automation system.
Troubleshooting Tips
- No Data or Incorrect Readings: Double-check the wiring and the Modbus configuration, ensuring the register address and data type are correct.
- Baud Rate Issues: If you’re not getting any data, try adjusting the baud rate to match the settings of your meter.
- Timeouts or Communication Errors: Ensure that the Modbus board is correctly wired and receiving enough power.
Conclusion
With the SINOTIMER DSS519MR Electric Meter and ESPHome, you can easily monitor your power usage in real-time and integrate the data into your smart home setup. Whether you're looking to optimize energy usage or simply keep track of your consumption, this setup provides an efficient solution.
Physical Wiring:
ESPHome WebGui of the Modbus Monitor:
Home Assistant Dashboard: