← All projects
🏠
Hardware ProjectIndependent Project · 2025

IoT Smart Home Dashboard

Real-time appliance control via Raspberry Pi and MQTT

Raspberry PiMQTTPythonIoT

Raspberry Pi + Relays

Hardware Base

MQTT (Mosquitto)

Protocol

True Hardware State Feedback

State Sync

Python + systemd

Daemon

A custom-built Internet of Things (IoT) system designed to remotely control and monitor home appliances. It uses a Raspberry Pi wired to physical relays and sensors, communicating in real-time with a cloud dashboard via the lightweight MQTT protocol.

The problem

Commercial smart home systems are often closed, proprietary ecosystems that lock you into their specific hardware and cloud subscriptions. They offer limited customization and rely heavily on external cloud servers, which means high latency and loss of functionality during internet outages.

The solution

I engineered a custom, open-source IoT hub using a Raspberry Pi. By utilizing the MQTT protocol, the system ensures near-instantaneous communication between the physical relays and the user interface. The architecture allows for local control over the local network while still providing remote cloud access if configured.

Architecture

The hardware layer consists of a Raspberry Pi connected to physical relay boards via GPIO pins. A Python daemon (`paho-mqtt`) runs as a systemd service on the Pi, subscribing to control topics and publishing sensor state. A central Mosquitto broker routes messages. The frontend dashboard connects to the broker via WebSockets to provide real-time UI updates.

Engineering Deep Dive

⚠️

Challenges Faced

Handling the electrical logic safely was the primary concern, ensuring the low-voltage Raspberry Pi was properly isolated from the high-voltage appliances using optocouplers on the relay board. On the software side, network drops meant the Python script could lose connection to the MQTT broker.

🛠️

Techniques Used

I utilized MQTT's Last Will and Testament (LWT) feature to detect when the hardware went offline. The Python client was configured with robust automatic reconnect logic. Hardware-wise, fail-safe defaults were wired so that appliances remained safely off in the event of a power cycle.

Why This Technology?

MQTT is the gold standard for IoT due to its publish/subscribe model, minimal packet overhead, and excellent support for unstable networks. Raspberry Pi provided the perfect blend of GPIO hardware access and a full Linux OS to run the Python daemon.

Technical deep-dive

The MQTT topic structure was designed hierarchically: `home/living_room/light/command` for incoming requests and `home/living_room/light/state` for status updates. When a user toggles a switch on the dashboard, it publishes to the `command` topic. The Pi receives this, toggles the GPIO pin, and immediately publishes the new state to the `state` topic. The dashboard UI only updates when it receives the `state` message, ensuring the physical hardware has actually changed before the UI reflects it (true state synchronization).

What was built

Wired a Raspberry Pi to multi-channel relay modules to control high-voltage appliances securely

Set up a Mosquitto MQTT broker for low-latency, bi-directional communication

Developed a Python daemon running on the Pi to listen to MQTT topics and trigger GPIO pins

Built a web-based cloud dashboard for real-time monitoring and control

Outcome

A highly responsive, reliable smart home system built from scratch. It provided real-time control of lights and fans with sub-second latency, proving the viability of custom MQTT-based IoT hubs over proprietary solutions.