T-Light

by TiemenHoWest in Circuits > Raspberry Pi

182 Views, 0 Favorites, 0 Comments

T-Light

ProjectOnePoster.jpg

Hey there!

For my school project at MCT HoWest Kortrijk, I made the T-Light, this is a smart nighlight with some sensors, like an Light Dependent Resistor, a smoke sensor and a temperature sensor. I also used an LCD display, a speaker and some Neopixels (ledstrip). The speaker is used for an alarm if there is to much smoke in your room but also it plays a sound when the clock alarm goes off. Everything runs on the Raspberry Pi (Database, Webserver and the Backend).

So this instructable is an step by step process of how I realized this project in 3 weeks. I had a lot of work into it but you can recreate my project if you want in a few hours ;)

Supplies

Raspberry Pi 4B

Everything from my project runs on the Raspberry Pi with an image i got from my profs.

Sensor 1: Temperature sensor (OneWire)

The OneWire sensor DS18B20 from Maxim Integrated is a sensor that measures temperature.

Sensor 2: LDR sensor

The LDR measures the Light Dependency i used it for measuring if it's dark in the room or not.

Sensor 3: Smoke sensor

The Smoke sensor measures the air quality of your room, if the air quality isn't good the alarm goes off.

MCP3008 (Analog to Digital converter)

The MCP3008 I used for measuring the LDR and Smoke sensor on the Raspberry Pi because the Raspberry does not have analog inputs.

Speaker

The speaker I used for the sound of the clock alarm and the sound of the smoke alarm.

Adafruit I2S 3W Class D Amplifier Breakout - MAX98357A

The Adafruit amplifier i used for sending data to my speaker.

Adafruit NeoPixel Digital RGB LED Strip

This I used for the nightlight to have some nice lights in there

LCD-display

The LCD-display i used for printing the IP-address of my Raspberry and the time and temperature.

Power Supply

I used this for using 1 wall outlet instead of 2. I can connect the Raspberry Pi and the 5V components to the power supply.

All the Components

Schematic and Wiring

ScreenshotScheme.PNG
ScreenshotWiring.PNG

This is the circuit is used for my project. You can use my schematic and my wiring scheme for making it yourself.

Database

ScreenshotDatabank.PNG

For collecting the data from the sensors, we use a database. The database is running in MariaDB. In the screenshot you see my ERD Entity Relationship Diagram. It was normalised with 3NF. In the database we also keep the Clock Alarms en the Lightcolor.

Setup Raspberry Pi

It's time to setup the Raspberry Pi:

First you i'll need some software

- Win32 Disc Manager

<a href="https://win32diskimager.download/" rel="nofollow">https://win32diskimager.download/</a>

- Putty

<a href="https://www.putty.org/" rel="nofollow">https://www.putty.org/</a>

Setting up MicroSD card

1) Plug in the microSD card in your PC

2) Install Raspberry Pi OS software from the Raspberry Pi website

<a href="https://www.raspberrypi.org/software/" rel="nofollow">https://www.raspberrypi.org/software/</a>

3) Open Win32 Disc Manager

4) Clock on the folder icon and select the image from Raspberry Pi OS

5) Click on the button 'Write'

6) Open the file 'cmdline.txt' with notepad++, add the text: 'ip=169.254.10.1'

7) Now insert the microSD into the Raspberry Pi

8) Connect the Raspberry Pi with your PC with the ethernet cable

9) Turn the Raspberry Pi on.

Connecting Raspberry Pi

1) Open Putty

2) Fill the IP address '169.254.10.1' in the box and click 'Open'

3) Username is 'pi'

4) Password is 'raspberry'

5) Set up WiFi: 'sudo nano /etc/wpa_supplicant/wpa_supplicant.conf'

6) Scroll down until the line 'Network = {'

fill in 'ssid="name wireless network"'

'psk="password wireless network"'

7) Ctrl-X and Ctrl-Y

8) You can refresh your network card with the command

wpa_cli -i wlan0 reconfigure

9) Now you can test it with the command

wget  www.google.com></p><p><strong>Change settings raspi-config</strong></p><p>1) Use commando 'sudo raspi-config'</p><p>2) Select 'Interface options' -> 'Enable I2C' and 'Enable OneWire'</p><p>3) Reboot your Raspberry Pi</p><p><strong>Install Apache</strong></p><p>1) Use the commando </p><p><pre>apt install apache2 -y

With apache you can use a webserver on the Raspberry Pi

Install MariaDB

1) Use the command

apt install mariadb-server mariadb-client -y
now MariaDB is downloaded

2) Use the second command for a secure connection

mysql_secure_installation

Making Python ready

Use the following commands:

pip3 install flask-cors
pip3 install flask-socketio>/pre></p><p><pre>pip3 install mysql-connector-python
pip3 install gevent
pip3 install gevent-websocket

Makerskills

IMG_0828.jpg
IMG_0830.jpg
IMG_0829.jpg
IMG_0832.jpg
IMG_0836.jpg
IMG_0838.jpg
_CLA8934.jpg

The first step was drawing my drafts like you see in the photos. The second step was making the wooden box and the plexiglass box with the rooftop. The third step was putting it all together.

Step 1: Drawing drafts

The first step was drawing my wooden box and how i wanted it.

Step 2: Making the components

Wooden box

The sides are 18 cm * 7.5 cm (4 times) with a bottom of 18 cm * 18 cm

A hole for two buttons of 2cm

A hole for an LCD 7.5 cm * 1.5 cm

Wooden cilinder

15 cm * 2 cm with the LED strips around

Plexiglass

The sides are 30cm * 18 cm (4 times)

A hole for the speaker of 7.5 cm

Rooftop

The roof is 20 cm * 4 cm (4 times) with a top of 20 cm * 20 cm

A hole for the smoke sensor of 2 cm

A hole for the One Wire sensor (temperature) 0.5 cm

A hole for the LDR sensor 0.2 cm

Step 3: Putting everything together

Put the plexiglass on the wood and the rooftop on the plexiglass.