# Set ESP32 output w/o using MQTT

**URL:** <https://discourse.nodered.org/t/set-esp32-output-w-o-using-mqtt/82242>\
**Category:** General\
**Created:** [21 October 2023 18:27 UTC](https://discourse.nodered.org/t/set-esp32-output-w-o-using-mqtt/82242 "2023-10-21T18:27:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![FlowZone](https://avatars.discourse-cdn.com/v4/letter/f/edb3f5/32.png) [@FlowZone](https://discourse.nodered.org/u/FlowZone)\
**Post date:** [21 October 2023 18:27 UTC](https://discourse.nodered.org/t/set-esp32-output-w-o-using-mqtt/82242/1 "2023-10-21T18:27:13Z")

</div>

I can read ESP32 input port values directly from Node-RED "Poll State" component (connected via Raspberry Pi running Node-RED).

Now I need to set a binary port of the ESP32 to high or low on certain conditions. Everywhere I read, MQTT is mentioned as the way to do that.  
Not familiar with MQTT I am wondering, if it can be true, that setting an output port is that much more complicated that reading an input port of the ESP32. Are there anyone of you, who know of a more “direct way” to access and set ESP32 output ports from Node-RED?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [21 October 2023 19:08 UTC](https://discourse.nodered.org/t/set-esp32-output-w-o-using-mqtt/82242/2 "2023-10-21T19:08:07Z")

</div>

It probably depends on what firmware runs on the ESP: Arduino, Lua, Circuit python, Tasmota, even (a version of) Node-red.

But I don't know any other way than MQTT. That's because I discovered MQTT and it's elegant and simple. No need for anything else.

So my advice is get familiar with MQTT. I doubt if you'll regret the time invested.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 October 2023 19:27 UTC](https://discourse.nodered.org/t/set-esp32-output-w-o-using-mqtt/82242/3 "2023-10-21T19:27:29Z")

</div>

> [@FlowZone](#):
>
> I can read ESP32 input port values directly from Node-RED "Poll State" component

Is that a Home Assistant node? How does that get the input port value from the ESP32? Or to put it another way, how is the node red machine connected to the ESP device?

If you are using HA is there not an HA node for driving the outputs? Few here use HA, preferring to do it all in node-red.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [22 October 2023 07:02 UTC](https://discourse.nodered.org/t/set-esp32-output-w-o-using-mqtt/82242/4 "2023-10-22T07:02:12Z")

</div>

I can only agree with @jbudd, make yourself a big favour and start with MQTT. To make a smooth intro then use ESPHome for your ESP32 and you will get going in short time. ESPHome is low coding for such devices, same idea as Node-RED is for automation and others

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 October 2023 10:42 UTC](https://discourse.nodered.org/t/set-esp32-output-w-o-using-mqtt/82242/5 "2023-10-22T10:42:51Z")

</div>

If you do decide to look at MQTT then this tutorial will tell you everything you need to know. [MQTT Essentials - All Core Concepts Explained](https://www.hivemq.com/mqtt-essentials/)

---

<div class="post-metadata">

**Author:** ![FlowZone](https://avatars.discourse-cdn.com/v4/letter/f/edb3f5/32.png) [@FlowZone](https://discourse.nodered.org/u/FlowZone)\
**Post date:** [22 October 2023 14:24 UTC](https://discourse.nodered.org/t/set-esp32-output-w-o-using-mqtt/82242/6 "2023-10-22T14:24:28Z")

</div>

Thanks, @jbudd I'll invest some time and get to learn MQTT 👍

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 October 2023 14:27 UTC](https://discourse.nodered.org/t/set-esp32-output-w-o-using-mqtt/82242/7 "2023-10-22T14:27:34Z")

</div>

How is the ESP device connected to the node-red machine? What comms protocol is it currently using?

---

<div class="post-metadata">

**Author:** ![FlowZone](https://avatars.discourse-cdn.com/v4/letter/f/edb3f5/32.png) [@FlowZone](https://discourse.nodered.org/u/FlowZone)\
**Post date:** [22 October 2023 14:28 UTC](https://discourse.nodered.org/t/set-esp32-output-w-o-using-mqtt/82242/8 "2023-10-22T14:28:01Z")

</div>

Thanks for your guidance, @krambriw. I will do as proposed.  
The Home Assistant and Node-RED combi I am currently running is very convenient in the sense that it allows for polling input port status "out of the box".  
It appears that there is no way around using MQTT when working with the ESP32’s output ports… 😀

---

<div class="post-metadata">

**Author:** ![FlowZone](https://avatars.discourse-cdn.com/v4/letter/f/edb3f5/32.png) [@FlowZone](https://discourse.nodered.org/u/FlowZone)\
**Post date:** [22 October 2023 14:32 UTC](https://discourse.nodered.org/t/set-esp32-output-w-o-using-mqtt/82242/9 "2023-10-22T14:32:12Z")

</div>

Hi @Colin . Thanks for your guidance. I will check out the tutorial you linked to 🙏  
I have connected the ESP32 to my Home Assistant (running on Raspberry Pi) by using [ESPHome](https://esphome.io/guides/getting_started_hassio). It is a _very_ convenient way to work with ESP32. I can highly recommend this way to work with the EPS32 controller 👍

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [21 December 2023 14:33 UTC](https://discourse.nodered.org/t/set-esp32-output-w-o-using-mqtt/82242/10 "2023-12-21T14:33:09Z")

</div>

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