How to publish a disconnected client to another mqtt client (ESP32 - Arduino)
How to publish a disconnected client to another mqtt client (ESP32 - Arduino)
I have a ESP32, a mosquitto server and a Android phone with Linear MQTT Dashboard installed. The thing is: I need to advice the phone about the state of the ESP32 specifically when is disconnected, I'm using the PubSubClient library.
Any help?
Any help?
Re: How to publish a disconnected client to another mqtt client (ESP32 - Arduino)
An ESP32 can publish message on MQTT. These can be received by an MQTT broker which in turn can make them available to an MQTT subscriber. If the messages contain ESP32 status, then that will result in status information being supplied to the MQTT subscriber.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
-
- Posts: 90
- Joined: Sun Jul 02, 2017 3:38 am
Re: How to publish a disconnected client to another mqtt client (ESP32 - Arduino)
If you're running your own MQTT server, for instance, mosquitto on Linux, you could write a script which publishes when a specific client hasn't published in a while.
Re: How to publish a disconnected client to another mqtt client (ESP32 - Arduino)
Hey there Neil and tele_player!
Thanks for the quick replies and answers!
Thanks for the quick replies and answers!
-
- Posts: 90
- Joined: Sun Jul 02, 2017 3:38 am
Re: How to publish a disconnected client to another mqtt client (ESP32 - Arduino)
I haven't tried to do this, but I expect this could be done using a shell script, mosquitto_pub and mosquitto_sub, or a python script.
Re: How to publish a disconnected client to another mqtt client (ESP32 - Arduino)
@Pyscho,
lets see if we can clarify some of your needs.
You said:
You have a mosquitto server. For others, this is an MQTT open source server. On what platform is the mosquitto server running?
You have an Android phone. Got that.
You have something called "Linear MQTT Dashboard" installed. Don't know what that is... but I'll assume its an MQTT client capable of receiving messages from an MQTT broker.
Now we get into the crux of the story. If I am understanding, you need to have the ESP32 post periodic MQTT messages on a topic which will then be delivered to Mosquitto server. An MQTT client that happens to be running on your Android phone will receive them.
Then you said "about the state of the ESP32 specifically when is disconnected".
In that statement ... when "what" is disconnected and disconnected from what?
Can you also paint some back story on the design/plan of why this function is needed. Putting it in context can commonly help.
In addition, can you answer whether this is a work project, a personal project or a school assignment?
lets see if we can clarify some of your needs.
You said:
You have an ESP32. Got that.I have a ESP32, a mosquitto server and a Android phone with Linear MQTT Dashboard installed. The thing is: I need to advice the phone about the state of the ESP32 specifically when is disconnected, I'm using the PubSubClient library.
You have a mosquitto server. For others, this is an MQTT open source server. On what platform is the mosquitto server running?
You have an Android phone. Got that.
You have something called "Linear MQTT Dashboard" installed. Don't know what that is... but I'll assume its an MQTT client capable of receiving messages from an MQTT broker.
Now we get into the crux of the story. If I am understanding, you need to have the ESP32 post periodic MQTT messages on a topic which will then be delivered to Mosquitto server. An MQTT client that happens to be running on your Android phone will receive them.
Then you said "about the state of the ESP32 specifically when is disconnected".
In that statement ... when "what" is disconnected and disconnected from what?
Can you also paint some back story on the design/plan of why this function is needed. Putting it in context can commonly help.
In addition, can you answer whether this is a work project, a personal project or a school assignment?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: How to publish a disconnected client to another mqtt client (ESP32 - Arduino)
Back story: I'm on a internship, and they need a ESP32 reading constantly the voltage of a battery to get the actual "%" of it , the ESP32 needs to be connected to a MQTT server (Mosquitto in this case) and they need to get notifications on a phone or Gmail (in this case i choose the phone), I have all done, but, they need a notification if the ESP is disconnected of the network or else (example: if was unplugged).
PD: Yes, Linear MQTT Dashboard is a MQTT client on android.
PD: Yes, Linear MQTT Dashboard is a MQTT client on android.
Re: How to publish a disconnected client to another mqtt client (ESP32 - Arduino)
If I am understanding correctly, the ESP32 is producing messages on a regular basis ... but if the ESP32 should be "lost" from the network, then you wont to know that. What about detecting that a message was NOT published by the ESP32 after a period of time when we should have expected the ESP32 to publish a new message? Would that be a sufficient algorithm?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: How to publish a disconnected client to another mqtt client (ESP32 - Arduino)
I think so, but, how do i do that algorithm? *I'm new on programming to*.
-
- Posts: 90
- Joined: Sun Jul 02, 2017 3:38 am
Re: How to publish a disconnected client to another mqtt client (ESP32 - Arduino)
It's simpler than I thought. Google 'mqtt last will'. No additional script needed.
Who is online
Users browsing this forum: No registered users and 123 guests