miketeachman/micropython-adafruit-mqtt-esp8266

Subscribing Format?

wecr3at3 opened this issue · 4 comments

Hi there, it's amazing how convenient it is to publish data using MQTT. Please help me out here as I was trying to subscribe to a topic, a simple push-button actually.

I added an example for Subscribe. See if you can extend the example to work with the push-button,

I tried very hard to publish and subscribe in one single program but it just doesn't work. It hangs every time. At the most what it does is react to either one subscription message or publishes just one message. What is wrong here. Is it not possible to simultaneously PUBLISH and SUBSCRIBE in one microPython script and a single NodeMCU?

I think the problem you are likely seeing is the blocking call to the subscribe, which prevents the Publish from running. It's possible to fix this situation. I added a new example, "pubandsub.py", showing how to use a non-blocking subscription check. Please try this and let me know if it solves your problem. thanks!

Hey Mike! It just works.
You are awesome. Thanks, brother!

I tried to publish a pot's raw 10-bit values and subscribed to a slider widget in the same program that you added previously. It worked flawlessly. Many, many thanks to you and the open-source community.

weCreateUs