Skip to content

ESP32 Modbus edge (WiFi MQTT) ​

Connectivity profile P2 — the ESP32 (or similar) is the Modbus RTU master on RS485. Autoconnecto receives normalized JSON telemetry over MQTT (or HTTP). Use this for WiFi labs, indoor pilots, and panels where a 4G DTU is not required.

Bench test: Pending — pattern is documented; per-Solution firmware maps inherit from device guides (e.g. XY-MD02, AVH) when you test. See Validation status.

This pattern applies to any Solution that lists P2 in its reference stack (Fuel, Water, Climate, Cold chain, etc.). Only the register map and telemetry keys change.


What you are building ​

mermaid
flowchart LR
  AC[Autoconnecto MQTT]
  ESP[ESP32 edge master]
  BUS[RS485]
  SL1[Slave 1]
  SL2[Slave 2]
  AC <-->|TLS 8883| ESP
  ESP --> BUS
  BUS --> SL1
  BUS --> SL2
PieceRole
ESP32 firmwareModbus master, scaling, publish interval
Autoconnecto deviceDevice token; telemetry keys match Solution doc
RS485 transceiverMAX485 / ISO3086 — observe sensor baud and termination

Contrast P1: With DR154 Modbus MQTT, Autoconnecto is Modbus master and the DTU is a serial tunnel only.


Wiring (field) ​

mermaid
flowchart TB
  subgraph Power
    PSU[5V USB or 12V DC supply]
  end
  subgraph ESP32_board
    MCU[ESP32 module]
    UART[UART2]
  end
  subgraph RS485
    XCVR[MAX485]
    A[A line]
    B[B line]
  end
  subgraph Field
    SENS[Modbus sensor or meter]
  end
  PSU --> MCU
  MCU --> UART --> XCVR
  XCVR --> A
  XCVR --> B
  A --- SENS
  B --- SENS
ConnectionNotes
PowerStable 5 V for dev boards; industrial 12–24 V where required by enclosure
RS485 A/BFollow sensor manual polarity; add 120 Ω termination at bus ends if cable length > ~10 m
GroundCommon reference between PSU and field device per manufacturer; avoid ground loops on long runs
WiFiProvision SSID once; store credentials in NVS

Always use the sensor datasheet for terminal labels (some mark A/B, others D+/D-).


Autoconnecto setup ​

  1. Devices → Create device with the Solution device type (e.g. ht_sensor, fuel_tank).
  2. Copy device token from Check connectivity → MQTT.
  3. Firmware publishes JSON telemetry, for example:
json
{
  "temperature": 24.6,
  "humidity": 52
}
  1. Keys must match the Solution reference stack for that fleet.
  2. Optional: create a gateway device and publish with childDeviceId if one ESP32 serves multiple logical devices (developer gateway relay).

Use the Device SDK for TLS MQTT to mqtt.autoconnecto.in:8883.


Firmware outline (Modbus master) ​

  1. Initialize RS485 UART (typical 9600 8N1 — confirm on datasheet).
  2. Poll holding/input registers per slave ID on an interval (e.g. 5–30 s).
  3. Apply scale/offset from manufacturer manual (same as cloud Modbus map would use).
  4. Publish merged JSON to device MQTT topic with device token auth.

For ClimateFleet + XY-MD02, register addresses match the DR154 guide Modbus table — reuse that map in firmware instead of cloud polling.


When to prefer P2 vs P1 ​

Prefer P2 ESP32 WiFiPrefer P1 4G DTU
WiFi on siteCellular only
Local logic / bufferingMinimal edge software
Multiple local algorithmsCloud-owned Modbus schedule

Safety ​

Mains-powered meters and genset panels require qualified electricians. This guide covers low-voltage RS485 sensor wiring only.

support@autoconnecto.in · founder@autoconnecto.in · +91 92121 00555 · app.autoconnecto.in