ESP32 WIFI/MQTT Based PC Power Control Prototype

The requirement's

  1. It must be controlled via MQTT so i can incorporate it into my smart home setup.
  2. It must also be able to be controlled via a simple web interface as a backup solution.
  3. It must support changing power state (ON/OFF)
  4. It must support doing a hard shutdown (Not that I have ever needed to do one with my workstation but still a good to have thing)

The hardware

ESP32 30-pin
  • It has onboard 18 Analog to digital converts ADCs. Each ADC is 12 bit SAR technology-based.
  • 2 digital to analog converts DACs.
  • It integrates 9 touch sensors.
  • For communication, it has 2 UART communications channels, 2 I2C communications interfaces, two I2S channels and one CAN communication interface.
  • It has 16 pulse width modulation channels.
  • It also has a cryptographic hardware acceleration module for various cryptographic algorithms like RSA, AES.
5V relay
How a relay functions

Assembly

  • D14 → S (Signal)
  • 3.3v → 5V Vcc
  • GND → GND
Example of assembled unit during testing

The code

  • WIFI (WIFI only version)
  • MQTT (MQTT only version)
  • WIFI_AND_MQTT (WIFI and MQTT version)

Planned improvements

  • Modify MQTT code so it publishes to the home assistant config topic so it gets automatically added to home assistant.
  • Create a case for the unit, currently I have it sitting in a small round plastic container which works but it really does need a case.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Admir Cosic

Admir Cosic

I am a developer who is passionate about stuff like IOT and home automation. Few tech that I enjoy working in are .net core, C#, Typescript and Azure.