Skip to content

Latest commit

 

History

History
101 lines (75 loc) · 6.25 KB

README.md

File metadata and controls

101 lines (75 loc) · 6.25 KB

Raspberry Pi lights!

In 2016, I moved to my first apartment in NYC. To truly embrace living in NYC, I decided to go all in, and rent an apartment where my room did not have a window. In order to prevent my circadian rhythm from going completely haywire, I decided to make my Raspberry Pi control my sound and lights system, and act as a sunrise in the morning Here's an outline of how I went about connecting my system.

lights

Parts List:

Required:

  • Raspberry Pi $35. A Raspberry Pi is effectively a computer, so once you figure out how to interface with it, you can treat it as such.
  • IR controllable Lights $25
  • At least 1 IR LED $1

Recommended

Total : ~80 ish (if you have nothing) Profits: 0

Rewards: You can wake up feeling like you’re waking up to the sunrise, even in your room. Except you’re not waking up to the sun, you’re trapped in a cage of your own design, and there is escape, but not for you. You’re going to wake up, go to work, gossip about Kendra, then go back to sleep, like you’ve done 100 times before. Only now, you’ll feel slightly better doing it.

Is it worth it: Likely.


Raspberry Pi Set up:

(There are plenty of resources on the internet that go into greater detail about how to set up and connect to your Raspberry Pi).

rpi

From there you can very easily connect from your laptop, into the Raspberry Pi to tell it commands (using ssh) so at that point I have a Raspberry Pi which I can control from my laptop, as long as I am on the same wifi. Here is an Instructables on the matter.

Now the actual lights project began:

It doesn’t really matter what LEDS you buy, as long as they have some IR remote control. I recommend these lights regardless, because they are nice even if you don’t do this entire project.

remote

I recommend get Velcro packs, so that you can hang up the remote around the room.

The important part about the lights you buy is that they have a remote that uses IR (infrared) to communicate to a little box (the white thing in the picture) to tell it to turn on, and what lights to turn on Red Green Blue, or any combination I found this thing online. The way these controllers work is that they pulse IR blasts in a certain pattern to communicate a particular signal. So our goal now, is to get the Raspberry Pi somehow to communicate those codes instead of the controller.

  1. First thing, I did was I bought 1 IR LED. Well, in reality, you can’t buy 1 LED, so I bought 50, but it cost about a dollar, so it was a sacrifice I was willing to make. Connecting the IR led to the GPIO can be dangerous, as you can fry your entire Raspberry Pi – so be careful. http://www.raspberry-pi-geek.com/Archive/2015/10/Raspberry-Pi-IR-remote and other forums say that you need to use a transistor, but powering a single LED does not require very much ampage, and it turns out that you don’t need very high speeds, so just connecting your LED to a pull up resistor is fine. (Namely, 5V to Resistor, to LED, to Pin out 18, and then controlling pin out 18). That being said, I’m not responsible for your electronics – you gotta do what you gotta do.

IR_led

  1. So now, my Raspberry Pi GPIO (pin in/outs) are connected to an IR LED, so now we need to tell them what to do. You can find most of these patterns for any IR remote controller at LIRC.org which basically tells you the IR "codes" for nearly any kind of controllers. To find the IR controls for your particular remote you may have to search the internet for a little bit, but If you want to use the same LEDS at the one that I posted, you can find the config file attached on the sourceforge forum (you can ctrl-f for “lirc44.conf”). Now, you need to set up “lirc” on your Raspberry Pi, to be able to interpret those codes that you just found.

Setting up LIRC

Here is a nice tutorial for how to set up LIRC on your Raspberry Pi.

  1. Now you can control your lights from your home computer, by ssh-ing into your raspberry pi, then typing in the command irsend SEND_ONCE LED_44_KEY POWER. Or any name you want in place of “Power”, as it is written in your .conf file. (This should all be explained in the LIRC webpage).

  2. Here's an example Python program.

  3. Crontab is a program that will allow you to schedule events on linux (i.e. run some program every 5 minutes, or every Friday at 6:01 pm). Install crontab as instructed here. Then type in crontab –e into terminal And you can set your own schedule:

    #min hour dayofMonth month(1-31) dayofWeek(0-6) ./CommandToDo
    20 7 * * 1 python ./Python3Programs/alarmclock.py # JOB_ID_1 monday
    40 8 * * 2 python ./Python3Programs/alarmclock.py # JOB_ID_1 tuesday
    40 8 * * 3 python ./Python3Programs/alarmclock.py # JOB_ID_1 wednesday
    40 8 * * 4 python ./Python3Programs/alarmclock.py # JOB_ID_1 thursda
    30 8 * * 5 python ./Python3Programs/alarmclock.py # JOB_ID_1 friday
    20 9 * * 6 python ./Python3Programs/alarmclock.py # JOB_ID_1 Saturday
    #05 9 * * 7 python ./Python3Programs/alarmclock.py # JOB_ID_1 Sunday