Introduction: Raspberry Pi Blind and Fan Controller
Did you ever wanted to wake up with your blind automatically opening when there is light outside or when it is too hot in your room and you want the fan to be automatically turning? Then this project is great for you!
You can also manually control the blind and fan and check in 'logs' when you manually and automatically controlled your blind or fan.
In this instructable I will explain you how to build this prototype using a Raspberry Pi, MySQL database and Flask. To recreate this project I assume you have basic knowledge of Python, Flask, Raspberry Pi, MySQL, HTML and CSS.
This project is an assignment for school.
Step 1: Materials
- Raspberry Pi
- Step motor with ULN2003A Chip
- MCP3008 Chip
- Light sensor
- Temperature sensor
- Resistor 4.7K (or put 2 resistors of 10K parallel)
- Resistor 1K
- Fan (12V)
- 9V battery to power the fan
- bc517 transistor
Try to put your own imaginination and input on decorating tools.
Step 2: Electric Circuit
You should be able to setup the electric circuit by yourself IF you carefully check everything 10 times!
Step 3: Configuring Raspberry Pi (OS)
Download and install following programs:
- raspbian lite image (OS for the pi)
- win32 disk imager (to set image on SD card)
- putty (to log into the pi through SSH)
- pycharm (to program the pi)
- python 3 (so you can execute python 3 code)
open win32 diskimager. Select the rasbpian lite image, after that select your device (your microSD) and write your image on it afterwards.
After writing op up "cmd.txt" and add this code just before rootwait
Step 4: Setup and Configuring Raspberry Pi With Putty
Plug in the raspberry pi and connect it with an networkcable to your computer, after that open up putty and try to connect to it with the following ip address: 169.254.10.1 and set it on SSH. Make sure you are using port 22. Once you are connected to the raspberry pi to have to log in with following credentials:
- username: pi
- password: raspberry
Make sure the OS is up to date by using the following command:
sudo apt-get update && sudo apt-get upgrade
After this, install MySQL database:
sudo apt-get install-server
sudo apt-get install-client
When you do these command it will ask you for a password, you can just type "password" if you want to, so goes for my code. give the user full control.
mysql -uroot -p
at last install mysql.connector with the following command:
sudo apt-get install python3-mysql.connector
Step 5: The Program
You can download the project called "SmartBlinds" on my GitHub here.
If you run the program and surf on your browser 169.254.10.1:5000
You will be redirected to the login page to login. You can login with username "admin" and password "admin".
If everything is working correctly you will be directed to the home page where you can manually open and close the blind and aswell turn on and off the fan.
Further you are able to set an automatization called 'scene' on the blind to let it react automatically on light and the fan on the roomtemperature.
On "logs" you can view the manual and automatic logs with time kept in the database.
We have a be nice policy.
Please be positive and constructive.