Case study · Bachelor's thesis · IoT + Android · 2019
A house that senses its environment, warns you of danger and listens to your voice. Built end to end, from the sensors to the Android app.



A complete smart home system with voice and mobile control: sensors watch the house, a Raspberry Pi runs it, and an Android app puts it in your hand.
Environmental and safety sensors wired to an Arduino Uno, which turns raw signals into meaningful values and sends them over a 2.4 GHz radio link.
A Raspberry Pi 3 B+ stores everything in MySQL, publishes it through PHP APIs on Apache, and drives the connected devices from Python.
An Android app shows the state of the house and the weather outside, raises alarms, and controls every device by touch or voice.
Smart homes are residences equipped with devices that collect and process information about their environment, automate everyday tasks and keep an eye on safety, alerting the owner of a gas leak or a fire as soon as it happens.
Developed as my bachelor's thesis in Applied Electronics at the University POLITEHNICA of Bucharest, this project builds such a system from the ground up: it monitors the house, shows the weather outside, raises alarms, and controls connected objects through an Android app, by the touch of a button or by voice.
The connected devices: a table lamp, a fan and an RGB LED strip
System data flow: readings travel from the sensors to the phone, action codes travel back
Environmental and safety sensors, spread across two breadboards, measure the state of the house.
Collects the raw signals and processes them into meaningful values, such as light in lux.
Two nRF24L01 transceivers carry all the readings to the server in a single 32-byte payload.
Stores the data in MySQL, publishes it as JSON through PHP APIs and commands the connected devices.
Reads the house status over the local network and sends the user's actions back as short codes.
The database is the heart of the system. Sensors write to it, the app reads from it, and every action is stored in it before anything happens. Because the database alone dictates the behavior of the house, the whole system can even be simulated by editing a single row.
All sensors are connected to the analog and digital pins of an Arduino Uno R3, built around the 8-bit ATmega328P microcontroller running at 16 MHz. The board is programmed in C with the Arduino IDE.
Its 10-bit analog-to-digital converter samples each analog signal into 1024 levels. From there, algorithms turn raw readings into values a person understands: light becomes lux, the SI unit of illuminance, and the microphone signal becomes a noise level.
The board reads every sensor in turn, over analog pins, digital pins and the I2C bus.
Raw values are converted, calibrated and reduced to compact integers.
All readings are packed into one payload and sent to the Raspberry Pi over the radio.
DHT11
A calibrated digital sensor measuring 0–50 °C and 20–90 % relative humidity, both at the same time.
LDR 5528
A photoresistor in a voltage divider with a 10 kΩ resistor. Its resistance drops from MΩ in the dark to a few kΩ in light, and is converted to lux.
DS18B20
A waterproof probe for the pool, measuring from -55 to 120 °C with ±0.5 °C accuracy and up to 12-bit resolution.
SOUND
An electret microphone module with adjustable sensitivity, flagging a high noise level in the house.
WATER
Mounted on the roof, its analog output changes with the water on its contacts, revealing both rain and rainfall level.
BMP280
A Bosch barometric sensor with ±1 hPa accuracy and long-term stability, connected over I2C.
LM393
A probe in the flower pot tells the owner when the plants need watering.
IR · YG1006
An infrared phototransistor that sees flames at 760–1100 nm, up to 80 cm away within a 60° angle. It triggers the fire alarm.
MQ-2
Detects flammable gases such as propane, methane, hydrogen and smoke, with a very fast response. It triggers the gas alarm.
The sensory part and the server talk wirelessly, through two nRF24L01 transceivers: one set as transmitter on the Arduino, the other as receiver on the Raspberry Pi.
Each module is a complete radio on a chip, working in the 2.4 GHz ISM band at up to 2 Mbps and programmed over SPI. It uses the Enhanced ShockBurst protocol, with packet framing, addressing and CRC error checking handled in hardware, and built-in standby and power-down modes keep its consumption ultra-low.
Enhanced ShockBurst packet
Every reading in the house travels in a single payload, from one transceiver to the other.
A Raspberry Pi 3 B+, with a quad-core ARM Cortex-A53 processor and 1 GB of RAM, is the core of the system. It is set up as a server on the local network with the Apache HTTP Server.
Received readings are stored in a MySQL database named licenta, created with phpMyAdmin. Rather than keeping a history, each table holds exactly one row that is updated every time data flows through the system, so it always describes the house right now.
Receives the radio payload, updates the database and drives the GPIO pins of the connected devices.
Two tables: senzori for the sensor readings and actiuni for the control codes.
Scripts in /var/www/html query the database and publish the result as JSON on the local network.
The JSON page changes every time the database is updated, ready to be fetched by the app.
Database licenta · the tables always hold the current state of the house
senzorisensor readingsidint(11)1temperatureint(11)20humidityint(11)68luxint(11)21soundint(11)151fireint(11)1gasint(11)1soilint(11)1rainint(11)450pressureint(11)100634wtint(11)25actiunicontrol codesidint(11)1lightvarchar(50)'11'ledvarchar(50)'124'fanvarchar(50)'11'http://server-ip/api.php[{
"temperature": 20,
"humidity": 68,
"lux": 21,
"sound": 151,
"fire": 1,
"gas": 1,
"soil": 1,
"rain": 450,
"pressure": 100634,
"wt": 25
}]
The Raspberry Pi controls three devices: a table lamp, a fan and an RGB LED strip. The lamp is plugged in at 220 V, far more than the board can handle, so the lamp and the fan are switched through 5 V relays that open and close the high-voltage circuit. The LED strip is connected directly to the board.
Control goes through the database. Every touch in the app writes the full configuration of the interface as action codes. The Python script reads them and sets the GPIO pins, so the house always matches what the app shows.
Control loop: every switch in the app becomes a code in the database
RELAY
Switched on or off by hand, or set to turn on automatically in the evening, at 7, 8 or 9 PM.
RELAY
Started by hand, or automatically when the house gets warmer than 25, 30 or 35 °C. It stops once the temperature drops below the limit.
GPIO
Individually addressable LEDs that change color and brightness, or play one of four light shows: Wipe, Theater, Rainbow and Cycle.
Each device is driven by a short code: one digit for every control in the app
The app is written in Java with the Android SDK in Android Studio. A single activity hosts three fragments, switched from the bottom menu: Home, Weather and Actions. Each one fetches its data as JSON, from the local server or from the OpenWeatherMap API, and a Read button lets a built-in narrator read the screen aloud.
HOUSE STATUS
Tiles show temperature, humidity, light, water temperature, noise, rain and pressure, updated in real time. Unusual values, like high noise or heavy rain, turn red.
SAFETY FIRST
Fire and gas leaks are the most important events. The tile turns red, a notification pops up, the phone vibrates and a spoken alert names the danger.
ALWAYS REACHABLE
Alarms are delivered as system notifications, so they reach the owner even outside the app. When all alarms stop, the phone returns to normal.
OUTSIDE
Current conditions in Bucharest from the OpenWeatherMap API: temperature, humidity, wind, visibility, sunrise and sunset, refreshed with custom animations.
CONTROL
Switches and sliders for the lamp, fan and LED strip. On opening, the screen loads the current state from the database, so it always matches the house.
HANDS-FREE
Press Speak! and say what you need. The app recognizes the command, acts on it and answers back with a spoken confirmation.
Voice control lives in the Actions screen. Pressing Speak! starts Google's speech recognizer through a RecognizerIntent, and the recognized words come back to the app as a list.
There is no need for an exact sentence: the app looks for keywords, such as an action, a device and a state. A recognized command performs the same click as a touch would, so voice and touch always stay in sync. Then Text to Speech answers back with a randomly chosen confirmation, or tells you when there is nothing to change.
Turn the lights on
Ok, lights are on!
Turn the lights on
Lights already on!
Set automatic lights to 9 PM
Light · automatic at 9 PM
Change color to yellow
LED strip · yellow
What is the purpose of this project?
This project is being developed for the electronics bachelor's degree.
Readings and actions flow through the system with low latency.
Fire and gas alerts arrive instantly, with sound, vibration and a notification.
Control the house and ask questions by voice, with spoken answers.
New sensors and devices can be added with ease.
A fully working smart home system that monitors the house, warns of danger and controls connected devices by touch or voice. Built from common modules at a low cost, it responds quickly, and centralizing everything in the database proved simple and reliable. It also meant writing code in four languages: C, Python, PHP and Java.
Solder the sensors into a compact module with its own casing, and give the server a public IP so the house can be reached from anywhere. In the app, add deeper device configuration, more automatic triggers and support for new device types.