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

User avatar
By lotus49
#87158 This involved a bit of jiggery pokery that was far from obvious but I have figured out a way to do this and have recorded what I did below in case anyone else has the same issue.

What I have done is attach the ground pin of the sensor to GPIO0 rather than GND. GPIO0 will be HIGH at boot time ensuring that the output pin of the sensor is also HIGH but then I pull it LOW after boot which then permits the sensor to work normally by including this code in setup():
Code: Select allvoid setup() {
  ...
  pinMode(0, OUTPUT);
  digitalWrite(0, LOW);
}


So by doing this, GPIO0 defaults to HIGH on boot, which keeps the sensor (which is therefore not connected to GND at all during boot) HIGH and so keeps GPIO2 HIGH. Then, after boot, GPIO0 is pulled LOW by the code snippet above which means the sensor then is connected to GND and therefore works normally. Now my device works as expected using the ESP-01.