<- back to posts

Remotely turning on my desktop

The Problem

When I'm away from my desktop, I rely on Chrome Remote Desktop or Moonlight (in conjunction with ZeroTier) to remotely access it.

However, my desktop need to be powered on in order for the above methods to work. Rather than keeping my desktop powered on 24/7, I need a way to remotely turn on my desktop whenever I want to connect to it.

The Details

The Solution

I got my inspiration from this video, which used an ESP connected to Adafruit IO (using the MQTT protocol) and wired to a relay in order remotely toggle the PC power pins. I more or less followed this concept.

Small Aside: What is MQTT and how does it work?

In short, MQTT is a lightweight communication protocol for sending data between machines, designed for use cases that have limited network bandwidth or hardware resources.

Typically, MQTT uses TCP as its transport protocol. Think of MQTT as an organized group of drivers, and TCP as the cars the drivers use to do what they need to do.

In simple terms, MQTT allows for this:

  1. I send data sent to an external server (called the MQTT broker)
  2. External server sends that data to the connected clients (the subscribed MQTT clients)
  3. Client receives data
  4. The client and I did not have to be on the same network to communicate!

With slightly more jargon:

  1. I publish data to the MQTT broker on a certain feed
    • The "feed" is nothing more than a name that differentiates groups of clients
  2. MQTT broker sends data to clients that are subscribed to that feed
  3. Clients receive data from the broker

The Build

with breadboard done

I used an ESP32, Adafruit IO, and a 5V relay module.

I developed with PlatformIO, and my code can be found here. This is the gist of it:

It's simple, and it gets the job done. With this code, I've managed to keep the ESP-32 connected and running for over a week without any uptime issues.

I put it all together on a breadboard, and it got the job done. This worked well, but it was a little unsightly.

A few weeks later, I caved and went ahead and put together an enclosure for it.

drilled container soldered pins
no lid with lid


In Conclusion

back to top