ESP32 nodes and nodered flow

Hi guys!
I'm new to node-red, still trying to understand if it could do the job

Let's assume 5-6-7 ESP32/ESP8266 nodes. (still not sure about the firmware)
I need something to "orchestrate" them, based on events across multiple nodes, in example (just a stupid and complex example):

IF (node1.temperature1 >= 25 AND node2.relay1 = ON AND node3.uptime <= 3600) THEN
   node4.relay4 = ON
   SLEEP 0.5
   node4.relay4 = OFF
ENDIF

very stupid example, to power on the relay#4 on node#4 for 0.5 seconds IF node1#temperature#1 is greater or equal 25°C AND node#2 relay#2 is powered on AND node#3 is booted from less than 1 hour.

Can I make some rules/flow like this and then communicate them to each involved nodes ?
If not, any altenrative ?

I have a similar setup with multiple NodeMCU's. If I can I try to avoid building my own sketch (but sometimes you have to) and just flash them with Tasmota.

The relays and sensors can be easily configured and are often automatically recognized. If you configure a MQTT broker in Tasmota you will see a variety of messages and within NodeRED you can use the received temp readings to control outputs.

For the MQTT with Tasmota look at https://tasmota.github.io/docs/MQTT/
If you want to know how to control the relays and read the sensors https://tasmota.github.io/docs/Commands/
And if you want to learn more about the different components you can connect https://tasmota.github.io/docs/Components/

Thank you for the response.
So, by flashing tasmota on each device and setting the node red as mqtt broker, node red is able to get the "state" of the MCU's pool and intereact with them ?

So, I think that node red is getting the mcu state and each flow is set to node red that will react based on the configuration, like ? In other words, it's node-red that trigger a power on / power off the state to a tasmota device, based on the flow. if node-red server is down, nothing happens.

Well, almost. You will have to install a MQTT Broker (eg. Mosquitto) and both the NodeMCU's running Tasmota and NodeRED will interact with the broker to exchange messages.

The Tasmota devices will publish information to the broker (for example the temperature of a connected sensor) and subscribe to a command topic.

NodeRED will receive the temp readings by subscribing to the topic published by the Tasmota device and control relays by sending command messages to the command Topic the Tasmota device has subscribed to.

In NodeRED you can build logic that evaluates temp reading and controls the relays.

Hope this helps.

If you need something more generic than Tasmota, but still ready-to-use, I can also recommend ESPeasy.

3 Likes

Tying ESP8266/ESP32 devices together with an MQTT broker and node-red to read/process/control the devices is quite a usual approach. I do this too. It is the centralised approach where the network and the central need to work, else all fails.

Since I'm an old guy, I try to put the intelligence at the edge of the network.
This means that I program the esp8266 devices with enough intelligence to handle simple automation on its own. I.e. A device which handles a fan subscribes to the temperature values and then acts according built in logic. But this requires specific code for each device. Since it is a hobby and it is fun, I'm going down that road.
But you might want to use the central approach, even use openHAB or something like that.

2 Likes

I am adding MQTT support to my current ESP image that I wrote to control mosfet based switches. I use a small prototype board to power on and off my PCs, toggle the reset switch as well. This gives simple PCs some remote hardware control like commercial servers support via IPMI, HP iLO, Dell iDRAC, etc. ESP modules are powered by the PC PS as well, what else are those extra internal USB ports for anyway. :).

1 Like

That's actual a nice idea. I might adopt that some time. :nerd_face:

Pretty straight forward, NodeMCU (ESP8266), two breakout mofset boards, and just the code to drive the pins on the NodeMCU to control the breakout boards.

image

I use one for power on/off, and one for reset button. Current version uses REST API so any browser on my local network can reset, power on and off the given PC. You have to use 4 y-cables for the PC motherboard connectors, so the physical switches on the case work still, but that is easy. Because you are using switches, isolation is a given between PC and NodeMCU if the wiring is done right.

There are other ways to do this, with creating a complete circuit to drive the solution direct from the GPIO pins but that is not safe, unless you use opto isolation or other methods to protect each respective device.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.