Help with MQTT and Arduino

Here is the background …

All I wanted to do was turn on a sprinkler on the other side of the drive way, and so I discovered Arduino.

Not having done any hobby electronic work for a while, this piqued my interest.

So a breadboard and some modules later I have IDE installed and I can upload scratch files into the Nano and run simple scripts.

From the modules I purchased I built this OK… more than just turning on/off one sprinkler, but I can see where this is going to end up!! And although it’s the other side of the driveway, I will use a standard wireless access point to get to it. Unfortunately I did not purchase any ESP8266, so I will work with what I have got for the moment.

So how to control it Automatically.

Oh dear… look at this Openhab I discovered… Way overkill for what I want to do but, look at all this cool stuff… and I just so happen to have a Raspberrypi 3. And Openhab prebuilt image looks like it will be easy to get it all going. Then I can remote other stuff in the house as well.

SO I get Openhab onto thePi, and I have access to openhabpi.local. I read the docs and can grasp the Items/Bindings/Action/Things concepts. It’s taken me a week and some late nights to get this far.

Now, to get the Openhab to talk to the Arduino. I figured there would be some way in Openhab to make a rule to access a web page, because you can turn on/off a sprinkler easily by issueing a just in a browser.

HELP 1 : Can’t find it !! so just for academic sake (I can see I won’t be satisfied with this one way control), how would you go about that in Openhab?

Another two nights of reading an I see I need Mosquitto. Maybe not right now, but I will need it, so it might as well be now.

Sudo add-apt-repository ppa:mosquitto-dev/mosquitto-ppa gives me a “Colud not find a distribution template for Raspbian/stretch.” Ok, so I go to Github/mqtt. Seems to indicate there that I should be downloading from And so I get mosquitto-1.5.1. When I run the make, the error is “fatal error: openssl/ssl.h: No such File or Directory.”

HELP 2 : How can I get Mosquitto onto the Openhab/RaspberryPi?

HELP 3 : Even with Mosquitto Broker running on the OpenHab/Pi, I still need a client on the Arduino end. Given that the script I already have loaded is limited, any suggestions for something that is “2 way” and has Mqtt??

Sorry this is so long winded. Guess I wanted to show that I just don’t jump on forums asking for help, I do try first, but the frustration does have a limit!

TIA, Wambat

Switch MyItem1 { http=">[ON:POST:] >[OFF:POST:]" }

Assuming you don’t want the version coming with raspbian, you need to do some more commands (read the section at the bottom " Installing from the Mosquitto Debian repository"

That is something you won’t find in depth in this forum, but there are a lot of script examples in the net.

Many thanks sihui for your reply.

re: Help 1 : Thats easy enough, Missed it somehow.
re Help 2 : I read the referred article a number of times but didn’t action on it because I had also read that the “Built In” MQTT Broker in Openhab was not fully implemented! It seemed to install easy through openhab-config. Just need to test it now.
re: Help 3 : Yes, there is LOTS of little Arduino projects out there… just need to get the right one.

Best regards,

You either need to install your own broker (for example mosquitto) or you may use the built-in broker which seems to be still experimental and there is no documentation so far I’ve seen.

Just focus on the mqtt part and copy it to your scripts :grinning: