Project Description: Lamp with RGB LED strip inside, controlled via webpage in local network. It can check facebook inbox and notify you by light that there are some unread messages. Also lamp has “Alert” functionality that allows you send alert signal to it (just for fun!). Name and ip address of person who requested alert is sendig to Watson IoT service.
What you need:
- Raspberry Pi (and power supply for it)
- Transistors IRFZ34N or 2N2222A (which transistors to use depends on how much RGB LED strip you want to use)
- RGB LED Strip
- Power Supply (12V 2Amp) – for RGB LED Strip
- Power Jack
- Breadboard
- Wires
- Case for your lamp
- Monitor, mouse, keyboard for Raspberry Pi (optionally)
Overview:
This project may seem a bit trivial, but I want to show how to combine different technologies in one project and get much more than just controlling RGB LED strip.
As I said, we will controll RGB LED strip that attached to Raspberry Pi via webpage in local network. On the diagram above I show interconnection between all elements (It is better to look at it in full size). Main program (box with “Main Lamp Controller”, “Facebook Listener” and “Python Server” is written on Python and has three threads: one main thread and two threads for communicating with user and facebook api. I will tell about each thread in the following steps. “Python Server” communicates with Apache Server launched on the Raspberry Pi, and Apache Server communicates with users in local network. Also on Apache Server we have file “alert.php” that sends data to IBM Bluemix cloud with name and ip address of person who requested alert on your lamp. “Facebook listener” just check my inbox in facebook and send a signal when there are some unread messages.
Why do we need two servers: Python Server and Apache Server? Python Server is a simple program that listens only on one port. To make our project more secure we need to use Apache Server – program that is much more reliable that our implementation.
Why do we need threads? Threads is like programs that run independently of main process. In our project we have three different functionaly: control lamp, listen for data from user and listen for data from facebook. Each functionality by itself needs much time to work. If we implement all these functionalities in one program (one-thread program), program will work very slowly. More about threads in python you can read here.
Which transistors to use: IRFZ34N or 2N2222A? It depends on how much of your RBG LED strip you plan to use. My stip consumes 7.2W for one meter. It has 10 segments in one meter, so one segment consumes 0.72W = > current that flows through this segment: 0.72 = 12V * I => I = 0.06 amps. I used two segments => current in them 0.12 Amps. About electrical power you can read in wikipedia. 2N2222A allows max current around 500 mAmps, so for my lamp these transistors are good enough. If you wanna use 1 m and more you have to use IRFZ34N or counterparts.
Note: I used Raspberry Pi 3, which has wifi module, if you want to use Raspberry Pi 2, you have connect it to internet via Ethernet.
Step 1: Hardware
Step Description: On this step we will assembly our lamp and download special software.
Firstly, we have to configure Raspberry Pi. If you have brand new Raspberry Pi and have no experience with it you can use this tutorials (video, pdf) how to start with it. The main idea of this tutorials:
- Download Raspbian OS Image from offical web-site: raspberrypi.org
- Download program for formatting and burning data to flash-cards
- Format and then burn Raspbian OS Image to your flash-card
- Insert your flash-card to your raspberry pi and turn power on.
There two ways for control Raspberry Pi: attach monitor, mouse and keyboard to it – use it as standalone device, or control it via SSH from your own computer. If you want to control it via SSH – here is a good instruction how to set up this.
Now we have fully worked and configured Raspberry Pi.
Step 1. Take RGB LED strip, cut off elements what you need, solder wires to stip.
Step 2. Take breadboard, wires, power supply, transistors and strip that you cut and solder on previous step and assembly how it is showed on picture above. (I also attached Fritzing diagram)
Step 3. Attach wires for RED, GREEN, BLUE and Ground to Raspberry Pi to GPIO17, GPIO27, GPIO22 and ground respectively.
Attention! RGB LED Strip Ground and Raspberry Pi Ground have to be connected!
Note: GPIO pins on Raspberry Pi are shown on this picture.
Now we have to instal special software for controlling LEDs (actually you can use python module, but for me, pigpio library seems more stable). Open terminal on Raspberry Pi and type in the following commands:
wget abyz.co.uk/rpi/pigpio/pigpio.zip unzip pigpio.zip cd PIGPIO make -j4 sudo make install
More about pigpio library here.
We just installed special library that we use to set PWM on needed pins. What is PWM and how it is used to to conrtol RGB LED read here and here.
the original post:http://www.instructables.com/id/SmartSocial-Lamp/
Leave a Reply
You must be logged in to post a comment.