[Solved] High Impedance GPIO Input With Level Shifting - Page 1
Forum section: electronics / beginners

author: shmuelzon
author_rank: Contributor
timestamp: June 25, 2024, 08:17:41 pm
content: Hey all,I hope I'm using the correct terminology in the title...I'm working on a project for remotely controlling my home AC by intercepting the IR signals from the remote control, parsing it to understand the current settings, and retransmitting a signal to the AC so the setting will be applied.My current issue is that the power button of the remote is only to toggle the AC power and so I don't know, at a given point in time, if the AC is surely on or not.I was thinking of checking the LEDs of the control board to figure that out. It has two LEDs, one red for off and another green for on. The LEDs are connected to a 5v rail and are sink-driven by the existing controller. I want to read the level of this line taking in consideration that my MCU is 3.3v while the existing controller is 5v. My initial thought was to use a voltage divider to bring the 5v (when the LED is off) to 3.3v and read that from a GPIO but that would essentially mean I'm pulling down the line, no?Would just using high resistor values be good enough here or is there a better solution to get the logic level?Thanks in advance!

author: Kim Christensen
author_rank: Super Contributor
timestamp: June 25, 2024, 08:55:24 pm
content: You should be fine with just the voltage divider. Temporarily tack one onto one of the existing LED IO lines to be 100% sure.Another idea worth exploring: Some remote protocols also include "power-on" and "power-off" codes in addition to the "power toggle" code even though they're unused by the remote.

author: ArdWar
author_rank: Frequent Contributor
timestamp: June 26, 2024, 12:30:29 am
content: Divider is fine. Assuming the LED is only indicator and not a cursed multiplexing of input functions. You just need themt to be large enough values not to visibly turn on the LED.Depending on your MCU and its input structure, it might even be 5V tolerant and will be fine with only a single resistor.

author: shmuelzon
author_rank: Contributor
timestamp: June 29, 2024, 09:00:02 pm
content: Thank you both! I ended up using a voltage divider with 10k+15k resistors and it seems to do the job just fine.My MCU is an ESP32 and, AFAIK, isn't 5v tolerant so I needed to take this approach.The only odd thing I noticed is that when the LED is off, that rail is indeed 5v (before the divider) but, when it's on it's at ~3v and not the zero/GND I was expecting. It's still below the logic high minimum voltage threshold of my GPIO so it works OK (using an internal pull-down). I just hope it stays OK

author: Kim Christensen
author_rank: Super Contributor
timestamp: June 29, 2024, 09:43:03 pm
content: Quote from: shmuelzon on June 29, 2024, 09:00:02 pm

author: DavidAlfa
author_rank: Super Contributor
timestamp: June 29, 2024, 10:26:26 pm
content: Or just a diode:

author: shmuelzon
author_rank: Contributor
timestamp: June 30, 2024, 07:32:19 am
content: Hey,Please see attached where I connected my line to detect the LED status.The lower trace is the 5V line which I also use to power the ESP32 and the wire in blue is connected to the voltage divider.I think I have it connected correctly...Thanks!

author: Kim Christensen
author_rank: Super Contributor
timestamp: June 30, 2024, 03:26:30 pm
content: Connect the blue wire to the other side of R13 after verifying that point toggles between 0V & 5V when the LED goes off/on.

author: shmuelzon
author_rank: Contributor
timestamp: July 01, 2024, 08:13:54 pm
content: I think R12 is the resistor for the LED I'm connecting to. R13 is for the other LED color in that dual LED thing. The controller is already installed so I can only try this if/when something fails and I need to take it down.Could you please explain why I would see a different voltage before and after the resistor in this case? I'm especially confused by the fact that when it's off, I measure 5v but when it's on I measure 3v and not the zero I expected. Why would that be different before the resistor?Thanks for putting up with my ignorance

author: Kim Christensen
author_rank: Super Contributor
timestamp: July 01, 2024, 08:43:26 pm
content: Quote from: shmuelzon on July 01, 2024, 08:13:54 pmAh yes, you are correct. I see it now.Connect the blue wire to the other side ofR12after verifying that point toggles between 0V & 5V when the LED goes off/on.Thanks for putting up withmyignoranceQuoteBecause the resistor drops voltage across it when current flows through it. That's how the LED current is limited.

author: shmuelzon
author_rank: Contributor
timestamp: July 08, 2024, 11:50:05 am
content: Hey,I finally got around to dismantling it and probe the point after the resistor and can confirm what you've described. It measured at 0.1v which, I guess, is expected and close enough.Thanks again!

author: kevin.gibbs
author_rank: Regular Contributor
timestamp: February 12, 2025, 12:38:59 pm
content: A voltage divider would be fine.Are you sure On/Off only sends a power command? Usually, most AC remote control buttons send a packet with all settings (fan speed, temperature, etc.).