MQTT protocol on ESP32

ESP32 can run server on it. so we need to write server program that would run on ESP32. There are two device in HTTP communication one we call server and other we call client. client send request to server and server reply to client on the given request. HTTP is designed for serving web pages from a single server to multiple clients. How MQTT is different then HTTP ?

MQTT needs a server that will not run on an ESP32. I use a Raspberry Pi 4 as my MQTT Broker as a central communications hub for 13 ESP32's.

1 Like

To get some introduction to both protocols visit: https://www.electromaker.io/blog/article/http-vs-mqtt.

Got it, you made Pi 4 as MQTT Broker and 13 ESP32's. as MQTT client

There are many server, can you tell me which server you are running on Pi 4, Which language you are using C/ C++/ Python ?

On the RPi I am running the Eclipse MQTT Broker. I am using Python for MQTT, web site communications, FTP, and Image processing.

Node-Red could be used instead of Python.

1 Like

let's consider the case where you have Pi and ESP32. one LED is connected to Pi and one switch button is connected to input of ESP32. server is running on PI, HTTP protocaol

I don't think we can control LED connected to PI , pressing button connected to ESP32. because I think we can only send data from client to server. We can't read data from server.

Can we send / receive data from client to server with MQTT protocaol or we can only send the data to server ?

MQTT is two way or more. In this particular case, your ESP can send a message to MQTT and the Pi can subscribe to your topic, pick up the message and act on it to control the led.

Eclipse Paho | The Eclipse Foundation

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