Comments on: ESP32 MQTT – Publish and Subscribe with Arduino IDE https://randomnerdtutorials.com/esp32-mqtt-publish-subscribe-arduino-ide/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Sun, 16 Feb 2025 19:06:21 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Dr Quark https://randomnerdtutorials.com/esp32-mqtt-publish-subscribe-arduino-ide/#comment-1008407 Sun, 16 Feb 2025 19:06:21 +0000 http://randomnerdtutorials.com/?p=62610#comment-1008407 When using client.publish(topic,payload), it appears that payload can only be UTF-8 characters. Is there a setting that allows binary numerical data or a boolean byte? It appearss that PubSubClient.h only supports mqtt 3.1.1 and payload type might only be available in 5.0.

If the data can’t be “typed,” what’s the best way to send a boolean variable? Then how do you get that boolean to display in a filter node like “switch?”

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-mqtt-publish-subscribe-arduino-ide/#comment-1003789 Thu, 30 Jan 2025 10:24:21 +0000 http://randomnerdtutorials.com/?p=62610#comment-1003789 In reply to Kamyab Tajmiri.

Hi.
To use username and password, pass the client name, username and password to the connect method.

client.connect(“CLIENT_NAME”, “MQTTUSERNAME”, “MQTTPASSWORD”)

Regards,
Sara

]]>
By: Kamyab Tajmiri https://randomnerdtutorials.com/esp32-mqtt-publish-subscribe-arduino-ide/#comment-1003767 Thu, 30 Jan 2025 08:06:52 +0000 http://randomnerdtutorials.com/?p=62610#comment-1003767 hi
Thanks for your great tutorials and examples
I also wanted to suggest that consider a scenario where the mqtt broker has username and password auth required
does it make any change to the Arduino Code?
how should I config that?

]]>
By: Ariel https://randomnerdtutorials.com/esp32-mqtt-publish-subscribe-arduino-ide/#comment-1003610 Wed, 29 Jan 2025 12:42:49 +0000 http://randomnerdtutorials.com/?p=62610#comment-1003610 Hola Sara buen dia, gracias por el tutorial, excelente lo que hacen.

estoy teniendo problemas y no se donde porque mi broker lo estoy corriendo en forma local en debian, funciona porque hago pub y sub a tópicos de prueba desde la terminal y funciona, pero al momento de hacerlo con el esp32 me da que no se puede conectar, probé de todo, reinstale mosquitto sin solución los servicios están en active en mi sistema, no uso pass para el broker, las librerías que tengo instaladas son
#include <WiFi.h>
#include <WiFiClient.h>
#include <PubSubClient.h>
y el error que me arroja de la consola serial de arduino es:
Intentando conexión MQTT…falló, rc=-2 intentando de nuevo en 5 segundos
Podrás orientarme por donde puede venir el problema?

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-mqtt-publish-subscribe-arduino-ide/#comment-1002988 Sun, 26 Jan 2025 19:23:58 +0000 http://randomnerdtutorials.com/?p=62610#comment-1002988 In reply to Kupak51.

Hi.
But, what is exactly the error that you’re facing?
Regards,
Sara

]]>
By: Kupak51 https://randomnerdtutorials.com/esp32-mqtt-publish-subscribe-arduino-ide/#comment-1002971 Sun, 26 Jan 2025 17:33:33 +0000 http://randomnerdtutorials.com/?p=62610#comment-1002971 In reply to Sara Santos.

La respuuesta no es clara, Ustedes son muy buenos haciendo las cosas y explicando. Pero deberia modificar el codigo para que sea correcto, ya que todos fallamos en el mismo error.
The response is not clear, you are very good doing things and explaining.
But it should modify the code to be correct, since we all fail in the same error.

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-mqtt-publish-subscribe-arduino-ide/#comment-950128 Thu, 22 Aug 2024 09:36:58 +0000 http://randomnerdtutorials.com/?p=62610#comment-950128 In reply to Gary Rubin.

Hi.
Thanks for pointing that out.
You’re right. It should be ESP32 Client (this was previously adapted from an ESP8266 project).
To use username and password, pass the client name, username and password to the connect method.

client.connect(“CLIENT_NAME”, “MQTTUSERNAME”, “MQTTPASSWORD”)

Thanks for your comment. I realized we need to update this tutorial asap.

Regards,
Sara

]]>
By: Gary Rubin https://randomnerdtutorials.com/esp32-mqtt-publish-subscribe-arduino-ide/#comment-950007 Thu, 22 Aug 2024 00:09:13 +0000 http://randomnerdtutorials.com/?p=62610#comment-950007 In reply to Sara Santos.

Hi Sara,
I too am having this issue. It would be helpful if this tutorial expands a little to include authentication with a MQTT broker. I searched via google and found GitHub posts with examples that use different approaches, and I am confused at why “ESP8266Client” is used when this is a ESP32 device reaching out. Just saying, thank you!

]]>
By: Simão https://randomnerdtutorials.com/esp32-mqtt-publish-subscribe-arduino-ide/#comment-926820 Mon, 17 Jun 2024 16:20:30 +0000 http://randomnerdtutorials.com/?p=62610#comment-926820 HI
Im doing a project that follows the same structure as this tutorial, with the difference that instead of reading the sensor with the esp32, I am reading (3) dht22 sensors with an Arduino and sending the data via serial communication to the esp32 .
At the time of publication I added a debug message that if the publication was made it would print “Published”, but it is happening that often the 3 “Published” messages appear but there are topics without publications, for example the topic of sensor 1 always receives its data but the other two dont.
Before publishing, I print the data received from the Arduino and all the data from all the sensors are ok.

I can’t find a solution to this problem, do you have any idea what could it be ?

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-mqtt-publish-subscribe-arduino-ide/#comment-922429 Fri, 07 Jun 2024 09:47:24 +0000 http://randomnerdtutorials.com/?p=62610#comment-922429 In reply to Pablo.

Hi.
did you install node-red dashboard? https://randomnerdtutorials.com/getting-started-node-red-dashboard/
Regards,
Sara

]]>