# Circadian Pi Desk Light

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/071/335/medium800/raspberry_pi_IMG_1755.jpg?1550354674)

Blue light in the morning and red light in the evening can help us adopt a more natural circadian rhythm. Blue light is stimulating and ideal to be exposed to early in the day while the removal of blue light allows melatonin production to ramp up so red light in the evening can help get us ready for bed. The Raspberry Pi is the perfect device to help with the timing and driving of long NeoPixel strips. In this post we will show how just a few wires, some code, and a tiny bit of hardware, we can have a light with some circadian awareness.

![](https://cdn-learn.adafruit.com/assets/assets/000/071/336/medium800/raspberry_pi_IMG_1746.jpg?1550354807)

## Parts
Featured
### Raspberry Pi 3 - Model B+ - 1.4GHz Cortex-A53 with 1GB RAM

[Raspberry Pi 3 - Model B+ - 1.4GHz Cortex-A53 with 1GB RAM](https://www.adafruit.com/product/3775)
The Raspberry Pi 3 Model B is the most popular Raspberry Pi computer made, and the Pi Foundation knows you can always make a good thing _better_! And what could make the Pi 3 better? How about a&nbsp;_faster_ processor, 5 GHz WiFi, and updated Ethernet chip with PoE capability?...

In Stock
[Buy Now](https://www.adafruit.com/product/3775)
[Related Guides to the Product](https://learn.adafruit.com/products/3775/guides)
![Angled shot of Raspberry Pi 3 - Model B+](https://cdn-shop.adafruit.com/640x480/3775-11.jpg)

Featured
### Adafruit NeoPixel Digital RGB LED Strip 144 LED - 1m Black

[Adafruit NeoPixel Digital RGB LED Strip 144 LED - 1m Black](https://www.adafruit.com/product/1506)
We crammed **ALL THE NEOPIXELS** into this strip! An unbelievable 144 individually-controllable LED pixels on a flexible PCB. It's completely out of control and ready for you to blink. This strip has a black mask, and an extra heavy flex PCB.  
  
These LED strips are even more...

In Stock
[Buy Now](https://www.adafruit.com/product/1506)
[Related Guides to the Product](https://learn.adafruit.com/products/1506/guides)
![Adafruit NeoPixel Digital RGB LED Strip wired to a microcontroller, with all the LEDs in a rainbow](https://cdn-shop.adafruit.com/640x480/1506-00.jpg)

Featured
### Half Sized Premium Breadboard - 400 Tie Points

[Half Sized Premium Breadboard - 400 Tie Points](https://www.adafruit.com/product/64)
This is a cute, half-size breadboard with&nbsp;400 tie points, good for small projects. It's 3.25" x 2.2" / 8.3cm&nbsp;x 5.5cm&nbsp;with a standard double-strip in the middle and two power rails on both sides.&nbsp;You can pull the power rails off easily to make the breadboard as...

In Stock
[Buy Now](https://www.adafruit.com/product/64)
[Related Guides to the Product](https://learn.adafruit.com/products/64/guides)
![Angled shot of half-size solderless breadboard with red and black power lines.](https://cdn-shop.adafruit.com/640x480/64-06.jpg)

- [Pi Cobbler Plus](https://www.adafruit.com/product/2029)&nbsp;or&nbsp;[Pi T-Cobbler Plus](https://www.adafruit.com/product/2028)
- [Female DC Power adapter](https://www.adafruit.com/product/368)
- [5v 10A switching power supply](https://www.adafruit.com/product/658)

# Circadian Pi Desk Light

## Circuit Diagram

## Wiring
We are limited to just a few pins on the Raspberry Pi to drive NeoPixel strips (D10, D12, D18 and D21). You can see the **white** wire is our control line (D18) and the **black** is our shared **ground**. The other **red/black** wire of the NeoPixel strips can go right into the marked +/- barrel jack terminal block. That is it. We are wired up. This wiring will work on all releases to date of Raspberry Pi v1, v2, v3 and Zero.

![](https://cdn-learn.adafruit.com/assets/assets/000/071/337/medium800/raspberry_pi_Circadian_Pi_bb.png?1550354838)

The [10A power supply](https://www.adafruit.com/product/658) will connect to the female barrel jack and the female NeoPixel header will connect to our **GND** and **GPIO #18** on the Cobbler Plus breadboard.

![](https://cdn-learn.adafruit.com/assets/assets/000/071/338/medium800/raspberry_pi_IMG_1752.jpg?1550363275)

# Circadian Pi Desk Light

## CircuitPython Code

## Pi Config
Make sure your Pi is running the latest version of Raspbian and has the following Adafruit blinka and neopixel libraries installed.

1. [Prerequisite Pi Setup](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi)
2. Updates for an existing Pi
  1. `sudo apt-get update`
  2. `sudo apt-get upgrade`

## Library installation

1. `sudo pip3 install adafruit-blinka`
2. `sudo pip3 install adafruit-circuitpython-neopixel`

## Code
This script is intended to turn on blue light in the morning for a four hour window, then turn the lights off for most of the day. In the evening, it will turn on red lights for a four hour window and then the LEDs will be turned off for the night. You can customize the timing, color and duration by modifying this script.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Circadian_Pi_Desk_Light/Circadian_Pi_Desk_Light.py

# Circadian Pi Desk Light

## Run it!

![](https://cdn-learn.adafruit.com/assets/assets/000/071/339/medium800/raspberry_pi_IMG_1753.jpg?1550364268)

## Configure TimeZone

Run the **raspi-config** command as shown below to select your Time Zone if it has not already been configured.&nbsp;

- _Localisation Options_ 
- _Change Timezone_
- _Geographic Area_
- _Time Zone_

```auto
sudo raspi-config
```

![](https://cdn-learn.adafruit.com/assets/assets/000/071/375/medium800/raspberry_pi_tz1.png?1550512176)

![](https://cdn-learn.adafruit.com/assets/assets/000/071/376/medium800/raspberry_pi_tz2.png?1550512191)

![](https://cdn-learn.adafruit.com/assets/assets/000/071/377/medium800/raspberry_pi_tz3.png?1550512205)

![](https://cdn-learn.adafruit.com/assets/assets/000/071/378/medium800/raspberry_pi_tz4.png?1550512223)

## Download the Code
The most convenient way to get the program on your Pi will be to use the 'wget' command from a terminal and place the script directly into your home directory.

```auto
wget https://raw.githubusercontent.com/adafruit/Adafruit_Learning_System_Guides/master/Circadian_Pi_Desk_Light/Circadian_Pi_Desk_Light.py
```

## Running the Code
The desk light program can be launched once with the following command. It will automatically change the colors based on the time values placed in the script such as:

```auto
# morning BLUE light hours
# BLUE light is stimulating
start_morning = "06:00:00"
end_morning = "10:00:00"

# evening RED light hours
# RED light is calming allows melatonin production to increase
start_night = "18:00:00"
end_night = "22:00:00"
```

```auto
sudo python3 ./Circadian_Pi_Desk_Light.py
```

![](https://cdn-learn.adafruit.com/assets/assets/000/071/340/medium800/raspberry_pi_IMG_1754.jpg?1550364288)


## Guide Products

### Raspberry Pi 3 - Model B+ - 1.4GHz Cortex-A53 with 1GB RAM

[Raspberry Pi 3 - Model B+ - 1.4GHz Cortex-A53 with 1GB RAM](https://www.adafruit.com/product/3775)
The Raspberry Pi 3 Model B is the most popular Raspberry Pi computer made, and the Pi Foundation knows you can always make a good thing _better_! And what could make the Pi 3 better? How about a&nbsp;_faster_ processor, 5 GHz WiFi, and updated Ethernet chip with PoE capability?...

In Stock
[Buy Now](https://www.adafruit.com/product/3775)
[Related Guides to the Product](https://learn.adafruit.com/products/3775/guides)
### Adafruit NeoPixel Digital RGB LED Strip 144 LED - 1m Black

[Adafruit NeoPixel Digital RGB LED Strip 144 LED - 1m Black](https://www.adafruit.com/product/1506)
We crammed **ALL THE NEOPIXELS** into this strip! An unbelievable 144 individually-controllable LED pixels on a flexible PCB. It's completely out of control and ready for you to blink. This strip has a black mask, and an extra heavy flex PCB.  
  
These LED strips are even more...

In Stock
[Buy Now](https://www.adafruit.com/product/1506)
[Related Guides to the Product](https://learn.adafruit.com/products/1506/guides)
### Half Sized Premium Breadboard - 400 Tie Points

[Half Sized Premium Breadboard - 400 Tie Points](https://www.adafruit.com/product/64)
This is a cute, half-size breadboard with&nbsp;400 tie points, good for small projects. It's 3.25" x 2.2" / 8.3cm&nbsp;x 5.5cm&nbsp;with a standard double-strip in the middle and two power rails on both sides.&nbsp;You can pull the power rails off easily to make the breadboard as...

In Stock
[Buy Now](https://www.adafruit.com/product/64)
[Related Guides to the Product](https://learn.adafruit.com/products/64/guides)

## Related Guides

- [Adafruit NeoPixel Überguide](https://learn.adafruit.com/adafruit-neopixel-uberguide.md)
- [BLE Volume Knob with CircuitPython](https://learn.adafruit.com/bluetooth-le-hid-volume-knob-with-circuitpython.md)
- [Adafruit IO Basics: Digital Output](https://learn.adafruit.com/adafruit-io-basics-digital-output.md)
- [Boomy The Boombox](https://learn.adafruit.com/boomy-the-boombox.md)
- [LoRa and LoRaWAN Radio for Raspberry Pi](https://learn.adafruit.com/lora-and-lorawan-radio-for-raspberry-pi.md)
- [CLUE Metal Detector in CircuitPython](https://learn.adafruit.com/clue-metal-detector-circuitpython.md)
- [Using micro:bit and CRICKIT with MicroPython](https://learn.adafruit.com/using-micro-bit-and-crickit-with-micropython.md)
- [Adafruit IO Basics: Analog Output](https://learn.adafruit.com/adafruit-io-basics-analog-output.md)
- [Color Remote with Circuit Playground Bluefruit](https://learn.adafruit.com/color-remote-with-circuit-playground-bluefruit.md)
- [Digital Inputs with Adafruit IO WipperSnapper](https://learn.adafruit.com/digital-inputs-with-adafruit-io-wippersnapper.md)
- [Animatronic Fizzgig MonsterM4sk Puppet](https://learn.adafruit.com/animatronic-fizzgig-monsterm4sk-puppet.md)
- [Adafruit IO Home: Lights and Temperature ](https://learn.adafruit.com/adafruit-io-house-lights-and-temperature.md)
- [Adafruit IO Basics: Color](https://learn.adafruit.com/adafruit-io-basics-color.md)
- [Adafruit Feather HUZZAH ESP8266](https://learn.adafruit.com/adafruit-feather-huzzah-esp8266.md)
- [Using LoraWAN and The Things Network with CircuitPython](https://learn.adafruit.com/using-lorawan-and-the-things-network-with-circuitpython.md)
- [Comparison and Experimentation with Flammable Gas Sensors](https://learn.adafruit.com/gas-sensor-comparison.md)
