PowerLink: Smart Home Domotica System (MCT Howest)

by MichielGekiere in Circuits > Raspberry Pi

73 Views, 1 Favorites, 0 Comments

PowerLink: Smart Home Domotica System (MCT Howest)

Media (12).jpg
Screenshot 2025-06-17 003846.png
Media.jpg
Screenshot 2025-06-17 141328.png
Media (7).jpg
Screenshot 2025-06-17 141258.png

This domotica system, built around a Raspberry Pi 5, creates a smart, energy-efficient home by integrating sensors, actuators, and a custom app for control. It manages lighting, climate, access, and energy monitoring. Outdoor lights use a light sensor for automatic operation, while ground floor lights are controlled via push buttons or the app. Motion sensors handle bathroom and toilet lighting. Climate control uses a temperature sensor, with heating adjusted via a potentiometer or app-based schedule, and a ventilation fan activates if temperatures exceed a set threshold. Energy consumption is logged for all devices. Security features an RFID-based door lock, with a reed switch monitoring door status. An LCD displays the Pi’s IP, temperature, power usage, and battery level, calculated from current flow. A database stores energy data from solar panels and battery usage, accessible via the app for real-time monitoring, manual control, and historical analysis to optimize efficiency.


Contact: LinkedIn || Instagram || michiel.gekiere@student.howest.be

Supplies

Core Components

  1. Raspberry Pi 5 – 8 GB
  2. Official Raspberry Pi USB‑C Power Supply (5 V, 5 A, 25 W)
  3. SanDisk Ultra 16 GB microSDHC
  4. Raspberry Pi GPIO Breakout Board
  5. Breadboard
  6. Dupont Jumper Cables (100-150‑pieces)
  7. Breadboard Jumper Cables
  8. Raspberry Pi Pushbutton Switch
  9. Playmobil House
  10. Wood MDF planks (buy at local store, size will matter depending on what house you use)
  11. Wood glue (buy at local store)
  12. Hinges (buy at local store)

Power Supply

  1. 10 W Solar Panel
  2. ANSMANN Powerbank 20.000 mAh – 2-poorts powerbank
  3. DeltaTek DC‑DC Step‑Down Regulator (5 V/12 V/24 V)

Sensors

  1. DS18B20 Temperature Sensor
  2. Generic LDR
  3. MFRC522 RFID Reader/Writer + cards
  4. INA219 Wattage Meter (×6)
  5. HC-SR501 PIR Motion Sensor
  6. Generic Reed Switch

Interfaces & Expanders

  1. MCP3008 ADC (8-channel)
  2. TCA9548A I²C Multiplexer

Control / Output

  1. Generic 5 mm LEDs (×6)
  2. Brushless Cooling Fan
  3. Small 5 V Heating Pad
  4. 16×2 LCD
  5. SG90 micro servo on Amazon

Electronic Components

I did not put a link to these components, buying them seperate will increase the cost by alot. There are many electronics sets available where you can buy them in bulk for about the same price as buying small amounts.

  1. 10 kΩ Linear Potentiometer (×2)
  2. 4.7 kΩ Resistors (×3), 470 Ω (×3), 100 Ω (×6), 2 kΩ (×3)
  3. 1N5819 Schottky Diode (×5)
  4. 2N2222A NPN Transistors (×3)
  5. SS8050 NPN Transistors (×3)
  6. NPN Transistors Kit (includes 2N2222A, etc.)

Estimated Cost

  1. 320 with the house excluded
  2. 420 with the house included

Get the GitHub Repository

GitHub Repository PowerLink

Besides the code this repository has some extra documentation like linux commands, component datasheets,...

Building the Circuit

breadboard_schematic_bb.png
electrical_schematic_schem.png

