User Tools

Site Tools


2016:ha:openhab_mqtt_arduino_and_esp8266

OpenHAB, MQTT, Arduino and ESP8266

This article is from Make Magazine. The original file is here:

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.

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.

Step #1: Assemble the Raspberry Pi and touchscreen

  • 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

  • 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


Now it’s time to install our home automation control software, OpenHAB, and the OpenHAB addons we’ll be using.

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

2016/ha/openhab_mqtt_arduino_and_esp8266.txt · Last modified: 2016/05/13 09:23 by 75.177.137.2