I have written a sketch that works perfectly on a NodeMCU. For the production version (this is just a hobby project but you know what I mean) I want to use one of the ESP-01s that I have as I only need a single GPIO input and it seems wasteful to use a full development board when I don’t need to. My sketch publishes an MQTT message based on a sensor input.
When I upload the sketch to my ESP-01 using my ESP-01 programming/UART adapter it works as expected in that it boots and outputs the appropriate MQTT messages. I obviously cannot connect the sensor to the ESP-01 while it is attached to the adapter so the MQTT message always says “OFF”.
When I try to boot it using a separate 3.3V power supply, I connected GND, VCC and connected CH_PD to VCC and it does boot successfully And published the same MQTT messages. However, when I connect the sensor to GPIO2, it’s not clear what’s happening but it doesn’t publish any messages so it looks like it’s not booting.
I presume that there is something I need to do either in the code or in hardware to get it to boot while GPIO2 is connected as an input. GPIO2 will either be HIGH or LOW depending on the status of the sensor at boot time. What am I missing?