Easy Wake-Up: a Smart Wake-Up Light Made With Raspberry Pi

by Ruben Goethals in Circuits > Raspberry Pi

1708 Views, 4 Favorites, 0 Comments

Easy Wake-Up: a Smart Wake-Up Light Made With Raspberry Pi

IMG_0692.JPG

Intro

For the curriculum Project1 I had to make something. I was always fascinated about how a wake-up light like would benefit you in waking up like the ones from philips.

So I decided to make a wake-up light.

I made the wake-up light with a Raspberry Pi as base, a led strip, speakers and a couple of environmental sensors to get measurements.

Here are its features:

  • Webserver gets hosted on the Pi
  • Data gets exported to a MySql database
  • Webpage that shows data
  • Webpage that execute statements

This project has been a great learning experience for me. It got me solving some unexpected problems. I learned quite a bit about the capabilities of the Pi and how php communicate with everything.

Gathering the Materials

2329-08.jpg
987-00.jpg
386-00.jpg
1314-00.jpg
4007-00.jpg
498-06.jpg

For my project I need it multiple parts that I will be listing below, There will be also an excel file with all the the prices of the components with corresponding websites from where I ordered them.

Components:

  • Raspberry Pi 3 model B+
  • Raspberry Pi power supply
  • Raspberry Pi T-cobbler
  • Stereo 3.7W Class D Audio Amplifier-Max98306
  • 2 x Speaker - 3" diameter - 4 Ohm 3 Watt
  • RGB Backlight negative LCD 20x4
  • Adafruit Dotstar Digital LED Strip - White 144 - 0.5 meter
  • Ultrasonic sensor HC-SR04
  • DHT11 sensor
  • Jumper wires (m to f) and (m to m)
  • 470 Ohm & 330 Ohm resistor

Material design:

  • MDF wood 7mm
  • plastic

Tools:

  • Soldering iron
  • Glue gun

In total the materials will cost around 210 Euros.

Wiring All the Compenents Together

screenshot.PNG
IMG_0711.JPG
IMG_0715.JPG

I build the circuit by following the Fritzing scheme that I made, you can find the documents pdf of the breaboard and electrical scheme below.

The circuit has multiple sensors, speakers, lcd display and a led strip that works together as one. I will list for each component on how you will need to connect these and can find in the scheme.

  1. The Ultrasonic sensor: this sensor calculates the distance between the sensor and a object in front of him. With this function we can automate certain abilities by holding your hand infront of it. It has 4 pins: ground, 5V, trigger and an echo. Echo output needs resistors between the ground and the echo pin.
  2. The DHT11 sensor: this sensor measures the temperature and the humidity. If you buy one with a PCB than the 10k resistor is soldered with the sensor already and makes it super easy to wire it up.
  3. The ledstrip: for the ledstrip an external power supply is need it to power it up otherwise you can dmg your raspberry pi without using one. DI wire goes to the MOSI pin of the pi and CI goes to the SCLK pin.
  4. The lcd display: specially the rbg displays requires alot of wires, all of used pins of the pi can be used with normal GPIO.pins. It also has a potentiometer with it to change the contrast of the display.
  5. The push button: I use it to put the raspberry in shutdown mode and by pressing again to wake-up mode. Normally open connection is need it for it.
  6. At last the amplifier with the speakers: since we use just speakers we need an amplifier to make the signal strong enough to produce sound. Its connected with the audio input of the raspberry pi.

Setting Up the Pi

raspberry_pi.jpg

First of all you will need Raspbian which you can download here.

I used a monitor connected with the hdmi of the raspberry pi after installation of the sd card. With mouse and keyboard connected to the usb ports of the pi. Then you follow the begin settings on the screen to initialise the raspberry pi, make sure to change in the configuration panel certain functions like SPI, I2C, ... to enable.

Enter the following command in your command prompt on your Pi:

sudo apt-get update

This may take a while, so get comfortable. After the update we will upgrade

sudo apt-get upgrade

Installing Modules & Packages and Setting Up the Webserver

blinkapi.jpg
Knipsel2.JPG

We install each modules for python with:

sudo pip3 install name_of_module

List of modules need it:

  1. adafruit-circuitpython-charlcd
  2. adafruit-dht
  3. adafruit-circuitpython-dotstar
  4. adafruit-blinka
  5. RPI.GPIO

There could be more but if you get an error that says can't find the module, just install it.

Also the following command, because you need version 3.4 and not 3.3!

python3 -m pip install --upgrade --force-reinstall spidev

For setting up a webserver I used flask.

Applying the Code

FZ5TRYBJ3YQNX1A.LARGE.jpg
Knipsel.PNG

For the code you need to make sure that everything is in the folder of /var/www/html

You can get the code from Github.

The site is also responsive so it could be opened on mobile without losing features or otherwise.

While the Pi is booting up, it will start running my main python script. This will be taking care of getting the data to show on the website. To add a script on boot you need to do systemd preferable way. Check link.

For the button you need to use physical pin 5 of the pi and the ground. Use pins on the button, normal open pin and common pin. Btw polarity doesn't matter!

Do the following commands in the terminal of your raspberry pi and you should be able to shutdown and startup your pi with the button press.

git clone https://github.com/Howchoo/pi-power-button.git
./pi-power-button/script/install

Building the Housing

DSC_0554.JPG
DSC_0565.JPG
DSC_0570.JPG
DSC_0584.JPG
DSC_0587.JPG
DSC_0589.JPG

For the housing I used scavanged wood that I cut into pieces and putted together by glue. For making the front a bit slant I had to calculate the slant side because when you don't calculate it, even if it's not a huge slant the wooden pieces won't fit together.

You must always be very careful with the measurements on the wooden pieces, because you can sometimes forget the thickness of the wood.

The holes were done with drill and sawing machines.

After that was done you can start painting it, I used spray painter with brown color for it. Make sure you do it outside and try to stand away from where the toxic fumes are going to.

For the speaker and the backside I used scews to connect them.

The top I used plastic that also got glued.

Finnaly I added some device feets.