Introduction: Blind and Light Automatisation With Raspberry Pi, Flask and Mysql Database

Picture of Blind and Light Automatisation With Raspberry Pi, Flask and Mysql Database

I am a student at Howest Kortrijk, and I made this project called: "BlindBerry" for school.

Did you ever got stuck in the moment where you were already laying in your bed and realised that your blinds and lights were still on? Well, I have the perfect solution. This model represents a room and how it should work in the real life.

On this page I will show you how to build it yourself, using a Raspberry Pi, Flask and MySQL database. I will assume you have basic knowledge of HMTL, raspberry pi and MySQL

Step 1: The Materials We Will Need

Picture of The Materials We Will Need

Here is the list of materials you will need to build this project, in total it will cost about 75 euro's.

List of materials

  • Raspberry Pi
  • MicroSD
  • Step motor with ULN2003A Chip
  • MCP3008 Chip
  • Light sensor
  • Resistor 4.7K
  • Resistor 200 Ohm
  • Temperature sensor
  • Led
  • Wood
  • Paint
  • Your own input on decoration

Tools

  • A drill
  • Saw instrument
  • And A LOTof Tec-5 (this fixes everything together)

Step 2: The Electric Circuit

Picture of The Electric Circuit

With a lot of concentration you should be able to build this electric circuit, remember to check and double check your circuit, we don't want to fry our Raspberry Pi!
You can open the FZZ file with a program called Fritzing.

Step 3: Configuring the Raspberry Pi

Picture of Configuring the Raspberry Pi

Before we can get to the fun part we have to configure our Raspberry Pi.
First of all we will need to download some things:

Downloads

  • Raspbian, this is our operatingsystem. It's a kind of Linux made for the Pi.
  • Putty, we will use this to connect to your Raspberry Pi.
  • Win32, so we can "write" Raspian to our Pi

Instructions

First of all install Win32 with the basic installation settings.
Next pick the raspbian file and set your microsd card as destination device.

If everything is right we can connect to our Raspberry Pi with Putty using a SSH-connection. Fill in your apipa-adress wich is: 169.254.10.1. You can login with the following credentials, Login: "pi" and password: "raspberry".

Now we need to fill in a commando to update the software:

sudo apt-get update && sudo apt-get upgrade

Step 4: Configuring MySQL

Picture of Configuring MySQL

Because we need to save some data we need to use a simple database, nothing that hard we can't handle.

Instructions
First we got to install MySQL with following code:

sudo apt-get install mysql-server

To connect with the database we need a client, copy following code:

sudo apt-get install mysql-client

Next we have to connect to MySQL with root, this user has full control.

mysql -uroot -p

Now we will create a new database.

CREATE DATABASE db_BlindBerry;

Make sure you have MySQL workbench installed because this will make everything much easier.

You can with this program connect remotely to the database on the Raspberry Pi. View on the print-screen the settings you have to use.

Now all you have to do is import the sql-script.

Sitenote: never use root as default login!

Step 5: The Program Itself

Picture of The Program Itself

You can download the project on my GitHub here.

If you run the program and surf on your favorite browser the following address: 169.254.10.1:5000

You will see now the login page, you can create a user or login with: "admin", "admin".

If everything is all right you will now see the controls for your blind and light. Also the temperature in the room.

On the page automatisation you will see you can automate your blinds

The page "Grafiek" will show you the last 10 temperatures.

Step 6: Final Product

Picture of Final Product

You can put your own creativity to work here, or just make it full scale!

Comments

Swansong (author)2017-06-20

Thanks for sharing :)

About This Instructable

191views

5favorites

License:

More by MathiasVanHecke:Blind and Light Automatisation With Raspberry Pi, Flask and Mysql Database
Add instructable to: