My Domotica
![20210614_192319.jpg](/proxy/?url=https://content.instructables.com/F2M/EPCZ/KPX8ZL75/F2MEPCZKPX8ZL75.jpg&filename=20210614_192319.jpg)
My Domotica is a system that makes your house safer and easier to control. I build this project because I am interested in home automatisation and I like doing it. You can control the temperature, alarm and a light with the site. The light automatically turns on and off with the help of a motion detector. At last there is a smoke detector for the safety.
Downloads
Supplies
These are the components that are needed for this build.
- Raspberry PI
- Resistors :
- 220 Ohm
- 110 Ohm
- LCD screen
- Buzzer
- TMP36
- MCP3008
- 74HC595 shift register
- 3v-5v step up module
- 5v - 230v relais
- Lamp
- mini PIR
- BC547 transitor
- Raspberry Pi 5v fan
- 5v and 3v source
- MQ-135 smoke detector
- Potentiometer
The total price is around €64
Tools Required
- Soldering iron
- File
- Drill
- Screws
- Woodwork tools
Circuit Diagrams
![schema_schema.png](/proxy/?url=https://content.instructables.com/FVE/245R/KPX8ZMD0/FVE245RKPX8ZMD0.png&filename=schema_schema.png)
LCD screen
On the LCD screen you can see the ip-adress to wich you can surf to go to the site. You can also see the temperature on the screen. The 74HC595 is a shift register used to control the LCD screen. If I dont use a shift register, the LCD screen would take up to much IO pins.
TMP36
The TMP36 is a temperature sensor. The temperature sensor has an analog output, thats why I use the MCP3008.
MCP3008
The Raspberry Pi can't read analog signals so that is why we use the MCP3008. The MCP3008 is an analog to digital converter(ADC). This is used to convert analog signals that come from sensors and convert them into digital signals.
MQ-135
The MQ-135 is a smoke detector that can give an analog and digital output. I use the analog output and connect it to the MCP3008
Mini PIR
The mini PIR is a pyroelectric infrared motion sensor. The sensor gives an analog signal when it detects movement. It can detect movements from 3 meters far. This sensor is also connected to the MCP3008.
Buzzer
The buzzer is used as an alarm. It is connected to a 110 Ohm resistor. If you give the buzzer a digital signal it will make a loud sound.
Raspberry Pi Fan
This is the fan to control the temperature. If the temperature is to high the fan will turn on. The fan is controlled with an BC547 transistor. This is because the fan runs on 5v but the RasPi(Raspberry Pi) can only supply 3v so I used a transistor.
Lamp
The lamp is controlled by a relais that switch 230v and 30A. It is a 5v -230v relais, this means you give a 5v signal. Like I said before the RasPi can only suply 3v so that is why I use a 3v-5v step up module. I can use a transistor here because the transistor can't deliver enough current.
Making the Circuit
![200346819_537778010918359_953312354507695314_n.jpg](/proxy/?url=https://content.instructables.com/F2T/DE8R/KPX8ZN59/F2TDE8RKPX8ZN59.jpg&filename=200346819_537778010918359_953312354507695314_n.jpg)
![199911500_720942268600056_469496099293628855_n.jpg](/proxy/?url=https://content.instructables.com/FQG/4NU4/KPX8ZN5A/FQG4NU4KPX8ZN5A.jpg&filename=199911500_720942268600056_469496099293628855_n.jpg)
First off I started by reading the temperature sensor and putting that on my site. Once that worked I started by connecting all the other electronic devices. I use 2 breadboards to connect the components with the Raspberry Pi.
If you look at my diagrams you can recreate the whole circuit.
Setting Up the Pi
Before I started programming I had to set up the RasPi.
Step 1: Connecting the RasPi to the internet:
use the command:
"wpa_passphrase >> /etc/wpa_supplicant/wpa_supplicant.conf"
Replace by the name of your wifi at home and by your wifi password.
Then use the command "wpa_cli -i wlan0 reconfigure" to reset the network card of the RasPi. If you then use
"ping www.google.com" you should get a connection.
Step 2: Full update/upgrade:
- Use the command "apt update" to update the RasPi.
- Then "apt upgrade" to upgrade the RasPi. If they ask if you are sure press 'y'.
Step 3: Installing apache:
- "apt install apache2 -y" to install apache, webserver.
Step 4: Install MariaDB:
- U can find a lot of tutorials to do this so I will just leave a link here.
- MariaDB is used for the database.
The Code
I use Visual Studio Code for my coding. You can find my code here
The Database Schematics
![db.PNG](/proxy/?url=https://content.instructables.com/FXC/JIXE/KPX8ZOHM/FXCJIXEKPX8ZOHM.png&filename=db.PNG)
The database is very simple and is easy to understand. Each component is listed in the component table and then every measurement is stored in the meting table with the componentid of the right component.
Making the Case
![131363653_3030179773932528_4094834809101274467_n.jpg](/proxy/?url=https://content.instructables.com/FAL/TZRV/KPX8ZQ39/FALTZRVKPX8ZQ39.jpg&filename=131363653_3030179773932528_4094834809101274467_n.jpg)
![199820328_172192678117129_7157641365195963934_n.jpg](/proxy/?url=https://content.instructables.com/F28/GDGG/KPX8ZQ3A/F28GDGGKPX8ZQ3A.jpg&filename=199820328_172192678117129_7157641365195963934_n.jpg)
Step 1: Drawing and cutting
First off I started by drawing the case on my wood with a pencil. When that was done I cutted it with a saw and used a file to smoothen the edges so I don't get splinters.
Step 2: Painting
Once everything was cut I painted the inside of the house white and the outside red. The roof is kinda black.
Putting It All Toghether
![200011406_396441178567458_6998403041548997319_n.jpg](/proxy/?url=https://content.instructables.com/F2C/V01Y/KPX8ZQM2/F2CV01YKPX8ZQM2.jpg&filename=200011406_396441178567458_6998403041548997319_n.jpg)
Step 1: Screwing it together
Once the paint was dry I started by screwing everything together so it looks like a nice house.
Step 2: Mounting everything in the case
Then I assembled everything in the case and made wholes so every component fits perfect.
Decorating
![131629608_289047572941135_6821956436884334569_n.jpg](/proxy/?url=https://content.instructables.com/F7M/1BID/KPX8ZRBY/F7M1BIDKPX8ZRBY.jpg&filename=131629608_289047572941135_6821956436884334569_n.jpg)
![200789470_387656985984927_1050103266680683513_n.jpg](/proxy/?url=https://content.instructables.com/F2N/MR2Z/KPX8ZRBZ/F2NMR2ZKPX8ZRBZ.jpg&filename=200789470_387656985984927_1050103266680683513_n.jpg)
![199531592_141561154615109_2376037402554817926_n.jpg](/proxy/?url=https://content.instructables.com/FX7/PTU6/KPX8ZRC1/FX7PTU6KPX8ZRC1.jpg&filename=199531592_141561154615109_2376037402554817926_n.jpg)
![20210614_192319.jpg](/proxy/?url=https://content.instructables.com/FU9/ODGN/KPX8ZRD6/FU9ODGNKPX8ZRD6.jpg&filename=20210614_192319.jpg)
At last I decorated a little bit because it was kinda empty. Then I was done. I finished my project. I can control the temperature with my site, turn on my lamp (wich it automatically does because of my motion sensor) and control my alarm.