please help me with this - I have ultrasonic sensor module HSR-04, connected to Arduino Mega 2560 like this:
+5V in digital section GND in digital section Trigger pin 34 in digital section Echo pin 35 in digital section
The sensor is connected via 50cm ethernet cable
Everything is working OK untill I disconnect the sensor, but leave the 50cm cable connected to pins on Arduino. There is still reading - it varies from a few centimeters to 1,8 meter, up and down irregular.
Problem is, that I need it to read -999 or something like that, when it is disconnected (or broken). It reads -999 only if I disconnect the echo line from ETH cable from pin 35 on Arduino completely.
I have tried to put 1 or 2 or 3 4k7 resistors in series between pin 35 and the cable, but it still gets some reading :-(