Parking Sensor problem
-
Just completed building the parking sensor project and interfaced it to a Vera edge via NRF2501,s and every thing works. The problem I am having is the sensor (monitoring it with serial monitor to confirm ) when a vehicle is parked it changes states ever 5 seconds from car parked to car gone . this does not occur when vehicle is actually gone . It reports correctly. I have verified connections, reloaded the sketch and now I am at a complete loss . Any suggestions .
-
Welcome @mikeg291 !
Uncomment this// Serial.println(fullDist);
and see what the serial output look like. That should give a clue into what is happening.
-
It could be that transient sound waves are reflecting/scattering around and affecting the readings. The NewPing library states that 29milliseconds should be the shortest delay between reads.
Sound travels a little more than one foot in 1millisecond so you have an inherent delay in an empty garage; 15 feet each way, for example is about 30milliseconds from ping to read.
So, if you insert a delay(50) after you obtain the distance you may leave enough time for all of the sound to be absorbed or reflected away.
void loop() { unsigned long now = millis(); unsigned int fullDist = (sonar.ping_median() / US_ROUNDTRIP_CM); // Serial.println(fullDist); int displayDist = min(fullDist, MAX_DISTANCE); if (displayDist == 0 && skipZero<10) { // Try to filter zero readings skipZero++; return; } delay(50); // try this // etcetera
-
@BulldogLowell said:
It could be that transient sound waves are reflecting/scattering around and affecting the readings. The NewPing library states that 29milliseconds should be the shortest delay between reads.
Sound travels a little more than one foot in 1millisecond so you have an inherent delay in an empty garage; 15 feet each way, for example is about 30milliseconds from ping to read.
So, if you insert a delay(50) after you obtain the distance you may leave enough time for all of the sound to be absorbed or reflected away.
I second this. Built the sensor with a neopixel ring and the leds go berserk when I am about 3 cm away from the sensor with my hand.
-
Problem solved Turned out to be a bad sensor and with mfalkvidd 's suggestion troubleshooting was a lot easier . Thanks
Suggested Topics
-
Day 1 - Status report
Announcements • 23 Mar 2014, 22:45 • hek 24 Mar 2014, 20:12 -
NODs stop responding, but ping works.
Troubleshooting • 8 Mar 2025, 19:47 • Marcin 8 Mar 2025, 19:47 -
Getting system time from the controller
Troubleshooting • 27 Feb 2025, 01:39 • dpcons 3 Mar 2025, 01:00 -
Echo request is not set
Troubleshooting • 12 Aug 2024, 15:36 • kamilb85 3 Sept 2024, 08:58 -
Can not compile MySensors on esp8266
Troubleshooting • 24 Aug 2024, 15:35 • TheoL 29 Aug 2024, 20:47 -
DHT22 wrong sensor type in Home Assistant
Troubleshooting • 13 days ago • Commodoreuno 8 days ago