OpenGarage Forums OpenGarage Firmware Second Sensor for One Door 2 Car Reply To: Second Sensor for One Door 2 Car



Ok I found a sensor that did the same thing as yours using this code – Adding debugging into the code it was failing at this part

while((digitalRead(ECHO)==LOW)&& (micros()<quit_time));
{//Do nothing

and exiting out of the loop due to micros() getting larger than the quit_time..meaning it never detects the beginning of the pulse it needs to measure to determine distance. That exit condition was there mostly to stop the ESP from doing a watchdog reset and the code really should quit the function at that point since something is wrong and the measurement after will not be correct.

Looking around a bit I found an article that recommended connecting echo to Trig via a 2.2k resistor instead of directly. Adding that in fixed it for me. It seems some configs are just more sensitive than others.

So I have VCC -> 5v on the nodemcu (VIN)
D6 –> TRIG

And then TRIG -> 2.2k resistor ->ECHO