Member-only story

Android WebSocket Application for controlling an ESP32 relay device

Eugene Tkachenko
9 min readDec 23, 2023

A video version of this article is here:

Life would be easier if we could control everything from a smartphone screen. Luckily, it’s not a big deal to make it happen. Today, we are creating an Android application that connects with esp32 through web sockets and controls a relay.

We need to connect two individual devices with distinct operation systems, so we need to use a common protocol for communication. There are many ways to do it, but I used WebSockets to achieve faster responses.

Why WebSockets?

HTTP requests work like small talk in the elevator.

  • *enters elevator*
  • Hello!
  • Hello!
  • How are you?
  • I am good!
  • *leaves elevator*

We can receive a lot of data, but the session is limited to a short time (I don’t want to use a long pooling-ish solution either).

--

--

No responses yet