npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-red-contrib-serial-modbus-energiam

v0.2.1

Published

Node-RED node para Modbus RTU sobre RS485 con soporte de control manual de RTS para adaptadores half-duplex que lo requieren

Readme


Por qué existe este nodo

node-red-contrib-modbus (el paquete más usado) y el node-red-contrib-serial-modbus original no exponen ninguna forma de controlar la línea RTS del puerto serie. Muchos adaptadores USB-RS485 half-duplex (sin auto-detección de dirección) necesitan RTS forzado en alto para habilitar su transmisor — sin esto, el maestro nunca llega a poner nada en el bus físico, aunque el puerto abra sin ningún error y todo parezca configurado bien.

Esto se confirmó de forma empírica contra hardware real (adaptador USB-RS485 basado en FTDI + ESP32 corriendo Modbus RTU esclavo) antes de escribir este nodo: con RTS en su estado por defecto, cero bytes llegaban al esclavo; forzándolo en alto, la comunicación funcionó de inmediato.

Fork de node-red-contrib-serial-modbus (originalmente de IBM Corp., mantenido por tyrrellsystems / leifnel), con dependencias actualizadas y esta opción agregada.

Instalación

Desde el gestor de paletas de Node-RED (menú → Manage palette → Install), buscar node-red-contrib-serial-modbus-energiam. O por línea de comandos:

cd ~/.node-red
npm install node-red-contrib-serial-modbus-energiam

Reiniciar Node-RED después de instalar.

Nodos incluidos

| Nodo | E/S | Uso | |---|---|---| | Modbus-Serial In | solo salida | Poll automático a intervalo fijo de una lista de esclavos | | Modbus-Serial Out | solo entrada | Escribe en el esclavo en cada mensaje recibido | | Modbus-Serial Request | entrada y salida | Cada mensaje que llega dispara una lectura o escritura puntual y devuelve el resultado por la salida |

Los tres comparten un nodo de configuración modbusSerialConfig (puerto, baudrate, data/parity/stop bits, y el checkbox Forzar RTS).

Ejemplo funcionando: Modbus-Serial Request

Flujo mínimo inject → Modbus-Serial Request → debug, probado contra un esclavo Modbus RTU real (medidor de energía por PZEM-004T detrás de un ESP32), leyendo 6 holding registers desde la dirección 1:

[inyectar] → [Modbus-Serial Request] → [debug]

Payload del inject (tipo JSON):

{
  "unitid": 30,
  "fc": 3,
  "address": 1,
  "quantity": 6
}

Salida real obtenida (msg.payload, array de 6 valores):

[21420, 0, 0, 0, 0, 5000]

En este caso: voltaje = 214.20 V, frecuencia = 50.00 Hz (los registros vienen multiplicados x100 desde el firmware del esclavo).

Flow JSON para importar

Copiar, y en Node-RED: menú → Import → pegar.

[
    {
        "id": "46961f40413ba442",
        "type": "inject",
        "z": "",
        "name": "",
        "props": [ { "p": "payload" } ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"unitid\":30,\"fc\":3,\"address\":1,\"quantity\":6}",
        "payloadType": "json",
        "x": 210,
        "y": 280,
        "wires": [ [ "644a0d806285d0c6" ] ]
    },
    {
        "id": "644a0d806285d0c6",
        "type": "modbusSerial request",
        "z": "",
        "name": "",
        "port": "",
        "x": 460,
        "y": 280,
        "wires": [ [ "debug-node" ] ]
    },
    {
        "id": "debug-node",
        "type": "debug",
        "z": "",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 730,
        "y": 280,
        "wires": []
    }
]

Nota: hay que asignarle el nodo modbusSerialConfig correspondiente al nodo Modbus-Serial Request después de importar (puerto serie, baudrate, y Forzar RTS si tu adaptador lo necesita).

msg.payload de entrada (Modbus-Serial Request)

Lectura:

{ "unitid": 30, "fc": 3, "address": 1, "quantity": 6 }

Escritura (un valor o un array):

{ "unitid": 30, "fc": 6, "address": 1, "value": 123 }

fc (function code):

| fc | Operación | |----|-----------| | 1 | Read Coils | | 2 | Read Discrete Inputs | | 3 | Read Holding Registers | | 4 | Read Input Registers | | 5 / 15 | Write Coil(s) | | 6 / 16 | Write Holding Register(s) |

Licencia

Apache-2.0 (heredada del proyecto original — ver LICENSE).