Daniel Martin
Acknowledgements:- · Weather Underground
- · Alexander Baran-Harper https://www.youtube.com/watch?v=PYBZtV2-sLQ
- · Adafruit
- · Sparkfun
- · Cayenne
When you walk into a dark room, it’s nice to have an LED light strip automatically turn on. But wouldn’t it be cooler if it were controlled by a smartphone – that with a tap of a finger the light could change color? What if, with just a few sliders on your phone’s app, you could create virtually any color with varying intensity, for example sunrise colors in the morning and sunset colors in the evening? This Smart Ambient Lighting system would be able to detect where you are: if you’re simply walking by in the periphery of the room or if a baby is crawling in the hallway in another part of the house. Below is a schematic overview of the Smart Ambient Lighting project.
The Remote Control module (ESP8266 with motion sensor) communicates via Wi-Fi with the Light Control module (Arduino Yun with motion sensor, buzzer, and LED Strip). This system not only provides soothing ambient lighting in a family room, but can effectively be used for monitoring a baby or pet moving in the hallway. The possibilities are limitless! All these sensors can be easily accessed on the Cayenne dashboard from a smartphone or laptop. As an additional bonus, I added a Raspberry Pi which communicates with the Yun and takes pictures when motion is detected in the Family Room (not part of this project). Using Cayenne, I set up a schedule for the Ambient Lighting to go on at sunset. Cayenne also provides options for triggers and alerts to further enhance your lighting system.
Instructions for the Yún Light Control Module:The first step is to setup the LED strip with the Arduino. This link provides the tutorial for connecting the RBG LED strip to a microcontroller: https://learn.adafruit.com/rgb-led-strips?view=all. The section on “Wiring” shows how to solder four wires to the copper pads on one of the ends of the LED strip. I found that on one end of the strip the manufacturers had already done this, so you may be able to skip this step. However, since you might choose to have your microcontroller several feet away from the LED strip, you will need to solder the three wires from the Micro Connectors cable to the RGB ends from the strip. You will also need to solder the Shaxon wire to the +12V wire from the strip (this needs to be thick because it carries three times as much current as RGB wires, e.g. 14AWG). Connect up the wires as shown in the diagram.
The grounds from the three transistors must be connected to the Arduino Yún in addition to the ground of your 12V DC power adapter (the batteries indicate the 12V power supply – don’t actually use batteries). The thick wire you just soldered from the +12V of the LED strip should be soldered on the other end to the positive side of your 12V DC power adapter. The diagram shows the digital pins used: pin 3 for RED, pin 5 for GREEN, and pin 9 for BLUE. Use any GPIO pins that you want, just be sure to alter the code accordingly. If you choose to test using the code provided by Adafruit in the link above, power up your microcontroller, plug in the 12V adapter, and upload your program (using the Arduino IDE). It should work like in the video at the top of Adafruit’s tutorial. Now you’ve completed the first part!
Now, to make it motion controlled – you will need the PIR to detect motion. It is very easy to connect, just three wires: GND, VCC, and OUT (sometimes labeled on the back of the sensor itself). This link contains the tutorial on how to use this sensor: https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor?view=all. It’s a good read, but also long, so you can simply wire it up according to this diagram.
Once again, you can use any I/O pin, just make sure to change the code to match your wiring. The link provides an example code which you can use to test your work, which I have modified to make it simpler. Upload this program, and open the serial monitor. Wave your hand near the sensor, and “Motion detected!” should appear on your screen.
Next are the photocells – we only want the light to turn on when it is dark. I used four photocells in parallel with a 10k resistor connected in the same format as https://learn.adafruit.com/photocells?view=all, under “Using a Photocell”.
Once again, utilize their example code to test your work. Just upload the program as it is (and adjust your input pin to match your wiring) and open the Serial window to observe if your readings match your intuition (shine a light on the cells to see if values approach 1023, and cover them to watch the values drop toward 0).
To create some audio feedback, which is especially useful in alerts, connect a piezo speaker to the Arduino. The positive side goes to a digital output pin, and the negative side to ground.
With all the pieces together, the project looks like this (scroll through images):
The Light Control Module can also be made by replacing the Yún with another ESP8266 board, with alterations to the code. Since this part of the project uses only 1 analog pin and 5 digital pins, it is possible to use Sparkfun’s board as a substitute.
Instructions for the ESP8266 Remote Control Module:The Sparkfun ESP8266 board will contain the following sensors:
· IR Receiver / Transmitter
· Some photoresistors
· RGB LED
The IR transmitter, which looks like an LED, sends out pulses at a frequency of 38 kHz. The positive (longer) leg is connected to the digital pin via a 2k Ohm resistor, and the negative side is hooked up to ground. The IR receiver has 3 pins: the left pin (when facing it) is connected to a digital pin via a 220 Ohm resistor. The middle pin is hooked up to GND, and the right pin receives +5V. Here, you can also use an IR distance sensor to adjust the intensity of the light based on the measured distance.
The next step is to add the RGB LED, so that when motion is detected we have a visual feedback. These LEDs are really cool – with only one digital pin you can control the red, green, and blue values, so you can create virtually any color! Since the ESP8266 has Wi-Fi capability, I was able to use Weather Underground’s API to get the outside temperature and color code it. If you want, you can use the LED’s color to update you if your favorite team won, or if you have unread emails in your inbox. The hardware is simple: one pin to ground, another to 5V, and a third to a digital pin. The LED has a tiny chip inside it, and it decodes a signal sent from the microcontroller to determine what color to display. This complex part is wrapped up in the Adafruit NeoPixel library.
The final part is to add some local photoresistors to detect lighting wherever you place your ESP board. We are going to use the ADC pin, which is also known as A0, to receive an analog value of the intensity of light present. I decided to use two photocells in series with a 10k Ohm resistor, but you may choose to hook up the cells in parallel, or use a different number of cells. Below is a schematic of the final ESP8266 circuit, with the added photocells.
With all the pieces together, the Remote Control Module looks like this:
Here are some screenshots of the Cayenne Dashboard:
Comments
Please log in or sign up to comment.