Simplest implementation of micropython-mqtt

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
Posts: 26
Joined: Fri Feb 14, 2020 4:02 pm

Simplest implementation of micropython-mqtt

Post by doceave » Mon Jun 01, 2020 9:34 pm

Hi there All (and PeterH)

Please assist me with an idiot's guide to implementing MQTT using your uasyncio compatible library:(

All I need is an implementation that satisfies the following:
> Callable function that publishes a string to a topic
> The function should only attempt to connect to broker when called (internet connection is intermittent and the function will only be called when there is connectivity)
> Async routines should be able to easily pass strings for publication to the function
> The function may be asked to send as many as 5 strings, of 40 characters each, per second
- Intermittently

Thanks as always.

User avatar
Posts: 4242
Joined: Fri Jul 18, 2014 8:01 am
Location: UK

Re: Simplest implementation of micropython-mqtt

Post by pythoncoder » Tue Jun 02, 2020 5:57 am

It is not really possible to detect internet connectivity at runtime. The only way you could do this would be by aggressively pinging the broker, which would probably make you unpopular. But even then, an outage might occur between receiving the ping response and your acting on it.

I'm not sure why you'd want to do this. With my library simply publish, if an outage occurs it will be handled automatically with the message being sent when connectivity resumes.

As for performance this is highly variable and impossible to quantify. It depends on the quality of your internet connection and the performance of the broker (which may vary as its workload varies). MQTT with a remote broker is not particularly fast.
Peter Hinch

Post Reply