-->
Page 1 of 3

GPIO2 as input, do I need resistor?

PostPosted: Fri May 08, 2015 5:58 am
by Suxsem
Hi. Sorry for the very noon question, but I'm scared of destroy my esp8266-1 board.

Basically I have a 12v logic signal (from my home surveillance system) and I want to monitor the state of this signal with the esp8266.

Can I just shift the 12v to 3.3v with a voltage divider and connect it to the GPIO2 (I know that I can't use the GPIO0 because it may trigger the bootloader during boot) or this could damage the esp8266 GPIO2 pin?

Do I need some sort of current limitation? I'm not very expert in electronics but I think that when a GPIO pin is in input mode it should be in high impedance state... but I'm wondering if the GPIO2 is already in input mode at boot time

Thanks!

Re: GPIO2 as input, do I need resistor?

PostPosted: Fri May 08, 2015 6:21 am
by eriksl
You could do it with a voltage divider, but it's a bit risky. Better alternative would be to have your monitoring signal drive a transistor (base, with a resistor) and have the resistor (collector to emitter) pull down the GPIO, which you can either pull up internally or using an external resistor to +3.3V (about 10k should be fine).

Re: GPIO2 as input, do I need resistor?

PostPosted: Fri May 08, 2015 6:21 am
by eriksl
Or even better use an optocoupler ;)

Re: GPIO2 as input, do I need resistor?

PostPosted: Fri May 08, 2015 7:52 am
by Suxsem
Thanks. I know how to apply transistor or optocoupler solutions but I'm wondering why you say that voltage divider is dangerous.
Because the GPIO2 could not always be in high impedance state?