So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By DavidRK
#80844 Hi guys, first time posting here (go easy), but I have been playing around with IC's again (after 20 years lol), To get me started on a few projects around the house I got a load of ESP8266-01 due to their small footprint and most my applications only needing 1/2 IOs.

Its been a love/hate month but I feel like I have the chip down pat on most things, but of recent I have had issues with connecting up the JSN-SR04T-2.0 Ultrasonic sensor (for a water tank level reading).
I am using the NewPing library v1.8 as all the newer ones threw a wobbler when compiling, I am using GPIO0/2 for the Trigger/Echo and a 3.3k pull up on GPIO0, I have the SR04 powered by the 3.3v supply.

If I boot it with everything connected, it won't start. In the serial monitor, I get an endless loop of character gargan, not even any of my sketch serial prints.
BUT if I remove the echo pin from the SR04 on boot and once running setup connected it again, bam all works sweet as. I can't detect any weird voltage spikes and adding a pullup to GPIO2 or a voltage divider does nothing.

Now in a normal world with a larger waterproof enclosure I would just use one of my ESP-12s and use a Mosfet on another input to delay the connection of the echo pin, but I only got 2 IOs and I really like to keep the TX/RX IOs free for debugging. I really need this to work as I am soldering the reset to the GPIO 16 for deep sleep, and needed to unplug the echo pin on restart is definitely not an option.

Anyone experience this weird behaviour or have any tips on how to figure out what's causing it.

Thanks Dave
User avatar
By DavidRK
#80884 Well, in case anyone has similar issues, normal boot required GPIO0 and GPIO2 to be pulled high, the JSN-SR04T sending a low signal at boot was just causing a boot issue.

My solution while still keeping the package small was to use the RX pin (GPIO3) and change its pinMode in setup to FUNCTION_3. I can still use the TX for serial debugging while having the input connected. I am not sure if TX works with FUNCTION_3 but for the moment this is perfect for switches that start LOW and any other modules that pull LOW at boot on the ESP-01.