Hi,
I made some changes on the example code used at ‘MQTT Project – MQTT Client ESP32 #1’
I’m trying to use QOS 1 or 2 to make sure the ESP32 will get the message when it loses connection and comes back online again but it’s not working.
I have Mosquitto installed and working correctly on the Raspberry PI. When I send the command below via SSH it is successfully received on ESP 32:
mosquitto_pub -h 192.168.50.92 -p 1883 -t ‘client0001/machines/dryer004′ -m ’12’ -q 1
If I hold down the ESP32 reset button and send the above command via SSH it is not received when the ESP32 reconnects. What might I be missing? Could be something related with chipID? If yes how to set it?
Hi,
I found the solution. You have to add:
mqttClient.setCleanSession(false);
Below mqttClient.setServer(MQTT_HOST, MQTT_PORT); and use qos 1 or 2 to subscribe