Introduction: Basic Room Automation

About: student MCT at Howest (Kortrijk Belgium)


for my school project I made a mini home automation system. This could be used for people who work in the office all the time and forget to regulate the lighting, open the window or cool the room when its to hot. I’ve been that guy to many times while I play games or work for school. I just need to make this for my room in real life and I’m good to go! For now it’s just for my friend ‘Anthony’, a play mobile figure…

What :

A mini home automation system that regulates temperature, lighting and air quality for us hard working office people. It works automatic but you regulate everything on the website.

Why :

As I mentioned before, I made this for a school project. It’s something I would love in real life so maybe one day I can build it for my room who knows…


Step 1: The Case

In the files you you find all the sizes you need to create the sperate wood or mdf panels. I used a CNC machine to make the holes. Using that machine is not a must! You can use more basic tools and achieve a simular result.

The pieces are made to nicely fit in each other so with some glue you can put them all togheter.

Note that the "fake" inner wall is not glued so I can take it out, same for the "fake" ceiling, the outer piece of the "fake" wall and the ceiling itself. We will need to acces the fake ceiling and fake wall later when we put in the electronics.

Next you can paint the box if you wish to do so. I used white paint but it can be any color you want.

Step 2: Electronics

Please use the fritzing breadboard file when you make the circuit. I suggest that you use the same pins as me or you could be in some trouble. Since we already made the box there is no need to make a "test" circuit, you can build it in 1 of 3 ways listed below.

There are multiple ways of putting this circuit in the box.

The "lazy" way:

  • You can fit the breadboards between the fake wall and the actual wall then use longer wires to reach the sensors on top.

The "more professional" way:

  • You can do like me and make a pcb where you solder everything on it so it's a bit more professional

The "this is for my job" way:

  • You still need a pcb you you order one where the wires are part of the pcb so you just need to solder the components and some wires to reach the top of the box.

Step 3: Setting Up the PI

For those who have never coded on a Pi yet, you first need to set it up.

This link will show you how to work remotely using ssh.


This link will show you how to setup the databaseserver


Then you will want to install some packages, select the folder you had to create using the guide and open a terminal.

You need to install:

  1. pip3 install mysql-connector-python

  2. pip3 install flask-socketio

  3. pip3 install flask-cors

  4. pip3 install gevent

  5. pip3 install gevent-websocket

Step 4: Connecting MySQl

Once you have opend MySQl workbench you need to make a new connection.

The connection should look like the picture above.

  • Obviously you name it to whatever you like, I named it "Raspi"
  • Then you set the connection method to "Standard TCP/IP over ssh", THIS IS VERY IMPORTANT
  • The ssh hostname is just the IP address of your PI
  • Ssh username is the user of your pi
  • Mysql hostname does not need to change
  • The port doesn't need to be changed either
  • Username should be your workbench username.

Link to mysql workbench:

Step 5: the Code

In the repository you'll find the nessessary code.

Note that you need arduino aswell, the code for reading the air quality is written in arduino.


Library for the air quality sensor:

Just placing all the files in visual studio code is probably not going to work.

First you'll need to check if:

  1. Serial communication is activated on your PI
  2. SPI is activated on your PI
  3. One wire is activated on your pi

Then you can place the backend code where ever you like on your pi but the "html" folder needs to be in /var/www.

Feel free to change the code and improve the project.

Step 6: The Database

To save the data and to be able to use the system you need this MySQL database.

I used Maria DB as database management system on my Raspberry Pi (

If you don't understand the database, you can read the "DB help" and hopefully understand everything.

The data in the database should be left there. This is for the devices, without this data the system will not work.

Step 7: Step 5 Testing the Program

In order to be able to test if everything works, you will first need to plug in your PI, and the power supply. It is absolutely necessary to have a 3.3V and 5V power supply. If you miss 1 of them the project is not going to work.

To get to the website you just need to google the IP-adress of you PI.

Then you can register, log in and explore.