MQTT tutorial on Raspberry pi, Arduino and Python

preview_player
Показать описание
Arduino tutorial about the MQTT communication protocol between machines m2m.

Brief overview about mqtt.

Download and install Mosquitto on a raspberry pi:
Command lines:

sudo -i

apt-get update

apt-get install mosquitto

Python code is in the arduino sketch.

command line
to see all the published topics and text:
mosquitto_sub -v -t "#"
to see a specific topic like "ledStatus":
mosquitto_sub -h 192.168.0.106 -i testLED -t ledStatus //repace the ip address with your broker IP.
to publish a new message to a topic (ledStatus):
mosquitto_pub -h 192.168.0.106 -t ledStatus -m "0" // replace IP with your broker IP

install the python mqtt library paho-mqtt on Raspberry pi:

pip install paho-mqtt

Link to install mosquitto on Windows:
Рекомендации по теме
Комментарии
Автор

Thank you so much for explaining MQTT you are the first one to show commands in MQTT and explain what it does and how it works this is so helpful for a new person like me to MQTT, top marks

MrBobWareham
Автор

When you explain it like this, it all becomes clear.
Another great tutorial, thanks!

vanamstel_nl
Автор

Thanks for taking the time to make this video. It was easy to follow and i really appreciated the sketch for the Wemos mini. I was able to load everything onto my Windows machine and as a added bonus, get your sketch working with Node-Red. Awesome:)

davejack
Автор

Thank you very much for your clear explanation ... not as thousand of Internet pages ..which write too many .. but not useful.

hosamssandid
Автор

Any help on this subject is a great help so thank you

dgb
Автор

how can i get the data displayed in the terminal to save it to a data file? a .csv file for example?

fabricekouame
Автор

I'm missing the code in the Arduino where it connects to the broker.
In addition, I have tried the broker on the Arduino since I have an esp8266 so I can host a server on the arduino way easier.
30 hours of trial and error, and I still can't send a variable from a pi to an arduino.


How do I get this to work? Because following these exact steps, nothing is happening in the serial nor to the LED. I run the python code in the pi at boot.

StepwaveMusic
Автор

Geweldig mate, thanks heaps for this video, love the accent. ;-)

janschuijling
Автор

Hello, nice tutorial. But I have a problem: when I try to send a message on the topic I get an error saying: No connection could be made because the target machine actively refused it ". I opened 2 cmds on the computer and it works like that. Any ideas what's the problem?

did
Автор

Hi I would like to know how to start with the Raspberry pi and Cloud computing. Any leads will be useful.

reachavinandan
Автор

if i using ethernet shield, how i connect to MQTT? can u give me the coding for arduino using ehternet shield..

limwuising
Автор

Hi, How to find the IP address of the RPi you used in the code? I have connected RPIB+ board connected to my Windows Laptop through ethernet cable and laptop's Wifi is shared with thies ethernet. And I want to send MQTT message to RPI. On windows, my Laptop IP is 192.168.0.164, and raspberry pi IP is 192.168.137.51 (which is detected using Advanced IP Scanner i.e. against raspberrypi.mshome.net). In Arduino code, when i use 192.168.137.51, the connection is not established. Can you please guide me how did you find the IP of the RPi? Regards

sajjadhussain
Автор

Hi Moss,
what a great project! It works properly.
I would like to setup a MQTT project with one ESP32 as a subscriber and another ESP32 as publisher. The broker should be a RasPi standalone as Broker-Server creating its own WLAN without connection to the Internet via Router or Access Point.
Can you give me hints how to do this?
The handling of the ESP32 should be easy. But with the RasPi I have got my problems to combine the installed Mosquitto and the WLAN-Server capabilities.
Do you have this setup described in one of your courses? (Please without NodeRed.)
Thanks!
Oli

os-channel
Автор

Hi Mos, awesome topic. I will try these in next time. But I am afraid that these is to difficult for me as a noob. First impression is that there are no version for Windows 10. Would be great if you can made an addition video with your experience. Hope you continue your lessons. Thanks for these perfect video

uweri_
Автор

Hello friend, Greetings from colombia, which version of mosquitto you are using and you get to get the error rc = -2 from the lib pubsubclient.h

aliriohernandez
Автор

Hello,
So the Arduino code is being uploaded to the ESP8266? Is it necessary to use the PC running Mosquitto as well? Or was that was Pub/Sub demonstration?

Thank You

priyankadookie
Автор

where in the video did you install the broker??

hammershigh
Автор

Great video!
I am working on same project, i use a android app to publish a topic through cloud and it is recieved on raspberrypi through mosquitto, now as soon as i recieve msg on my pi i want to turn on my led, how is it posiible?

thecreditcardrewards
Автор

Could anyone help me with controlling the gpios of a rpi zero w? I have set mosquitto up on the broker as well as the rpi zero w client and i can receive messages. But i don't know how to handle them, or how to simply connect to the topic and switch the gpio states based on the incoming message. Would be nice if anyone could help :)

PaYtrIxHD
Автор

Nice guide, but you should look at security, as that are important.

AndersJackson