martin-ger / esp_mqtt

MQTT Broker/Bridge on the ESP8266
MIT License
297 stars 70 forks source link

GPIO1 on startup #55

Closed matejb123 closed 4 years ago

matejb123 commented 4 years ago

Hi, I want to use GPIO1 as an output, but if I have the peripheral connected before power, the ESP doesn't boot. If I connect the peripheral after boot, then everything works as intended. Am I missing something? I don't need serial. Thanks for good work and best regards. Matej

justoke commented 4 years ago

GPIO1 is HIGH at boot, so if you have something connected that is pulling it low you will likely get unexpected behaviour or failure to boot. You could try ensuring that the boot state of whatever you connect there is HIGH. You can still only use GPIO1 as an output. There should be no Serial.begin, print anywhere in the setup() or loop() methods.

If you are using an ESP32 module - such as this then you will note that GPIO1 pin is wired to the TX pin for USB to TTL chip for the purposes of programming the board. That is why Serial is reserved for this purpose even if you don't use it. There are ways to disable this Serial port but then you wouldn't be able to program the ESP32.

matejb123 commented 4 years ago

Hi, Thanks for reply. Hm... I'm trying to power a sensor with polling, i.e. I don't want the sensor be powered all the time via Vcc. The sensor is basically a comparator but I suspect the blocking capacitor on its Vcc pin is pulling gpio1 down for a short period of time. Has anyone of you run into this problem? Would a lower value capacitor help? Thanks and best regards, Matej

justoke commented 4 years ago

You could use a P-Channel MOSFET to switch the sensor on. It would be OFF during the boot sequence, in setup() keep it HIGH until you want to poll the sensor. This should negate the influence the capacitor might have on your circuit.

matejb123 commented 4 years ago

Thank you very much! Regards, Matej