3

Voice-Controlled Home Lighting — IoT System

A home automation system controlling mains lighting by voice through Google Assistant — an ESP8266 Wi-Fi bridge to an Arduino microcontroller driving a relay board, with a documented state machine covering the failure modes that matter when the load is mains power.

Technology Stack

Arduino, C++, ESP8266, Relay Board, Google Assistant, IoT, Embedded Systems

Overview

Duration: 3/2023

A home automation build that puts mains lighting under voice control. A spoken command to Google Assistant reaches a cloud action, which signals an ESP8266 Wi-Fi module, which instructs an Arduino microcontroller to switch a relay board — and the light turns on.

The interesting engineering in embedded work of this kind is not making it work once. It is what the system does when the network drops, when the cloud service is unreachable, or when power is restored after a cut — because unlike a web application, a wrong state here means a light left on all night, or a switch that no longer responds to the physical control on the wall.

System Architecture

The controlling device connects to the Wi-Fi module, which is wired to the microcontroller. The controller issues switching commands to the relay board, which acts as the isolating switch in the mains circuit. Appliances connect to the relay board and become individually addressable.

Block diagram of the home automation system

The relay is the critical component and the reason the architecture is split this way: it is an electrically operated switch that lets a low-power logic signal control a mains circuit, with genuine electrical isolation between the two sides. The microcontroller never touches mains voltage.

ESP8266 to Arduino UNO wiring

State Machine

The control logic is specified as an explicit state machine rather than as reactive callbacks, which is what makes the failure behaviour reviewable before it is built.

Device state machine

It covers the states that matter in practice: disconnected and attempting to associate, connected and idle, command received and executing, and the recovery path after a power interruption. Relay state is treated as authoritative and reconciled on reconnect, so a command issued while the device was offline does not silently apply late.

Local server state machine

The local server runs its own state machine so the system degrades to local control rather than becoming unusable when the internet connection fails — the difference between a smart home and a house whose lights depend on someone else's uptime.

Components

This project covers the full IoT stack end to end: a voice interface, a cloud integration, network transport, embedded firmware, and a physical switching circuit — with the design attention spent where embedded work actually demands it, on what happens when part of that chain is unavailable.