unnamed

 

 

Using the open source software OpenHAB, we’ll be building a Raspberry Pi touchscreen command center that can interface with over 150 different “smart home” products, and provide an interface for control and task scheduling. Instead of using an existing product though, we’ll build our own WiFi enabled RGB LED strip that interfaces with OpenHAB, allowing you to wirelessly control it from your smartphone or any computer on your network.

OpenHAB is great because it interfaces with so many products, it’s free, it’s open source, and extremely flexible. It also runs on Windows, OS X, and Linux, so you don’t necessarily have to use a Raspberry Pi for this project. If you have an old laptop or desktop kicking around, you can just as easily run the same setup.

We also want to thank Arrow Electronics for sponsoring this build. They’ve given us access to their vast inventory of electronic components in order to make this project series possible. We’re super excited to share what we’ve come up with!

The main parts for this build are a Raspberry Pi and touchscreen, as well as the components used to control the NeoPixel strip. You can purchase the components from Arrow, or other online electronics vendors. You’ll also need a few tools for soldering and programming the microcontroller.

 

Steps

Advertisement

Step #1: Assemble the Raspberry Pi and touchscreen

PrevNext
Building a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs Wirelessly
  • Without instructions, assembling and attaching the screen to the Raspberry Pi can be a bit tricky.
  • Start with the screen face down and flip the display controller board over so that the large connector is visible. Connect the large ribbon cable from the screen to the controller, being sure to push the cable in fully and securing it with the clip on the connector.
  • Flip the display controller board onto the back of the screen, and push the small touchscreen cable into its connector. Screw the standoffs into the back of the screen, through the holes in the controller board.
  • Insert the ribbon cable into the display connector on the side of the controller board, then place the Pi on top of the standoffs and screw it in. Connect the other end of the ribbon cable to the display connector on the Pi.
  • In order to run power and ground to the touchscreen, we'll use the GPIO pins on the Pi. Take the red jumper wire that came with the screen, and plug it into the rightmost lower 5V GPIO pin on the Pi, then plug the other end into the rightmost pin on the controller board below it. Use the black jumper wire to connect the GPIO GND pin (two pins over from the red wire 5V pin) on the Pi to the leftmost pin on the controller board below it.

Step #2: Setup the microSD card and configure Raspbian

PrevNext
Building a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs Wirelessly
  • Download the latest build of Raspbian from the Raspberry Pi website and flash it onto a microSD card. Then insert the card into the Pi.
  • Plug in a keyboard, mouse, and wifi adaptor, then insert the card into the Pi and boot it up.
  • Go through the configuration process, and when it's fully booted, connect to your WiFi network.
  • In order to get the touchscreen to work, you’ll likely need to run a few commands from the command line to update Raspbian: sudo apt-get update sudo apt-get upgrade This will probably take a while, so be patient!
  • If you restart the Pi after the update, the touchscreen will flip upside-down. If that’s a bother to you, you can flip it by adding lcd_rotate=2 to the last line in the config file in the boot folder, using the following command: sudo nano /boot/config.txt Then hit Ctrl+X to save and exit.

Step #3: Install OpenHAB

PrevNext
Building a Home Automation System with OpenHAB to Control LEDs Wirelessly
  • Now it’s time to install our home automation control software, OpenHAB, and the OpenHAB addons we’ll be using.
  • Open a command line on the Pi, and enter the following commands: sudo mkdir /opt/openhab cd /opt/openhab sudo wget https://bintray.com/artifact/download/openhab/bin/distribution-1.7.1-runtime.zip sudo unzip distribution-1.7.1-runtime.zip sudo rm distribution-1.7.1-runtime.zip
  • Now we'll enter a few more commands to configure OpenHAB to run at startup: sudo wget http://www.element14.com/community/servlet/JiveServlet/download/38-152207/openhab.zip unzip openhab.zip sudo rm openhab.zip sudo cp openhab.sh /etc/init.d sudo chmod 777 /etc/init.d/openhab.sh sudo update-rc.d -f openhab.sh defaults
  • We'll also need to install the OpenHAB MQTT addons, since that's the protocol we'll be using to communicate with our LED strip: sudo wget https://bintray.com/artifact/download/openhab/bin/distribution-1.7.1-addons.zip sudo unzip distribution-1.7.1-addons.zip -d /addons sudo cp /addons/org.openhab.binding.mqtt-1.7.1.jar /opt/openhab/addons sudo cp /addons/org.openhab.persistence.mqtt-1.7.1.jar /opt/openhab/addons sudo rm distribution-1.7.1-addons.zip

Step #4: Install the MQTT broker

