Reader small image

You're reading from  Raspberry Pi 3 Home Automation Projects

Product typeBook
Published inNov 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781783283873
Edition1st Edition
Languages
Right arrow
Authors (2):
Shantanu Bhadoria
Shantanu Bhadoria
author image
Shantanu Bhadoria

Shantanu Bhadoria is an avid traveler and the author of several popular open source projects in Perl, Python, Golang, and Node.js, including many IoT projects. When in Singapore, he works on paging and building control systems for skyscrapers and large campuses in Singapore, Hong Kong, and Macau. He has authored and contributed to public projects dealing with control over gyroscopes, accelerometers, magnetometers, altimeters, PWM generators, and other sensors and controllers, as well as sensor fusion algorithms such as Kalman filters. Shantanu's work in IoT and other fields can be accessed on his GitHub account with the name shantanubhadoria. He is also the author of Device::SMBus, a popular Perl library used to control devices over the I2C bus.
Read more about Shantanu Bhadoria

Ruben Oliva Ramos
Ruben Oliva Ramos
author image
Ruben Oliva Ramos

Ruben Oliva Ramos is a computer systems engineer from Tecnologico de Leon Institute, with a master's degree in computer and electronic systems engineering and a specialization in teleinformatics and networking from the University of Salle Bajio in Leon, Guanajuato, Mexico. He has more than 5 years of experience of developing web applications to control and monitor devices connected with Arduino and Raspberry Pi, using web frameworks and cloud services to build the Internet of Things applications. He is a mechatronics teacher at the University of Salle Bajio and teaches students of the master's degree in design and engineering of mechatronics systems. Ruben also works at Centro de Bachillerato Tecnologico Industrial 225 teaching subjects such as electronics, robotics and control, automation, and microcontrollers. He is a consultant and developer for projects in areas such as monitoring systems and datalogger data using technologies (such as Android, iOS, HTML5, and ASP.NET), databases (such as SQlite, MongoDB, and MySQL), web servers, hardware programming, and control and monitor systems for data acquisition and programming.
Read more about Ruben Oliva Ramos

View More author details
Right arrow

Integrating CheerLights into a Holiday Display

CheerLights is a project by Hans Charler that allows your lights to be controlled by Twitter tweets. Anytime somebody tweets to twitter to @CheerLights with a color, all the CheerLights around the world will change to that color. This section will help you brush up on your soldering skills, navigate portions of the ESP8266 breakout board, and encourage creative building of LEDs into a variety of items.

In this chapter, we will create a festive holiday display that is triggered by festive cheers sent to you by your friends.

We will discuss the following topics:

  • Items required for this project
  • Getting the CheerLights code set up
  • Connecting it all together
  • Programming the ESP8266 Huzzah for CheerLights

Items required for this project

You will need the following materials for this project:

  • Adafruit HUZZAH ESP8266 breakout
  • One USB FTDI connector
  • Two WS2811 NeoPixels LED strips
  • Two 5V and 3.3V (optional) power supplies
  • Two 1000μF capacitors
  • Two logic level shifting ICs
  • Three 400-600Ω resistor 3 JST SM or JST PH connectors (optional)

Adafruit HUZZAH ESP8266 breakout

Adafruit Huzzah ESP8266 is a Wi-Fi microcontroller based on the Arduino IDE and it's one of the many ways in which you can create a CheerLights display. Note that you may choose to create a CheerLights display in scores of different controller types; however, for the purpose of this chapter, we will be using the Adafruit Huzzah ESP8266 for the...

Getting the CheerLights code set up

In this section, we will set up our CheerLights code and deploy it to the ESP8266 Huzzah.

Set up the Arduino IDE

The Arduino IDE is a free IDE provided by https://www.arduino.cc/ that makes it easy to write and deploy code on Arduino and Arduino-based boards like the ESP8266. It's written in Java and it supports Windows, GNU/LINUX, and macOS. Before we start, you must install the Arduino IDE from the following link. You might have to select the correct version for your OS.

https://www.arduino.cc/en/main/software

