Detect USB port power with ESP8266 (to check if TV is on)

Hey all,

For my “dumb” TV and connected set top box from our provider I’d like to be able to detect of they’re on or not. There are several ways to do this of course, and I’m thinking of checking the power on the devices’ USB port power since they are only powered when the devices are on.

I already have an ESP8266 mounted on the back of the tv that acts as an IR remote and works with MQTT. It would be great to use this to detect the USB power to signal that a device is on. But for this the USB voltage needs to be shifted to 3.3V but I have not experience with this. What’s the best way to do this (best = easy and cheap)? How advisable are circuits like this or can I use a TTL adapter and measure the output? Or does someone have other thoughts?

Thanks a lot in advance!

A simple Voltage divider should be all you need.

1 Like

If you are not using the usb port, you could power another esp8266 from it. When the esp8266 starts up it could send an MQTT message indicating on, and set the LWT message so that off is sent when it shuts down.

Slightly more expensive, but less fiddling around with a soldering iron.

2 Likes

This is a possibility that I also considered, but that would mean that I have 3 ESP’s at the back of the TV which feels like a bit over overkill. Certainly since I don’t mind fiddling with the soldering iron at all :wink: But thanks for thinking with me :slight_smile:

Perfect, thanks a lot! I’ve been looking into this and this is mostly mentioned under the “dodgy solutions” section. But only after looking further I realized that people mean it’s dodgy for transferring signals because of delay’s etc. But all I need to know if there is power or not, so I think the voltage divider will suffice. Thanks again!

Hello, @michielrutjes Can you explain in detail how to connect USB to nodemcu. And what code did you use with esphome. Thanks in advance.

Hey @Matrata, I never took up this challenge to be honest. But what I think @treno suggests is to solder a couple of resistors together to build a voltage divider, then use an analog pin on an ESP to measure a current. Then use an Analog to Digital sensor (ADC) to convert the signal into a number that Home Assistant can read. If that works, you can just read the high and low values of the sensor to detect wether a tv is on or not. https://esphome.io/components/sensor/adc.html