PrevNext
Building a Home Automation System with OpenHAB to Control LEDs Wirelessly
  • As we mentioned, we'll be communicating with our LED strip using a protocol called MQTT. In order to set this up, we'll need to install Mosquitto, an open source MQTT broker.
  • To install Mosquitto, enter the following commands in the command line: sudo wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key sudo apt-key add mosquitto-repo.gpg.key cd /etc/apt/sources.list.d/ sudo wget http://repo.mosquitto.org/debian/mosquitto-wheezy.list sudo apt-get update && sudo apt-get install mosquitto

Step #5: Install the OpenHAB configuration files

PrevNext
Building a Home Automation System with OpenHAB to Control LEDs Wirelessly

Finally, download our pre-made OpenHAB configuration files, and install them in the associated OpenHAB folders.

(See the included README file for folder locations for each file)

Step #6: Soldering the ESP8266 header pins

PrevNext
Building a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs Wirelessly
  • With OpenHab set up on our Raspberry Pi, it’s time to switch to building our NeoPixel strip controller. The cheap, WiFi enabled Adafruit ESP8266 HUZZAH board is perfect for this.
  • First, solder the provided header pins to the board so we can program it using an FTDI adaptor.

Step #7: Soldering the logic level converter

PrevNext
Building a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs Wirelessly
  • Because the ESP8266 uses 3.3 volt logic level instead of the NeoPixel strip’s 5 volts, we’ll need to solder a logic level converter between them.
  • On the low level side of the converter, solder a wire from pin 2 from the ESP to A1, another from pin 3V to LV, and a third from GND to GND. On the high side of the converter, solder a wire from pin B1 is to the NeoPixel data pin wire (that’s the striped wire on the NeoPixel connector), and another wire from GND to GND. Solder a red wire to the HV pin on the converter, and another red wire to the V+ on the ESP.
  • The male end of the NeoPixel strip will provide power for the ESP, so solder the red wire from the strip to the red wires coming from the V+ and HV pins, then solder the black wire to GND. After that, plug the NeoPixel strip into the wall with the provided cord, and make sure that the ESP is getting power by hitting the reset button to see if the onboard LED flashes.

Step #8: Setting up the Arduino IDE

PrevNext
Building a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs Wirelessly
  • With everything wired up, it’s time to flash the ESP using the Arduino IDE. First we need to make some changes to the Arduino IDE though.
  • Download the PubSubClient library from https://github.com/Imroy/pubsubclient, and extract the folder into the Arduino libraries folder.
  • Open the Arduino IDE, then go to Sketch > Include Library > Libraries Manager… and install the Adafruit NeoPixel library.
  • Finally, we’ll add the Adafruit HUZZAH ESP8266 board to the boards list. Go to Arduino > Preferences, and add “http://arduino.esp8266.com/stable/package_esp8266com_index.json” into the Additional Board Manager URLs field and click OK. Go to Tools > Board: > Boards Manager… and install the ESP8266 package.

Step #9: Flashing the ESP8266

PrevNext
Building a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs Wirelessly
  • Download and open the provided Arduino sketch, then edit the sketch to include your WiFi network settings and Pi IP address. You can check your Pi’s IP address by typing “ip addr show” into the command line.
  • Connect your computer to the ESP with an FTDI cable, and set your board and port in the Arduino IDE. Put the ESP into programming mode by holding the GPIO0 button down and pressing the Reset button, then upload your code.
  • After it’s flashed, open the serial monitor and make sure that the board connects to your WiFi network successfully.

Step #10: Install the OpenHAB tablet or mobile app

PrevNext
Building a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs WirelesslyBuilding a Home Automation System with OpenHAB to Control LEDs Wirelessly
  • With OpenHAB configured, and our NeoPixel strip on the network, it’s time to test it out!
  • Download the OpenHAB app to your phone or tablet (it’s available for both Android and iOS), then open it and select Settings in the upper right corner. Change the OpenHAB URL field to your Pi’s IP address, followed by a colon and 8080. Exit the menu, and your phone should connect to OpenHAB, bringing up your LED controller.
  • Alternatively, you can also control the LEDs from any computer on the same network (including the Pi) by entering the Pi’s IP address, followed by “/openhab.app?sitemap=home”.
  • If you need to troubleshoot, you can install the Chrome app called MQTTLens to verify that OpenHAB is sending out MQTT messages. Just edit the settings to point to the IP address of the Pi, and add a subscription to the topic # to see all MQTT messages the Pi is sending.

Step #11: Play!

PrevNext
Building a Home Automation System with OpenHAB to Control LEDs Wirelessly

OpenHab is extremely versatile, and we’ve only just scratched the surface of what it can do. You can control things with voice commands, monitor sensor networks, and even set up rules for automating devices from email or IFTTT. In the next few videos, we’ll show you how to build other cool devices that connect to OpenHab and make your house even smarter.

Jordan Bunker

Jordan Bunker

