Hi everyone, I’m a research student exploring ways to add low-cost, flexible sensor nodes (using ESP32 or similar microcontrollers) to an industrial control setup. I found this guide https://www.theengineeringprojects.com/2021/11/esp32-mqtt.html showing how an ESP32 can publish sensor data over MQTT, and it got me wondering whether it’s practical to feed that data into an Opto 22 controller or I/O module for logging or control. I’ve seen Arduino and Raspberry Pi communities where people stream sensor data into cloud dashboards or simple local UIs, but rarely see examples where this is integrated with industrial-grade I/O hardware like Opto 22. Has anyone here tried bridging ESP32-based sensor data to an Opto controller (via MQTT, serial, or other) and if so, what communication method and wiring/schema worked best for you?
Welcome to the forums!
A good solution would be to use a Python script running through SSH, but a quicker, easier setup would be to use Node-RED. It may not be as robust, but for a few data points with sensible scan rates it would do the trick.
I’ve used quite a few ESP32’s and found with an Opto22 controller it’s easier to use tcp modbus. Especially if you don’t have an Epic controller. There’s tons of code examples setting up an ESP32 with a modbus slave. I use the first register as an identifier so I know which board is connected since I don’t have fixed IP addresses on the ESP32’s. You can also setup a routine to scan all IP addresses if connection is lost if the ESP32 uses DHCP to connect to the router. Use the identifier in the first register to run a routine to pull the values and put them in the right table.
@tjcrusher great idea with modbus tcp directly to PAC controller!
I agree with @torchard that Node-RED may be the simplest set up.
I would also add that using Node-RED comes with other advantages like database connections and, if you don’t need the sensor value in your control logic, ability to send sensor data directly to the groovVIEW (HMI/UI).
If go with MQTT it will give you scalability and topic namespaces could provide context for wireless sensors dynamically.