Skip to content
Back to skills

Esp32 Energy Meter Modbus

ASecurity

Use when an ESP32 reads a Modbus energy meter - SDM120, SDM630, Eastron or similar - and the values are nonsense, swapped, or scaled by 1000. Covers float word order, register tables and polling rates.

  • 16 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 7, 2026
ai-agents

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 7, 2026

npx -y skills add Esmail-sarhadi/esp32-agent-skills --skill esp32-energy-meter-modbus --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Esp32 Energy Meter Modbus?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Esp32 Energy Meter Modbus
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/esmail-sarhadi-esp32-energy-meter-modbus/badge)](https://www.skillsdirectory.com/skills/esmail-sarhadi-esp32-energy-meter-modbus)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: esp32-energy-meter-modbus
description: Use when an ESP32 reads a Modbus energy meter - SDM120, SDM630, Eastron or similar - and the values are nonsense, swapped, or scaled by 1000. Covers float word order, register tables and polling rates.
license: MIT
---

# Reading an energy meter over Modbus

Energy meters are the most common Modbus device in the field and the most common
source of "the voltage reads 230000". The protocol works; the interpretation does
not.

## The float word order trap

Most meters return 32-bit IEEE-754 floats across two holding registers. Vendors
disagree on order:

- **Big-endian (ABCD)**: register N is the high word.
- **Little-endian word-swapped (CDAB)**: register N is the low word.

Reading 230.0 V as 230000 means the words are swapped. Reading it as
3.2e-41 means the byte order inside the word is wrong too. There are four
combinations and only one is right; check against a known value (mains voltage,
or a load you can measure).

## Register tables are per model

| Meter | Voltage | Current | Power | Energy |
|---|---|---|---|---|
| SDM120 | 0x0000 | 0x0006 | 0x000C | 0x0156 |
| SDM630 | 0x0000 | 0x0006 | 0x000C | 0x0156 |

Those are close but not universal. Take the table from the manual of the exact
model and revision, and record it in the reference file with the page number.

## Polling and scaling

- Default serial settings are usually 2400 8N1 with slave address 1. Change them
  deliberately and record it, or the next technician cannot talk to the meter.
- Energy registers are often 0.001 kWh units. A 32-bit float cannot hold a large
  lifetime total precisely; some meters use two registers or a 64-bit integer.
- Poll no faster than the meter updates. 1 Hz is plenty; 10 Hz on a 2400 baud
  line cannot fit the frames anyway.

## Sanity checks in firmware

Reject a reading when voltage is outside 90 to 300 V, current is negative, or the
power factor is outside -1 to 1. A meter that returns 0x7FC00000 is sending NaN,
and printing it as a float gives "nan" in the dashboard for the rest of time.

## Symptom table

| Symptom | Usually |
|---|---|
| voltage reads 230000 | word order |
| all registers read 0 | wrong slave address, or the meter is in a different mode |
| values update every 10 s only | polling faster than the meter's update rate |
| NaN in the dashboard | uninitialised float registers, or a read that timed out |
| CRC errors | 2400 baud with a long cable, no termination |

## Agent rules

- Record the exact model, the register table source page and the word order.
- Add range validation to the parser, not to the dashboard.
- State the polling interval and show that it fits the line rate.

Files in this skill

  • LICENSE.txt857 B
  • SKILL.md2.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.