Artkin Carreon

[ PUBLISHED_CASE_STUDY ]

I built a two-outlet controller so I could turn my fan and mosquito repellent on or off from my phone, or let a daily schedule switch them automatically.

Status
Published
Published
01

Context

I built a two-outlet controller so I could turn my fan and mosquito repellent on or off from my phone, or let a daily schedule switch them automatically.

02

Project overview

Oreo Smart Outlet combines an Android app I built with firmware I wrote for an ESP8266-based outlet. The app gives me a button for each outlet, separate daily schedules, and a way to check the device’s current state. The firmware switches the outlets and runs their schedules, so the app does not have to stay open. I built the app with Kotlin and Jetpack Compose and the firmware with Arduino-style C++. They communicate over my local Wi-Fi network; this version does not provide cloud or remote-internet control.

03

The problem

I was tired of manually turning my fan and mosquito repellent on and off every time I needed them. Some days I wanted to switch them immediately; on other days, I wanted them to follow regular on and off times without having to remember. That led to two simple controls: an on-screen button for each outlet and a daily schedule for each one. I also needed the app to show whether a command actually reached the device and the outlet to recover sensibly when Wi-Fi was interrupted.

04

How it works

  1. When the outlet has no saved Wi-Fi details, its firmware opens a setup portal. I choose my home network and enter its password. The outlet saves those details only after it connects successfully; if the connection fails, the portal stays available so I can try again.
  2. The Android app looks for the outlet on the same local network. I can also enter its address manually. Before remembering that address, the app checks that it received a valid response from the device.
  3. The app shows the current state of both outlets, their schedules, and device information such as its connection and clock status. It refreshes this information while I use it. If the status becomes outdated or the device goes offline, the app shows that clearly and disables changes until it reconnects.
  4. To switch the fan or mosquito repellent immediately, I tap its button in the app. The app sends a request through the outlet’s local API, the ESP8266 changes the corresponding relay, and the app reads back the confirmed state. If a request times out, the app does not automatically repeat it because the first request may already have switched the outlet.
  5. For routine use, I can set one daily on time and one daily off time for each outlet. The app sends those times to the firmware, which saves them on the device and runs the schedules using a synchronized Philippine-time clock. The schedules continue without the app open. If a scheduled moment is missed, the device does not replay that switch later.
  6. The app also lets me turn the outlet’s status lights on or off without changing either outlet or its schedule. The firmware saves that preference and reports the confirmed value back to the app. This setting requires the newer device API; the existing status and relay controls remain available to older compatible versions.
  7. If the router goes offline, the outlet keeps its saved Wi-Fi details and retries the connection. Once connected again, it restores its local API, clock synchronization, and wireless update service. If I deliberately need to set up a different Wi-Fi network, a three-second reset-button hold turns both outlets off and clears the Wi-Fi details while keeping the schedules and light preference.
05

Device flow at a glance

I tap an app button or save a daily schedule → the Android app sends the request over local Wi-Fi → the ESP8266 switches the selected outlet or stores its schedule → the app displays the state confirmed by the device. Timed switching happens on the outlet itself, even when the app is closed.

06

What I learned

This project gave me hands-on experience turning a repetitive task into a clear control and automation flow. I designed the app screens, built the logic for manual switching and daily schedules, and connected the app to the device firmware. I also worked through cases that matter in real use, such as lost Wi-Fi, outdated status, and a command that may have succeeded even when the app times out. It strengthened how I design automations around both the expected steps and what happens when something goes wrong.

Four screens from the Oreo Smart Outlet app: control the fan and mosquito repellent, manage their schedules, check device status, and adjust settings.