https://github.com/mkaczmarski07/raspberry-iot
Raspberry Pi-based Client-Server environment allowing for interactive management of sensors and actuators via a mobile application.
https://github.com/mkaczmarski07/raspberry-iot
embedded-systems home-automation ionic python-script raspberry-pi-4 rest-api
Last synced: about 1 month ago
JSON representation
Raspberry Pi-based Client-Server environment allowing for interactive management of sensors and actuators via a mobile application.
- Host: GitHub
- URL: https://github.com/mkaczmarski07/raspberry-iot
- Owner: MKaczmarski07
- License: gpl-3.0
- Created: 2024-02-19T16:18:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-09-14T08:50:25.000Z (9 months ago)
- Last Synced: 2025-09-14T10:25:50.958Z (9 months ago)
- Topics: embedded-systems, home-automation, ionic, python-script, raspberry-pi-4, rest-api
- Language: TypeScript
- Homepage:
- Size: 1.36 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# About The Project
This project was developed as part of my Engineering Thesis defended in 2025 at Lublin University of Technology, Faculty of Electrical Engineering and Computer Science, Department of Electrical Engineering and Intelligent Technologies.
### Main Concepts and Learning Objectives
- The primary objective was to explore the fundamental components of modern smart buildings and develop a simple system in real life using available resources.
- Apart from my theoretical research on the subject, I built a Raspberry Pi-based system that enables remote control of sensors and actuators via a mobile application.
- The communication between user interface and hardware components is achieved with client-server model utilizing HTTP protocol and REST API.
- A web server hosted on the Raspberry Pi executes Python scripts to manage GPIO pins and establish connectivity with the external world
### Live Demo
[Raspberry-IoT Demo Video](https://www.youtube.com/watch?v=RefyAJ8AFuA)
### Used Technologies
[](https://skillicons.dev)
### System Features
🛡️ Controlling operation of the motion sensor and detecting intrusions.
🔔 Sending notifications and turning on the alarm when an intrusion is detected.
📈 Measuring current temperature and humidity in a room and displaying data in the application.
⚙️ Controlling operation of the servomechanism representing automatic blinds.
💡 RGB lighting with the ability to set any color and brightness from the application.
🌈 Various lighting scenes.
🌦️ Displaying current weather data based on the API calls.
# Table of contents
1. [Hardware Components](#hardware-components)
2. [Hardware Architecture](#hardware-architecture)
3. [Software Architecture](#software-architecture)
4. [Full list of software technologies](#used-technologies)
5. [Network Communication](#network)
6. [Mobile Application](#ionic)
7. [Setup the Raspberry Pi](#setup-the-raspberry-pi)
8. [Setup Flask Web Server](#setup-flask)
9. [Expansion Possibilities](#expansion-possibilities)
| Name | Anmount | Description |
| ------------- | ------------- | ------------- |
| Raspberry Pi 4 model B | 1 | Microcomputer |
| JustPi LT-4B03 | 1 | Cooling case for Raspberry Pi 4B |
| JustPi USB C 5V/3A | 1 | Power supply for Raspberry Pi 4B |
| DHT11 | 1 | Temperature and humidity sensor |
| Active buzzer 5V 12mm | 1 | Small sound generator |
| PIR HC-SR501 | 1 | Motion sensor |
| MicroSerwo SG-90 | 1 | Precisely controlled rotation mechanism |
| MB102 Power supply | 1 | Power supply module for the breadboard |
| JustPi - 830 breadboard | 1 | Tool used to build circuits without soldering |
| RGB LED diode, co-cathode | 2 | - |
| Resistor 220 Ω | 6 | - |
| Resistor 1 kΩ | 1 | - |
# Hardware Architecture

> [!CAUTION]
> NEVER connect LEDs up to the GPIO pins without a resistor. The Raspberry Pi GPIO pins can only supply a small current (about 60mA). The LEDs will want to draw more, and if allowed to they may damage your Raspberry Pi or the pins used.
> [!WARNING]
> Low-current components like sensors and Buzzers / LEDs should be grounded directly to the Raspberry Pi to avoid incorrect current flow. However, it is not recommended to power and ground high-current components such as motors directly from the board pins, as too high current may permamently damage the pins or the Raspberry Pi itself.
# Software Architecture

# Full list of software technologies
### Programming Languages
[TypeScript 🔗](https://typescriptlang.org)
[Python 3 🔗](https://www.python.org)
### Frameworks & Extensions
[Ionic 🔗](https://ionicframework.com)
[Angular 17 🔗](https://angular.dev)
[Sass 🔗](https://sass-lang.com)
[Flask 🔗](https://flask.palletsprojects.com/en/3.0.x/)
### Libraries
[Iro.Js 🔗](https://iro.js.org)
[Flask CORS 🔗](https://flask-cors.readthedocs.io/en/latest/)
[Adafruit CircuitPython DHT 🔗](https://docs.circuitpython.org/projects/dht/en/latest/)
### Databases
[SQLite 🔗](https://www.sqlite.org)
# Network Communication
Communication between the user's application and the server (Raspberry PI) takes place in the local network (LAN). Local network ensures reliable and secure communication, as devices can communicate with each other without the need for an internet connection.
Remote communication with the system via the Internet is also possible, e.g. by port forwarding configured on the router. However, this solution requires an additional layer of security, including user authentication and protection against various types of malicious behaviors.
### User Interface

### Core Architecture
For this project, I decided to use Angular 17 as the main framework with the modular architecture. The Angular based web application can be compiled into native-like mobile application using Ionic Framework & Capacitor runtime. Ionic itself is not only allowing for cross-platform development, but also provides a collection of customisable UI Components and building tools.
Breaking the application into modules allows for significant reduction of loading time. Additionally, main routing strategy uses [Ionic tabs](https://ionicframework.com/docs/api/tabs) architecture, which also increases performance of the native application.
### Ionic Setup Guide
Before you begin, make sure you have the following installed on your machine:
- Node.js (version 18.13 or later)
- npm package manager (version 9.0 or later)
To install all required dependencies, move to the app main workspace (frontend folder) and run:
npm i
To create a localhost port type:
ionic serve
Your application is ready at port 8100.
http://localhost:8100/
### First steps
The first step is to upload the Raspberry Pi OS image to the SD card. This can be easily done using the [Raspberry Pi Imager](https://www.raspberrypi.com/software/) tool available on the official website.
After installing the system, you can either access the Raspberry Pi OS using keyboard and monitor connected directly to the computer, or remotely via SSH.
To access the device via SSH, enter the following in the terminal:
```
ssh username@ipAddress
password
```
The default SSH user is "pi" and the default password is "raspberry".
### Safe shutdown
> [!WARNING]
> The raspberrypi microcomputer should not be turned off by immediately disconnecting the power supply, as this may damage the system or the SD card.
To safely turn off the device, enter the following the the Raspberry Pi OS terminal:
```
sudo shutdown -h now
```
And wait until the green LED on the raspberry stops blinking.
# Setup Flask Web Server on the Raspberry Pi
First, install the required dependencies for this project:
```
sudo apt update
sudo apt upgrade
sudo apt install python3-pip
pip install Flask
pip install Flask-Cors
pip install adafruit-circuitpython-dht
```
Then, go to the backend folder and run the server.py file
```
python server.py
```
## Expansion Possibilities
- Due to the low availability of hardware components, the communication between Raspberry Pi and sensors & actuators is achieved via wired connections. In a full-scale building automation system, communication could take place wirelessly, e.g. via the ZigBee, Bluetooth, LoRa or MQTT. However, that would require additional hardware components and different software architecture decisions.
- RGB LEDs can be replaced with a regular light bulb or an RGB bulb powered directly from the power grid. Such light source can be controlled via a wireless relay. The good example would be ESP8266.
- The same rule can be applied to other hardware elements, such as motors. The servomechanism used in the project is controlled via PWM signal modulation, which is widely used control technique in the industrial world.