RaspberryPi, MQTT, Mosquitto & Arduino

Here is some examples / sample code for the RaspberryPI / MQTT / Mosquitto / Ardunio.

SSH to your RaspberryPi, with mosquitto installed, if not already running execute the command “sudo mosquitto” to start the broker.

Now your mosquitto server is running, run the command “mosquitto_sub -d -t HomeZoneCH“, what does this do? it subscribes the RaspberriPi to the topic HomeZoneCH

Open a second ssh session to your Pi and run the command “mosquitto_pub -d -t HomeZoneCH -m “CellarLightOff”” you should see the message below.

On the first SSH session you have open you should see the message below appear!

Now with the code runnning on my Arduino after a reset I receive the following message on the first SSH session.

Now I know this is super simple and your asking yourself what value does this have? it’s just a simple demo of the messaging system… I will be sharing all my final code with Webserver, mosquitto interface etc… as soon as I feel it’s ready. I am moving house soon and will not have much time to focus but I hope to have a good update next month regarding my progress

Have a look at some useful links here, here and here

HumpA

  1. Hey there, very informative howto… also . :idea: . dont forget to run the mosquito broker .. by running “sudo mosquitto” or you will get the ominous “connection failed” message!

    cant wait to see your next posting! :wink:

    J

  2. We made the project with its own broker PLC and a bridge between MQTT-S and MQTT systems.
    Work on Windows or Linux + Mono.
    For Example: Raspberry Pi + ArchLinux + Mono.
    As Hardware used: Arduino nano compatible boards plus RFM12 or CC1101 Shield.

    Look at X13home.github.com

    Best Regards

  3. Hi there, thanks for tutorial, but when i start mosquitto on rasPI, im getting an error:
    mosquitto version 1.1.2
    using default config
    opening ipv4 listen socket on port 1883
    error: address already in use
    ?? please advise

Leave a Comment


*


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>