EmsTechLabs Logo EmsTechLabs

Esp32 Example Modbus Register 5: Name today battery discharge

Technical documentation for Modbus register 5 on Esp32 Example. Data type: U WORD. Includes Python and YAML configuration examples.

January 16, 2026 3 read

Technical Definition

The register name today battery discharge at address 5 is used to monitor name today battery discharge on the Esp32 Example.

  • Protocol: Modbus RTU
  • Data Type: U WORD
  • Unit: kWh
  • Access: Read Only

How to Read (Python pymodbus)

Use this code snippet to read this specific value via RS485:

from pymodbus.client.sync import ModbusSerialClient

client = ModbusSerialClient(method='rtu', port='/dev/ttyUSB0', baudrate=9600)
client.connect()

# Read name today battery discharge (Address: 5)
# Note: Check if your device uses 0-based or 1-based addressing
result = client.read_input_registers(address=5, count=2, unit=1)

if not result.isError():
    print(f"Raw Value: {result.registers}")
else:
    print("Error reading register")

client.close()

Integration (Home Assistant)

Paste this into your configuration.yaml:

- platform: modbus_controller
  name: "name today battery discharge"
  address: 5
  value_type: U_WORD
  unit_of_measurement: "kWh"

Connection Diagram

Here is the standard RS485 wiring for this configuration:

graph TD
    PLC[Host Controller / Home Assistant]
    Device[Esp32 Example]

    PLC -- "A+ (D+)" --> Device
    PLC -- "B- (D-)" --> Device
    PLC -- GND --> Device


💡 Engineer's Insight

Analysis: Shows the total energy drawn from the battery for discharge purposes today, typically in Wh or kWh.

Troubleshooting: Zero could indicate no discharge events, low battery protection active, or a discharge circuit fault.