If you already have the Arduino IDE, make sure its version is higher than 1.6.4.

By default, the Arduino IDE doesn’t support the ESP8266. The Arduino IDE needs to be...

Connecting it all together

Adafruit the NeoPixels LED strip has three inputs: GND, V+ (or VIN) and DIN (or Digital Input). The ordering of the inputs may differ depending on when and who you order the strip from. Follow these steps:

  1. First connect the capacitor and power supply in parallel.
  2. Connect the 1000μF capacitor in parallel across the 5V power supply. If your multimeter supports capacitance measurement and 1000μF is within the measuring range, you may use it to verify the capacitance of your capacitor.
  1. Connect up the grounds next. Connect the power supply ground to the LED strip ground, to the 74AHCT125 ground and the 10E pins, and to ground on the ESP8266. If you have a 3.3V supply, connect the grounds of the two power supplies as well.

Connecting the data...

Programming the ESP8266 Huzzah for CheerLights

In this section, we will learn how to program the ESP8266 Huzzah to link up with the CheerLights API and talk to NeoPixels.

Let's try a simple single-color display

We are almost done with our funky networked blinking lights now; all we need to do is program the ESP8266 with the CheerLights code. For this, connect the ESP8266 with your computer again and switch back to the Arduino IDE:

  1. Include the libraries: The first thing we need to do in the code is include the libraries we will need. We need the Adafruit NeoPixel library and ESP8266WiFi library. Start with including these libraries:

        /* CheerLights
* Let the world set your LED strip's color using...

Summary

CheerLights is a fun and simple collaborative project to start with in your home automation journey. In this chapter, we also learned how to control NeoPixels, which are individually addressable LEDs. What you can do with the NeoPixels is only limited by your imagination. The NeoPixels are ridiculously easy to control and they can be used for some interesting automation projects. Some more practical applications can be to indicate system status of server racks on your workstation desk or to create floating ticker boards. Let your imagination run wild and share what you create!

In the next chapter, we are going to learn how to create a parking space monitor to automatically alert you when your designated parking space is occupied using a machine learning system to ease your vehicle parking headaches. Excited? Read on to learn more.

Cheers!

...
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Raspberry Pi 3 Home Automation Projects
Published in: Nov 2017Publisher: PacktISBN-13: 9781783283873
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Shantanu Bhadoria

Shantanu Bhadoria is an avid traveler and the author of several popular open source projects in Perl, Python, Golang, and Node.js, including many IoT projects. When in Singapore, he works on paging and building control systems for skyscrapers and large campuses in Singapore, Hong Kong, and Macau. He has authored and contributed to public projects dealing with control over gyroscopes, accelerometers, magnetometers, altimeters, PWM generators, and other sensors and controllers, as well as sensor fusion algorithms such as Kalman filters. Shantanu's work in IoT and other fields can be accessed on his GitHub account with the name shantanubhadoria. He is also the author of Device::SMBus, a popular Perl library used to control devices over the I2C bus.
Read more about Shantanu Bhadoria

author image
Ruben Oliva Ramos

Ruben Oliva Ramos is a computer systems engineer from Tecnologico de Leon Institute, with a master's degree in computer and electronic systems engineering and a specialization in teleinformatics and networking from the University of Salle Bajio in Leon, Guanajuato, Mexico. He has more than 5 years of experience of developing web applications to control and monitor devices connected with Arduino and Raspberry Pi, using web frameworks and cloud services to build the Internet of Things applications. He is a mechatronics teacher at the University of Salle Bajio and teaches students of the master's degree in design and engineering of mechatronics systems. Ruben also works at Centro de Bachillerato Tecnologico Industrial 225 teaching subjects such as electronics, robotics and control, automation, and microcontrollers. He is a consultant and developer for projects in areas such as monitoring systems and datalogger data using technologies (such as Android, iOS, HTML5, and ASP.NET), databases (such as SQlite, MongoDB, and MySQL), web servers, hardware programming, and control and monitor systems for data acquisition and programming.
Read more about Ruben Oliva Ramos