Tips:

  1. Follow the color coding on the PDF (In case you made any mistakes, it will be easier to follow your wires or you will notice a wire being in the wrong place faster.)
  2. Position the components like i did on my breadboard_schematic, the components that belong together are placed in the same area, this makes it look more structured and will also help with wiring.
  3. First build out everything on the breadboard. Debugging will be much easier.
  4. Mark the voltages and keep 3.3v and 5v on seperate breadboards.
  5. Dont lose your patience!

Setup Your RaspberryPi

What You’ll Need

  1. Raspberry Pi
  2. MicroSD card
  3. Raspberry Pi Imager (install on your PC)

Setup Instructions

  1. Launch Raspberry Pi Imager
  2. Open the Raspberry Pi Imager application on your computer.
  3. Insert the microSD Card
  4. Plug the microSD card into your PC.
  5. Select Configuration Options
  6. In the Imager, choose the following:
  7. Device: Your specific Raspberry Pi model
  8. Operating System: Raspberry Pi OS Lite (64-bit) (recommended)
  9. Storage: Select the microSD card
  10. Configure Advanced Options
  11. Click on "Advanced options" (gear icon) and enable:
  12. SSH access
  13. Set a username and password
  14. (Optional) Enter Wi-Fi credentials if using wireless instead of LAN
  15. Write the Image
  16. Click Write and wait until the process is complete.
  17. Connect the Raspberry Pi to Network
  18. Insert the prepared SD card into your Raspberry Pi
  19. Connect the Pi to your router using a LAN cable
  20. Connect via SSH
  21. Use the Raspberry Pi’s IP address (find it through your router or tools like ping or arp-scan) to connect via SSH:
bash
CopyEdit
ssh username@<Raspberry_Pi_IP>

Troubleshooting Tips

  1. If SSH fails:
  2. Make sure SSH is enabled
  3. Check your firewall settings and IP address configuration
  4. Try connecting via HDMI + keyboard to troubleshoot directly on the Pi

Important!

Try not to unplug the PSU while the RPI is running, this might damage the SD card. Always to "sudo shutdown now" or press the small button on the RPI twice in quick succession.

Creating the Database

power_link_erd.png

The script to create the database with some data is in the github repo under database -> power_link.sql

What's being stored?

  1. Component logs (the logging is optimized so only values get logged when they change, this prevents the database from being filled with useless data).
  2. Components.
  3. Component pages (this stores which component is shown on which page, this allows for a more customizable application).
  4. Inhabitants
  5. Pages
  6. Rooms
  7. Schedule types
  8. Schedules
  9. Schedule pages (this stores which schedule is shown on which page, for example the fan and heater have a seperate schedule, but the climate control is one. So you dont want to show 2 schedules for 1 control).

The Full Stack Workflow Explained

All code can be found in the github repo.

Main Code

app.py

  1. Setup and Initialization:
  2. Configures logging, GPIO, and hardware like sensors and displays.
  3. Sets up FastAPI for APIs and Socket.IO for real-time communication.
  4. Hardware Interaction:
  5. Controls devices: temperature sensors, LEDs, heating pads, fans, RFID readers.
  6. Reads sensor data (e.g., temperature, motion) and manages actuators.
  7. Data Management:
  8. Logs sensor and device data to a database.
  9. Manages schedules for climate and lighting based on time or sensors.
  10. API Endpoints:
  11. Offers RESTful APIs to manage components, rooms, schedules, and logs.
  12. Supports adding/removing components and updating schedules.
  13. Real-time Features:
  14. Sends live updates (e.g., logs, door control) via Socket.IO.
  15. Responds to events like motion or card scans.
  16. Power Monitoring:
  17. Tracks energy use of components and logs consumption.
  18. Monitors battery levels based on power flow.
  19. Climate Control:
  20. Adjusts heating/cooling with hysteresis based on schedules or manual input.
  21. Security Features:
  22. Handles door locks with RFID and logs access.
  23. Allows manual door control via Socket.IO.
  24. Display and UI:
  25. Shows system info (e.g., IP, power usage) on an LCD.
  26. Manages button inputs for lights and power.
  27. Cleanup and Shutdown:
  28. Safely shuts down hardware and GPIO on exit.
  29. Logs final states of components.

