Alex's Corner - Week 4 - WiPy & Publishing/Subscribing With MQTT
bucknall last edited by bucknall
I will be running the next webinar at 2pm (GMT) Thursday the 13th of April, around the topic of MQTT and the WiPy! This will cover how MQTT works, connecting up to an MQTT Broker and the methodology of publishing/subscribing to topics to get/send your data!
The format will be as following:
- Questions from Community
Please do ask any questions (either here or in the livestream chat) so I can help you out with any issues/problems you're facing!
Visit this link tomorrow on the 13th of April to join in!
@bucknall just posted about sending images over MQTT, perhaps one for another Corner?
RobTuDelft last edited by
Link in Youtube description seems to link to the week 5 forum topic
@PiAir That's correct, I'll make sure that's updated on both the docs & GitHub! Cheers!
@RL-Auroraim You can see an example of subscribe here in the video: https://youtu.be/3NDPSbr5J14?t=12m57s that Alex posted. But it looks like he hasn't pushed that one to github yet? (correct @bucknall ?)
RL-Auroraim last edited by
I would like to have our LoPys interpret incoming subscription messages and execute a corresponding function. How do I go about saving subscribed messages as a string variable for example so I can compare them?
OK great, now publishing temperature readings from my DS18B20 to my Mac via MQTT. However I note that client.connect() returns 0 even though the connection is working..
@robmarkcole I have a lot of problems using hivemq, its often down - maybe try another broker? like mosquitto?
Hmm this working before lunch, what could be going on?
@bucknall MQTT up and running now, thanks!
@robmarkcole it's hosted on YouTube so you can view it back whenever you wish. Regarding downloading it, I'm sure you can but I won't advise tools to do that as I believe it's against YouTube's Ts & Cs...!
Perfect! Is the video available to download?
Links that I mentioned in my the live stream:
robmarkcole last edited by robmarkcole
@bucknall Since I can't attend the demo live, my questions are:
- How to handle authentification - user and password? Also can I keep passwords separate from the main code? Are passwords encrypted over the network?
- Bandwidth - what is max rate I can push readings over MQTT?
- Sleep mode - if I wake from sleep mode are messages that were sent whilst sleeping received?
- The docs mention a bug on line 57, I guess you will cover addressing that https://docs.pycom.io/pycom_esp32/pycom_esp32/tutorial/includes/mqtt.html
- One final question, is it possible to pass a variable into a running python program using MQTT? For instance, could I pass in (via MQTT) the variable which sets how frequently the Wipy takes a measurement?
p.s. if you do a demo, perhaps also use a local MQTT broker on your mac, with mosquitto? Seems the most generic approach to me rather than a cloud service..
p.p.s. for week 5 perhaps you could cover/mention the json library? :-)
bucknall last edited by bucknall
@PiAir Not worried about trying another demo - I might try to set up the gateway with another network such as Loriot in the future or at least try again once TTN is working correctly.
I've pushed the docs updates regarding the LoRaWAN TTN Nano-Gateway code to our docs now so that should be going live next docs update. I'll post an update when it's online.
@bucknall You know I watch them :) but it is during work hours, so joining in live is going to be a bit difficult. They don't mind me playing with the LoPy in the evening or in the weekend, but during the day I'm supposed to do other stuff.
I can totally understand you don't want to try another TTN live demo. :)
@PiAir You're right the MQTT example in the docs doesn't make a whole lot of sense and I'll get around to updating this!
What you've described is exactly how I plan to demo MQTT. I'm not going to use TTN, unfortunately, as I've been testing it today and it's not reliable at the moment...
If you have time, please do join in and comment/ask me questions as I go along! The more questions you ask, the better I can help provide answers to questions!
I use MQTT extensively and the the example in https://docs.pycom.io/pycom_esp32/pycom_esp32/tutorial/includes/mqtt.html#basic-usage-example makes absolutely no sense to someone that doesn't know what MQTT is for (sorry).
I mean, it sends "OFF" and "ON" to an MQTT broker which you can then view in a websocket client (yippie).
So I think I would be useful for the demo to use 1 WiPy with a sensor (a button, a temperature sensor, anything really). This WiPy then sends data to a MQTT server. The second WiPy subscribes to that same topic and has for example a relay that switches on a light, a ventilator (if temp > certain value) etc.
That at least shows the purpose of MQTT (if you explain that a third, forth etc. WiPy can also subscribe to the topic and listen).
Or...have the WiPy subscribe to the MQTT feed of a device on The Things Network so that you have the bridge: LoPy -> LoRaWAN -> Gateway -> TTN -> MQTT -> WiPY -> relay... :)
(provided of course that TTN is up tomorrow when you do the livestream ;-) )
Yep! Exactly the same :) I'll do a quick run down on the differences between the two devices.
You mention WiPy, am I correct in guessing that it will work the same for LoPy?
And if not: can you should/cover the differences? :)