Skip to content

Latest commit

 

History

History
64 lines (55 loc) · 2.12 KB

README.md

File metadata and controls

64 lines (55 loc) · 2.12 KB

An ESP32 Modbus Mqtt bridge to node red.

platform platform

Purpose

To the works like 'modbus-flex-getter' and 'modbus-flex-write' of https://flows.nodered.org/node/node-red-contrib-modbus. Which then enables us to read multiple devices over the internet (or local network), without multiple PC's or raspberry pi's. eg:

device <-> modbus <-> ESP32 <-> Mqtt-Broker <-> a 'node red' able device (PC, Rpi, ...)
device <-> modbus <-> ESP32 <│
device <-> modbus <-> ESP32 <|

node red 'modbus-flex-getter' and 'modbus-flex-write'

We use mqtt for the modbus-flex-getter and modbus-flex-write.

Node-red modbus-flex-getter and modbus-flex-write Screenshot Node-red modbus-flex-getter and modbus-flex-write Screenshot Node-red code

Status of project

In test development phase.

works:

  • FC 1: Read Coil Status (untested)
  • FC 2: Read Input Status (untested)
  • FC 3: Read Holding Registers
  • FC 4: Read Input Registers
  • FC 5: Force Single Coil (untested)
  • FC 6: Preset Single Register
  • FC 15: Force Multiple Coils (untested)
  • FC 16: Preset Multiple Registers

To build

At Visual Studio Code, SDK Configuration editor of ESP-IDF SDK mod:

App Configuration

  • Broker URL (eg.:"mqtt://username:password@server_ip:server_port")
  • slave read/write request mqtt
  • slave read/write response mqtt
  • status mqtt

Example Connection Configuration

  • WiFi SSID
  • WiFi Password
  • WiFi Scan auth mode threshold

Modbus configuration

  • Modbus RTU or ASCII or TCP

If Modbus RTU or ASCII

  • UART port number
  • UART RXD pin number
  • UART TXD pin number
  • UART RTS pin number
  • UART communication speed

Else if Modbus TCP

  • Modbus TCP port number
  • slave ip address

Note

Data format out

  • Int16 payload.data and values *see b65c10e ("Fix modbus data integer type", 2022-10-07)
  • Int8 payload.buffer
  • Float32 payload.floatdata