What is the MQQT?
MQTT is a standards-based messaging protocol, or set of rules, used for machine-to-machine communication. Smart sensors, wearables, and other Internet of Things (IoT) devices typically have to transmit and receive data over a resource-constrained network with limited bandwidth (aws.amazon.com).
It works by having a broker managing all the messages coming to it. It receives them and then sends them to the clients assigned to it. To send messages to the broker we need to define which topic the clients are subscribed to. We can set up this when we create the connection to the broker. We can do this connection using the terminal to download mosquitto and then use it to send messages to the broker as long as we have the IP of the service, and we set up the user, password and message.
Using the ESP32 wifi to connect to MQTTTo reveive the messages (and see them) we can use the ESP32 microcontroller wifi feature to connect to the broker through a serial port, in this was we can receive the messages in the Arduino IDE serial monitor.
For the test I used this protocol, for multiple digital slave to communicate with the master. It is for short distances communications.
So for the test i'm using a Barduino acting as the master in an I2C communication with a slave device, in this case my PCBoard with a phototransistor. So is to requesting data from the slave device and control an analog output based on the data that is receiving.
When open arduino, keep in mind to change the serial configuration to "ONE_UART_ONE_WIRE_NO_SPI" this means ne one-wire interface