DataRepository.py

  1. Purpose:
  2. Manages database interactions for a smart home system (schedules, components, rooms, logs, etc.).
  3. Key Functions:
  4. Data Retrieval:
  5. Gets schedules (read_all_schedules), components (read_all_components), rooms (read_all_rooms).
  6. Page Management:
  7. Links components to pages (add_component_to_page, remove_component_from_page).
  8. Logs:
  9. Fetches latest logs (read_all_last_logs) or by ID.
  10. Energy Usage:
  11. Tracks energy over 24 hours (read_energy_24h) or 7 days (read_energy_7d).
  12. History:
  13. Analyzes data like hourly energy (read_log_history_24h) or daily temps (read_temperature_daily_history_7d).
  14. Features:
  15. Uses pandas for time-series processing.
  16. Enables real-time data, dashboards, energy monitoring, and historical reports.

Javascripts

  1. Give a overview of the most important components and information
  2. Setting schedules
  3. Showing graphs
  4. Customizable to which components will be shown

Take a Look at the Schematics

model_project_one (3) (2).png
model_project_one (2) (1).png
model_project_one (1) (1).png
model_project_one (4).png

This is the box where the house will be mounted on. I designed it so it’s solid but not too heavy to carry around.

As you might notice, the schematics don’t have holes in the top plate to run the wires through. I left these out because where you drill the holes in the bottom of your house (either the one I bought, another one, or maybe one that you made yourself), might vary. What I did myself: I drilled the holes in the bottom of the house, I placed the house on top of the box once it was finished, and with a marker, you draw through the holes on the top plate. This will ensure your holes match

Building Your Home

Media (2).jpg
Media (3).jpg
Media (1).jpg
Media (6).jpg
Media (5).jpg
Media (4).jpg
Media (7).jpg
Media (10).jpg
Media (11).jpg
Media (9).jpg
Media.jpg
Media (14).jpg
Media (8).jpg
Media (12).jpg
Media (13).jpg

What tools do you need?

  1. Table saw
  2. Screw clamp
  3. Hotglue gun
  4. Drill with drill size 13mm
  5. Soldergun and solder (in case you want to solder the components insead of using the jumper cables to ensure connection)
  6. Green spray can

Steps to building your home

  1. Saw all planks needed (available on the schematics).
  2. Place all planks together to ensure everything fits correctly
  3. Glue the sides to the base plate.
  4. Place some supports, make sure your components fit between them! (these will support the top plate when weight comes on top of it). I also places the supports close to the door, this will prevent the door from swinging inside in case they get pushed when already closed.
  5. Drill a hole in the side to run your ETH and RPi supply trough.
  6. Connect the hinges to the doors and put some handles, or pieces of wood on them
  7. Spray the top place green
  8. Place the house with the holes drilled in the bottom on top of the top plate, and mark the holes.
  9. Drill the holes with diameter 13mm.
  10. Place the components inside of the house, i secured them in place using a hotglue gun.
  11. Pull the wires trough the bottom of the house and mark the wires with tape, this will be usefull later to connect the components to your breadboard. Instead of a bunch of wires, everything is ordered. This will save you alot of headache.
  12. Place the house on top of the top plate, and pull the wires trough. Then place the top plate on top of the box.
  13. Connect all components to the breadboard and test everything using the code.
  14. When everything works, you can secure the top plate to the box, and the house to the top plate. I did this by the preffered method: using L profiles. But you can glue this as well.

Enjoy You Smart Home!

You've built an awesome smart home system with real-time monitoring, energy tracking, and automated control! Here's how to wrap it up:

  1. Let your system run and play around with it
  2. Explore and Tweak
  3. Share Your Creation