Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By valentin
#64821 Hi everyone,

I have looked through the topics and could not find a precise answer so I am posting my question as new topic, hope this is not redundant.

I am using ESP01 for a project that uses hall sensors. As a result I am using GPIO0 as input, that count the number of falling edges of the sensors thanks to interrupts. Everything works well until I need to reset the module: if unfortunately the hall sensor detects a magnet, it is LOW and I enter firmware-loading mode until I move the magnet away and reset it again.
As I need a second hall sensor I guess I will have the same problem with GPIO2.

I tried using pull-up resistors and diodes without results.
I was thinking about having a NMOS, but I am not sure it would work out.
I also read about the possibility of PCF8574 I2C module here http://www.esp8266.com/viewtopic.php?f=13&t=8370&hilit=GPIO0+as+an+input&start=4, but the Datasheet says nothing about GPIO0 as I2C interface pin. Moreover here http://www.esp8266.com/viewtopic.php?f=13&t=14120 it says that the I2C interface is only software emulated, so I am afraid of delay and inacurracy.

Would someone have a solution for using GPIO0 (and 2) as interrupt inputs without the reset problem?

Sincerely,
Valentin
User avatar
By alguti2000
#65302 I had the opposite problem on GPIO15, in which this pin has to be LOW for the device to boot normally. I have an SD card connected to HSPI, and I'm using GPIO15 for the CS line. The SD card, however, set the CS line HIGH by default, interfering with the boot process.

The way I solved was, I connected the SD card's CS to GPIO15, as normal. But, then I added a BC547 NPN transistor. The base is connected via a diode 1N4148. The collector is connected to GND. Finally, the Emitter is connected back to to GPIO15 via a 10K resistor.

I guess that, since GPIO0 has to be high at boot, using a PNP transistor instead, to create a "pull-up" effect (opposite to what my workaround does, which is a pull-down), should work.
User avatar
By valentin
#65450 Thank you so much @alguti2000! I am really happy someone else came up with a solution!

I took some days to study it, and I have a small question: does the GPIO needs to pull or push at reboot? Your solution seems to push GPIO15 (emitter) to GND (collector). My intuition would have been to invert the two (GPIO15 to collector and GND to emitter) so that GPIO15 would pull itself to GND.
As I am not very familiar with bipolars I prefer to ask for confirmation.

I guess in my case:
-if GPIOs are pulling at booting I should use a NPN with GPIO0 at Base (with diode) and at Emitter, and Vcc at Collector.
-if GPIOs are pushing current at booting I should use PNP with GPIO0 at Base and Collector and Vcc at Emitter.

Does it make sense?
User avatar
By alguti2000
#65495 At boot, GPIO15 needs too be pulled down (0), and GPIO0 needs to be pulled up (1).

I tried the way you suggested...actually, I tried a few other ways. But the one I described is what worked at the end. Remember, I only wanted to pull down the GPIO at boot. Inverting the collector/emitter would interfere with normal operation after boot completed.