Skip to content

Instantly share code, notes, and snippets.

@HarvsG
Last active June 19, 2025 12:01
Show Gist options
  • Save HarvsG/70e4a136dd7a618f0fac7e1d4d76b34d to your computer and use it in GitHub Desktop.
Save HarvsG/70e4a136dd7a618f0fac7e1d4d76b34d to your computer and use it in GitHub Desktop.
I built an ESPHome project to sense the mains voltage inside my turntable to sense whether it was swtiched on.

ESP-Home Turntable

A quick morning project I did to detect whether my turntable was turned on so I could automate powering on my monitors (speakers). Note - the easiest and safest way to do this was probably with an energy detecting smart plug but I didnt have enough space for one. Another advantage is that it resulst in having an esphome close to my turntable which may come in helpful for future automations. Another better alternative is probably just using a CT clamp.

Ingredients

  • ESPHome device - I used an ESP32 DEVKIT 1
  • Optocoupler
  • Project box
  • I also got some heatshrink
  • Electronics essentials: Soldering iron, jumper leads etc
  • Hot glue gun

Method:

  1. Work out what you're dealing with
    • turntable-circuit
    • This seems to show two terminals that get energised to mains voltage
  2. Prototype on a breadboard, Note that this is HIGH VOLTAGE, stay well clear when the mains side is energised.
    • breadboard
  3. Solder and assemble into project box, cut holes for connections, glue components into place.
    • project box
    • N.B in the finished project I put a non conductive space between the ESP and the highvoltage circuit.
  4. Solder the HV side - I also had to put a cut out to let the wires through, then wrap in heatshrink
    • hv_solder

References

esphome:
name: turntable-monitor
name_add_mac_suffix: false
friendly_name: Turntable monitor
esp32:
board: esp32doit-devkit-v1
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# use_address: 192.168.0.128
# Optional manual IP
# manual_ip:
# static_ip: 192.168.1.100
# gateway: 192.168.1.1
# subnet: 255.255.255.0
ap:
ssid: "Turntable Fallback Hotspot"
password: "some_fallback_password"
logger:
# Enable Home Assistant API
api:
encryption:
key: yourkeyhere=
ota:
- platform: esphome
password: "somepassword"
binary_sensor:
- platform: gpio
pin:
number: GPIO4 # D4 contains neither a pull up or pull down internally
mode: INPUT
inverted: true # our optocoupler has a 47k resistor between the 3.3V VCC and the collector, which is directly connected to 'out' so when there is no high voltage input, out is pulled up
name: "Turntable"
device_class: running
bluetooth_proxy: #because why not, will only work on boards that support it (not an esp8266)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment