Setting Up The Home Automation Server (OpenHAB 2 + MQTT)

The first thing I will show you is the device in action so as you can see here it is and it is mounted on the same wall as the network. But, you might be wondering what it is doing right now well, right now it is hosting the OpenHAB 2 service as well as the mqtt service. After completing this series we will be prepared and ready to create the user interfaces as well as connect our smart automation devices.

Now let’s talk about how it all works. To start off the entire thing is running on a raspberry pi, in this case I am using a raspberry pi 3 but this will work fine on a 2 as well as anymore pi’s in the future. Next up the storage for the pi is a 32gb sandisk micro sd card class 10 of course for the extra data speed. The pi is being housed in a clear acrylic case with a fan built in. But the fan does not do the cooling on its own, I have also installed a heat sink which with the fan is pretty good cooling. The pi is being powered by a 5v 2.5 amp power adapter that is UL certified which is important for power stability. The actual pi is connected to the network via a green cat 6 cable. We will be installing the software onto the pi using either a Mac computer or a windows computer which each have their own video so when you do it make sure you watch the right video. The software we will be installing is OpenHAB 2 as well a Mosquitto Mqtt server. But, this has all been made easy because all we will be doing is flashing a prebuilt image called openHABian which makes everything a lot easier. To actually configure the pi we will be using a combination of the web browser and ssh. But, the entire software process will be explained in its respective video.

That’s all I have for the actual demo, now it is time for you to watch the next videos to learn how to setup your own home automation server running OpenHAB 2.

Product Links:

Raspberry Pi Stuff
Raspberry Pi 3: Link
Heatsink: Link
Case With Fan: Link
Power Adapter: Link
Micro SD Card: Link
Ethernet Cables:

Wall Mount Hardware
Plastic Spacers:
Screws (M3.5 + 20mm):

Micro SD Card Reader: Link
Impact Gun + Drill:
Screw Bit Set:
Drill Bit Set:
Counter Sink Bit Set:


Installing the heatsinks onto the raspberry pi:

  1. Peal the backing off of the smaller heatsink
  2. Take the smaller heatsink and place it on the small black square on the raspberry pi
  3. Align the heatsink and then press down on it to make sure it attached
  4. Peal the backing off of the bigger heatsink
  5. Take the bigger heatsink and place it on the big black square on the raspberry pi
  6. Align the heatsink and then press down on it to make sure it is attached

Setting up the case:​

  1. Take off all the protective acrylic packaging paper off of the acrylic pieces of the case (Use a knife to pick at a corner and pull off the plastic)
  2. First take bottom piece, the one with the box in the center and the long side with the shorter distance of the side to the box facing you
  3. Take out the 4 screws, 4 plastic washers and 4 nuts from the bag
  4. Take the 4 screws and put them into the bottom plastics piece from underneath with the long side with the shorter distance of the side to the box facing you and place on flat surface
  5. Take the 4 plastic spacers and put them on the screws
    Take the raspberry pi and put it on the screws by ligning it up
  6. Take the 4 nuts and put them on the screws
  7. Take out the 4 nuts and 4 screws out of the bag
  8. Take the top piece of the case and lay it flat with the gpio cut facing away from you and the big lift tabs to your left
  9. Lift up the piece and stick in the 4 screws underneath the piece and through the holes
  10. Take the fan and look around its sides to find two arrows
  11. Orient the fan so the arrow is pointing up and where the cable exits the fan should be away from you
  12. Take the fan and place it on the 4 screws
  13. Take the 4 nuts and screw the fan down
  14. Use a philips screw driver and a wrench or pliers
  15. Take the two long side pieces for the case and put them on
  16. 5v fan so plug the red side into pin 4 and black side into pin 6
  17. But sadly the case does not fit with the connector how it is so we are going to shave off the side clip with a razor or knife then plug it in
  18. Take the cable and sort off wrap it around the fan, and place the top piece in the two holes of the side pieces
  19. Take the piece with two holes in it and align it over the front ethernet and usb ports, when you put on the piece first hook it over the top hooks and then the bottom clips
  20. Then take the final piece and put it over the back, by hooking it on the top and cliping it in
  21. Now the case is complete

