I’ve been working on a few big projects that have been hitting
frustrating roadblocks and I needed a break. So I decided to stop and work on something
simple for a little bit. Making Youtube videos means I spend a lot of time working from home
and especially using my computer. Researching, writing, editing, and even other things like
playing games are just some of the activities I do here and take up the majority of my day. Staring
at a monitor all day makes it really easy to miss how much time is passing by. Sure I have clocks,
but I’m not really paying attention to those when I get in a groove. Another problem I have is my
desk being a bit dark because of the shelf I have over it. The contrast from my monitors to the dark
area leads to some eye strain over the day. I’ve been putting a lamp behind them to help with this,
but I had another idea to solve both of these problems at once. By creating a color daylight
simulator using inexpensive RGB light strips and a raspberry pi. Adding this has changed
how I look at my desk for long use sessions and has made the experience working here
better than I thought it would. I’ll admit, my use case here is somewhat niche, but there are other
ways this could be used so I’m going to go over how this works and how you can make one yourself.
The end result here is going to be a light controller that changes color in a similar
way to how the sun is colored by the atmosphere throughout the day. Everything I’m going to be
covering here is also available in a Github repository that I’ll link in the description.
It has a schematic for putting this together as well the software
I created for this. Now again this is just the controller,
the implementation of a particular style of light is going to be up to you and how you
want to make it. But what I’ve put together will take care of tedious steps of controlling it.
Now to start, when you buy a kit of RGB LEDs you can get them with some kind of controller. There
are a few different basic types of controller and some of them allow you to configure them from an
app with more advanced options. When I first had the idea for this project I figured there must be
something out there that could do what I wanted or at least close. I had pretty low
expectations for this setup at the beginning, I just wanted a light that would change color
at different times of the day. Many of the RGB LED strip controllers advertise schedules, but
everything I read made it look like they’re only for turning the lights on and off. Not changing
colors. But I couldn’t really tell from reviews or the images. I had a couple of uses in mind for
the light strips so I went with a 32ft kit with a full fancy remote and app based controller on
the off chance that no one else cared about color schedules and didn’t think to mention it. But no,
the app scheduling is only for turning it on and off only. So it was on me to make what I wanted.
I think this is overall a fairly representative RGB LED strip kit and there are a few things
I want to mention about these before starting for anyone who may want to repeat this project.
Firstly it comes with these right angle joiners. Do not use these. This will fail,
it’s only a matter of when. And there are plenty of reviews out there talking about these or others
like them smoking or starting fires, and this is what will happen when the contacts become loose
and cause arcing. You should only use wire that is soldered to the contacts to join the strips
which ensures you have a solid connection. And on a related note, this may be specific to my kit,
but the connection to the controller is unsafe as well. The strips came with machined
100 hundred mil connectors which will be better for higher current connections. But one of the
mating connectors on the controller doesn’t fit right and the pins are extremely loose creating
another possible point for arcing. I don’t have a solid recommendation for this problem if you
need to use the controller. But if yours is like this you may want to return it. Another issue,
these lights are produced in sheets that are then cut into strips and soldered together.
So there are solder joints quite frequently. You should really take a look at all of these
for problems before you power the lights for the first time. This may also help you notice
other production issues. This section of strip was offset slightly when cut
and broke the blue light trace. This caused it and all downstream lights to be missing
the blue channel and I had to remove this section. Essentially all this boils down to keeping in mind
these are not a refined quality product and you may need to re-engineer some things about them.
Alright, now that we know that these are garbage and have made sure they won't catch fire we can
continue. Before I committed to making this a full project I set up the lights draped behind
my monitors and set up custom colors using the good side of my controller to the colors I had
in mind for a daylight cycle. I used this for a couple days while working on other projects
and manually advanced the colors at different times of the day. I ended up really liking this
and was increasingly motivated to make something automatic and more permanent. In the end I decided
I wanted a solution completely independent of a computer or other device so I decided to use some
kind of embedded system for it. I also wanted automatic time syncing which meant I needed
something with WiFi. I actually have an embedded system clock that uses an 8051 to keep time
and it drifts badly, so I don’t want to rely on anything like that to keep time over long periods.
I was also given the idea to have the light accurately change the local sunrise and sunset
times throughout the year. And that is very possible and not all that difficult to do,
although for the moment I’m not interested in learning all the math to calculate the position
of the sun myself. But more importantly for a released project like this it will need to be
able to handle different locations and timezones, which would be a lot of extra monotonous work. So
I looked up what libraries already exist for this and Astral for python seemed like an ideal choice
after reading over the docs. With that the best choice for the project was pretty clear
and I settled on using a Raspberry Pi for this. I planned on using a zero W but the two I had both
ended up having bad WiFi radios for some reason so I went forward with an overkill 3 B for now.
Anyone following along with this could easily use a working zero W instead.
Next we have to control the lights and thankfully driving the LEDs is easy.
These strips are standardized to common anode with three elements in series with current limiting
resistors included. The forward voltage of the LEDs is gonna to be around 3V each and a 12V DC
PSU is what was meant to power them. We’ll need to be able to control the 12V power source with the
Pi to control the lights so we need some kind of driver to interface with. I’m far from the first
person to want to connect RGB strips to a Pi and the generally accepted way seems to be with TIP
120s. They are a darlington transistor pack which gives them excellent current throughput capacity.
And being an NPN BJT makes them well suited to the low side driving that we need to do.
Also being a darlington they have a very high gain meaning we don’t need a lot of current
to activate them. So now we have a basic idea on how to control the lights, if we throw in a power
connector and pick some GPIO on the Pi we have a schematic of what you need to make. We should
add some 1k resistors between the GPIO and base on the transistor to limit the current from the Pi.
Assembly really isn’t difficult, let’s walk through the process on a breadboard with a
small strip. You don’t want to do this for a lot of lights because breadboards don’t do
well with high current. You need to connect the base of the transistor, which is the left pin,
to the GPIO on the Pi. Make sure to have the resistor in between. The emitters,
the right pin, all get grounded. And the collectors, the center pin, are connected
to the LED strips color connections. And that’s the basic setup of the circuit. Using the Pi we
can confirm all the lights can be controlled. For a final version you’ll again want to solder this
together on a PCB instead of a breadboard but this is how it needs to be laid out.
To set up the daylight control of the lights you’re not going to need to do much,
I’ve written a program that can do this already and is up on
github so you can just download that and be good to go. Start off by preparing your Pi OS SD card
however you prefer, using the flashing tool and loading Raspian will work just fine. Go
through the basic setup steps after that to get it working, I recommend setting it to automatically
log in to make it easier to auto run the program on power up later. To use my daylight controller
software you’ll need to install two dependencies, astral which can be done with pip and the slightly
more complicated step of installing pi-blaster by following their compilation instructions.
Pi-blaster is a GPIO interface program that uses hardware level PWM on the Pi which means the OS
won’t get in the way. There isn’t anything you need to configure with either of those once they
are installed. My software can be cloned from the git repository and then run to generate an initial
configuration file. This is where all the settings you may want to change are stored. The github page
goes into further detail on them all but I’ll briefly cover some of the basics here. First,
you’ll need to make sure your GPIO pin numbers are correct for how you built your driver interface.
Next to get the correct times for where you are you need to determine your timezone and provide
a latitude and longitude. I highly recommend using the location of a nearby airport for
checking against known values and for security reasons. There are some other things you can
personalize but we’ll come back to those after the next section. And just a note, if something
isn’t working after changing a setting you can delete that one setting or the whole file and
it will automatically be created again with the default value on the next program launch.
With that taken care of you’re now ready to build an artificial daylight source. You could put this
up anywhere. My use case was again putting lights on my monitors but you could easily use this to
make a fake window. Putting up a curtain rod and putting up lights that point out from the
sides would be a very easy and convincing way to achieve this. To demonstrate this idea though I
pulled down a set of window blinds which you can get for about $20-40 and create a cool effect
with. And since I pulled these off a window I’m just going to do a temporary setup on the back
of a sliding door. For the blinds you are going to want to try and create as even and smooth of
an effect as possible. I’m putting the lights on a piece of dollar store foam board that I can hang
behind them. I’m putting them on perpendicular to the surface and up against each other so that
they will illuminate the white as much and as thin as possible. Then I can hang the whole thing up.
Before I hang the blinds over them though I’m going to attach a thin white
sheet to act as a diffuser. And once it’s hung up we can see how it looks, and
I think that looks pretty darn good. Now again, this is just a temporary demonstration.
I would probably want to add more lights to this if I were doing it for real. But
this is also a pretty big 3ft wide set of blinds. This is something that you could
easily customize and play around with to get the ideal results for how you want to make
it. Also, the sheet I have in there does cut a fair amount of the light and removing it makes it
much brighter, but you’re likely to see the LEDs then so it’s probably not a worthwhile tradeoff.
Now that we have something set up, let’s take a look at the other options we have
to configure the software. There are three options that change the output of the light,
the intensity is fairly obvious as it just changes how bright the lights are
overall. The white balance is something you are going to need to tune for your lights. These LED
strips don’t match any kind of color standard out of the box and having all elements fully on
probably isn’t going to look completely white. Using this setting will allow you to customize
the maximum brightness for each color to make sure when it is set to white they are all even.
This is definitely something you will have to tune for your particular setup. To test this you
can run the program with a “test-color” option and specify noon which is pure white by default. The
last setting are all the colors the lights cycle through. The software will slowly blend through
different colors throughout the day to create the daylight effect. There are different colors for
dawn, sunrise, noon, sunset, and dusk as well as night. There are currently two night colors for
programming purposes right now, they should both be set to the same color though due to a bug that
won’t blend them correctly. I’ll fix that later. These colors default to more subtle realistic
values to make the light seem more “real” but you can change them to anything you want.
So if you want a green sunrise and magenta sunset you can go right ahead and do that. For my use
I’m using slightly more saturated colors for the different times of day to make the
daylight change more obvious. So I like having this be easier to change. You can easily test
all of the colors by running the program with the “test” option which will rapidly cycle through the
entire daylight routine. Once you’re happy with it, you can make the program autostart
on login with the pi user by adding it to the “.bashrc” file in the home folder. Do make sure
you change the user password if it’s network connected before you leave it running though.
Well that pretty much wraps this up, I couldn’t really find any other projects trying to do
this online but based on the reactions I got after posting about my setup on Twitter and
other places I suspect there are going to be a number of people who like this
idea. If you do build one of these I would be fascinated to see how you did it if you
want to tag me on twitter with pictures. This isn’t the normal kind of video I make but I
really needed a break from some of my other projects that were going awry and this has
been kicking around the back of my head for a while. But I hope you enjoyed this and if you
want to support the channel I am on Patreon. But that’s it for and I’ll see you next time.