logo elektroda
logo elektroda
X
logo elektroda

Best way to synchronize ESP8266 device status with smartphone app over MQTT?

mtk3d 3363 3
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 15404973
    mtk3d
    Level 10  
    Hello,
    i apologise in advance if my question is trivial and stupid, but I am a beginner in IoT and communications. I want to connect devices running an ESP8266 to the internet, via the MQTT protocol and control it with a smartphone etc. However, I have a small question regarding the status synchronisation of the devices. In the event that a smartphone or other device is outside the local network, I am unable to continuously monitor changes in the status of a device and update the switches in the application. The simplest solution seems to be to send a device status query to the server as soon as the smartphone is connected to the network, and then send the status information from each device to the server. I just wonder if this is really the right solution? It seems to me to be the best one, but I'd like to make sure so that I don't have problems later on with other devices running the same protocol.
    Greetings!
  • ADVERTISEMENT
  • Helpful post
    #2 15540842
    voyo
    Level 12  
    You misunderstand MQTT, it is not about 'querying the server for status', it is about receiving status messages sent by a specific device. The server (broker) only mediates these messages.
    Implement (enable) QoS for MQTT, this will ensure that messages are delivered to devices that subscribe to the topic even if they are connected to the network later than when the message was sent.
    And set up a broker server (use a ready-made service?) somewhere on the Internet, not in the LAN.
  • ADVERTISEMENT
  • #3 15546277
    mtk3d
    Level 10  
    Thanks, that's exactly the kind of QoS I was after. I understand the basics of MQTT, I just phrased the query a bit badly, inaccurately :) . What I meant was that I would fire up the client on the server at the same time and it would check the newly connected devices and send the data again. And I'll fire up the server locally, as I'll have a thin client from HP running 24/7 anyway. It draws fairly little power, and MQTT doesn't require some cosmic bandwidth or high performance. Thanks again.
  • #4 16886976
    czasnagli
    Level 18  
    mtk3d wrote:
    When a smartphone or other device is outside the local network, I am not able to continuously monitor the status change of some device and update the switches in the application.

    In this case, support for 'Retained Messages' should be added.
ADVERTISEMENT