Setting it up for use:

  1. Plug in the ethernet cable into your network and into the raspberry pi
  2. Plug in micro usb side into the raspberry pi but not into the wall socket yet

Software WINDOWS:

Setting up the micro sd card:

  1. Grab the micro sd card at least 16 gb recommended 32GB
  2. Put the micro sd card into your computer, could be using a micro sd card reader
  3. Go to:
  4. Scroll down to downloads and download the raspberry pi image by clicking on the file called “openhabianpi-ua……..img”
  5. It should download
  6. Go to:
  7. Click the download button and it should automatically download
  8. Once it is done downloading open file explorer and go to your downloads folder
  9. Double click on Win32DiskImager to install it
  10. Click run and then yes in the pop up boxes
  11. Click next, agree to the terms, click next, next, next, next and then click install
  12. Once it is done click finish
  13. You should get an error that says “Unable to execute file” click ok
  14. Go into the search bar or wherever your applications are and find Win32 Disk Imager
  15. But we have to run as administrator so right click on it and press run as administrator then click yes in the pop up
  16. First we have to load the image so click on the folder icon next to the Image File Field
  17. Go to the downloads folder and double click on the file that starts with openhabianpi
  18. Next in the device drop down select the letter drive of your micro sd card if you are unsure you can go to the file explorer and check the letter of the drive
  19. Click write

Putting the micro SD card into the raspberry pi:

  1. Take the micro sd card and put it into the raspberry pi, the logo on the SD card should be facing down
  2. Then take the other end of the power adapter and plug it in
  3. The raspberry pi is now booting
  4. Please be patient and set a timer for 45 minutes because that is how long the first boot will take

Setting up the static IP address:

  1. Go to you routers web page in your web browser, mine is and login
  2. Then go to DHCP and DHCP Client list
  3. Look through the list and find openHABianPi
  4. Then copy its MAC address
  5. Now head over to address reservation
  6. Then click add new
  7. In the MAC address field paste the pi’s MAC address
  8. And then give it a reserved IP address, continuing on from the network videos, I am going to give it
  9. Then click save and in the pop up box click ok
  10. There will be a little warning saying that it needs to reboot so click on the thing that says “click here”
  11. And press the reboot button and ok in the pop up box
  12. Let the router restart
  13. Once the router is fully booted unplug the raspberry pi wait 10 seconds and then plug it back in
  14. Wait 1 minute for the raspberry pi to boot back up

Setting Up OpenHAB 2.0 web config

  1. Then open up your web browser and go to http://yourpiipadress:8080 replace the yourpiipadress with your pi’s ip address, mine is
  2. You should see a webpage asking which setup you would like, we are going to click Expert
  3. Now it should be installing our user interfaces, this could take a couple minutes so be patien