Technical Editor at Maker Media. Maker. Hacker. Artist. Sometimes Scientist. Pretengineer. Builder of things. Maker of stuff.


  • Richard Koshak

    Since openHAB 1.7 (the current version is 1.8.1) there has been an apt-get installation method. Installing via apt-get is the most preferred and the “official” installation method recommended by the openHAB community. Using this method you will get automatic updates, openHAB will be configured to run as a service under a limited rights access user, and most of the thorny permissions problems that causes problems for many openHAB users are avoided. Instructions for adding the openHAB repository and installing via apt-get are located here:

    https://github.com/openhab/openhab/wiki/Linux—OS-X#apt-get

    • Annettetsmith4

      ❝my .friend’s mate Is getting 98$. HOURLY. on the internet.❞….few days ago new McLaren. F1 bought after earning 18,512$,,,this was my previous month’s paycheck ,and-a little over, 17k$ Last month ..3-5 h/r of work a day ..with extra open doors & weekly. paychecks.. it’s realy the easiest work I have ever Do.. I Joined This 7 months ago and now making over 87$, p/h.Learn. More right Here;;206➤➤➤➤➤ http://GlobalSuperEmploymentVacanciesReportsMoney/GetPaid/98$hourly…. .❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2:❦2::::;;206………ac

    • atxproffer

      apt only works on debian-based distros. it will not work on arch, redhat, or RTOS systems.

      • Richard Koshak

        Indeed, apt doesn’t work on Windows or OSX or any of the other operating systems that OH will run on. But since this tutorial is based on Raspbian which is Debian based, installation via apt-get is the preferred method.

  • mosix
  • Ayan

    Ported this project on Particle Photon and added feature to control analog RGB LED strips(non neopixel) using PWM pins and transistors.
    Check out:
    https://github.com/iayanpahwa/OpenHab-Particle-MQTT-master

  • B34N3R

    I’m looking forward to the series. I’m been using RPi based OpenHAB for mostly Z-wave. I’m now looking to get into using 8266s with MQTT. I’ve never used Arduino but a few 8266 ESP-01s just arrived and are ready to go once I figure out how to use them.

  • mosix

    What kind of display did you use? Could you post where did yuo buy it?

  • Deepansh Pahwa

    Can we control lights and other electronics in the room with this?

    • Saabi

      With OpenHAB I can control my Philips Hue lights, but it needs completely different method.

  • Jack H

    Any chance of posting more pics? The neopixel strip I got from following the parts link in your post has no power cord and no connectors. Would like to see what goes where and what other parts I need. The text description is hard to follow without pictures. Thanks.

  • SuigaredRiotpPoof

    I’ve almost completed the project but I’m getting an error when the NeoPixelOpenHab.ino file compiles in Arduino IDE. It says “‘MQTT’ does not name a type”. Is it not seeing one of my libraries?

    • SugaredRiotpPoof

      Wish I know what I did, but it finally worked.

    • Dave Dague

      SugaredRiotpPoof,
      I too am receiving this failure. Any guidance available?

      • SugaredRiotpPoof

        I think it was because, after downloading Imroy’s PubSubClient, I would load it into my Arduino library, then restart the Arduino IDE. It would then offer to update the library, which sounds like a good idea. It’s not. There is another GitHub library with the same name. Try that. I think I went round and round, redownloading the files and libraries, over and over. Suddenly it worked. I’m really not sure what I did to make it work.

      • Jack H

        Thank goodness you posted this. I had the exact same error and would never have overcome it without your helpful post. Alas, it was only one of the ultimately insurmountable hurdles I had to face. I hope you had better luck than I.

  • Jack H

    I really appreciate the effort that must have gone into putting this project together, but I have to say that I have found myself incapable of successfully implementing it. I’ve now spent countless hours on this and am giving up in frustration. There is not a single step that is clearly described or easy to follow. I ran into problems in literally every phase (except the display which I already had). Even cutting and pasting the software commands resulted in errors that I was unable to resolve. I’ve spent enough time on the bleeding edge. Let me know when I can buy this in the store.

  • Kevin Rutledge

    I have yet to figure out what is going on when I try to follow any instructions related to the pi, including these. Usually around permissions and uploading files. I have yet to find a setup that can get me through it. Aside from the weird formatting of the commands where there are no breaks in the command lines leaving me to figure out which commands start and end where, I get to the point of uploading configuration files and while you walk through every step of the way everywhere else, you leave this completely lacking in instruction. I tried to use afp, and install netatalk and cyberduck, and nothing. At least with cyberduck, I can see the root folder “/” but when I try to upload the files of the sample configuration I run into permission errors.

    Getting so frustrated that the pi is about to be thrown out the window.

  • RoganDawes

    Seriously? Chmod 777 a file that is run by root on startup? Great advice there!

  • Julian Balles

    Which Version of PubSubClient was used here ?
    With newer Versions this implementaions wont work.