Setting up SSH:

  1. Go To
  2. Find where it says “MSI(‘Windows Installer’)” and click on the .msi file that corresponds with you system architecture either 32 or 64 bit personally I choose 64 bit
  3. Open File Explorer then go to your downloads folder
  4. Double click on the .msi file that starts with putty-
  5. When the box comes up hit run
  6. Click the next button 2 times and then click install when the box comes up click yes
  7. Once done hit finish
  8. Now we are going to open putty, so either search for it in the search bar or go to wherever your applications are and run it
  9. Right click on it and press pin to taskbar so you always have access to it
  10. In the Host Name field type in the IP address of the raspberry pi
  11. In the Saved Sessions field type in Home Automation Server and press the save button
  12. Click Open
  13. Box should pop up saying not cached in the registry, just press yes
  14. In the prompt box it will say login as: type in openhabian
  15. Now it will ask for the password type in the default which is openhabian and press enter
  16. Congratulations we are now SSH into the raspberry pi
  17. type in sudo openhabian-config and press enter
  18. Type in the default password openhabian
  19. Use the arrow keys and go to update and press enter (it might kick you out of the configurator if so follow step 20 if not go to step 21)
  20. Then go back to configuration type in sudo openhabian-config and press enter
  21. Use arrow keys and go to Upgrade system and press enter
  22. Once that is done use arrow keys and go down to Mosquitto and press enter
  23. Then on the screen press enter while continue is highlighted
  24. We will not be using authentication so use arrow keys and go over OK and press enter
  25. It should now be installing our mqtt server
  26. Once it is done press enter over OK
  27. Use arrow keys go to exit and press enter
  28. It should give you a warning that we didn’t change the password so we are going to change some passwords I recommend using the same new password for the next two things
  29. Type passwd and press enter, we are now going to change ssh password, so enter the default password openhabian and press enter then enter a new password and press enter then confirm that password by typing it in again and enter it should say updated successfully
  30. We are now going to change the samba password I will explain what this is later, anyway type in sudo smbpasswd openhabianand press enter
  31. You might have to Type in the sudo password so the one we just changed previously and press enter if not go to step 33
  32. Now type in a new password I recommend using the same password as the sudo password so type it in and press enter then type it in again and press enter
  33. Next we are going to change the timezone and locale so the raspberry pi can set its date and time
  34. type in timedatectl list-timezones and press enter Then use the arrow keys to scroll down through the list to find your time zone, once you find it highlight it and then copy or remember it then press control z to exit
  35. Type in sudo timedatectl set-timezone Europe/Berlin but replace the Europe/Berlin part with your timezone then press enter
  36. Then type timedatectl and press enter to check the timezone
  37. We have now finished configuring the initial setup home automation server
  38. So now type in sudo reboot and press enter, you might have to type in the sudo password and press enter

Testing The MQTT Server Mosquito:

  1. Once it is done rebooting go to
  2. Press Download MQTT.fx then click on the one below Latest version
  3. It will take you to a new page click on the file that suits your windows the first windows one is 64 bit and the second one is 32 bit
  4. It will start downloading
  5. Once it downloads open up file explorer and go to your downloads folder
  6. Double click on mqttfx………windows
  7. Click run and then when the other box comes up click yes
  8. Click next 3 times and then click finish
  9. Go to your search bar or wherever your applications are and look for mqttfx and the double click on it to open the program
  10. This is now a good time to explain what this is, this is a program that tests mqtt stuff so you can debug it and see if it is working
  11. Click on the gear at the top
  12. Change broker address to the ip address of the raspberry pi mine is and make sure the port is 1883
  13. Then at the bottom click apply then click cancel
  14. Now click connect
  15. If it connects successfully and there is a green circle in the top right then you are good
  16. Go over to the subscribe tab and type in the # symbol and press subscribe
  17. Then in the publish tab type in hi in the field and then in the big box type in hello world! Then hit publish
  18. Then go back to the subscribe tab and if you see hello world that we are very good
  19. We successfully set up the mqtt server

Connecting The MQTT Mosquito server to OpenHAB 2:

  1. Now lets connect the mqtt server to openhab, so go to open up your web browser and go to http://yourpiipadress:8080 replace the yourpiipadress with your pi’s ip address, mine is
  2. Then click paper ui, paper ui is the web administration pannel for the automation server
  3. Add ons
  4. In the search box type in MQTT
  5. Next to where it says MQTT Binding click install wait for it to install
  6. Go back and ssh into raspberry pi again using putty
  7. type in sudo nano /etc/openhab2/services/mqtt.cfg and press enter
  8. Might ask for sudo password so enter that
  9. The only thing we are going to change is the server or url to our broker so delete the line #<broker>.url=tcp://<host>:1883 and replace it with broker.url=tcp:// but change the IP address to match your raspberry pi
  10. Press Control x and then press y then press enter to save

Software Part Complete For The Setting Up The Home Automation Server

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *