💬 Parking Sensor

  • Admin

    This thread contains comments for the article "Parking Sensor" posted on MySensors.org.

  • I am going to abuse this use case to handle the 'toilet occupied' events because it is a well known challenge of presence detection


  • i think HC-SR04 is a bad sensor for parking . this sensor can not detect distance If there is some angle.

  • Now after hundreds of tests I can only confirm that HC-SR04 isn't really a sensor to rely on.
    Yes it shows something and it is somehow correlated with reality but... the deviations are so big!
    In my case it shows stable results if you point it onto a wall... if you put a book, hand or try to dance in front of it... so unreliable measures! I even tried to apply statistical methods to filter outfitters silly errors etc... too bad!

  • I've had some success with this but not using the HC-SR04. As others have commented this sensor is rubbish at anything except detecting a good flat surface like a wall for example.

    I instead used the Sharp GP2Y0A02YK0F. You have to re-write some of the code to use this as it just provides a sense voltage you have to convert in to a distance. There is lots of useful information on the comments section here https://www.sparkfun.com/products/8958. Which is where I managed to come up with the function below.

    int pingSharpSensor(){

    int voltageLevel;
    int sum = 0;
    int averageReading;

    for(int i=1; i<10; i++){
    voltageLevel = analogRead(distancePin);

    float v = (averageReading/1023.0)*5;

    int cm = int(61.681 * pow(v,-1.133));


    Serial.print("Distance ");

    return cm;


  • Hey David,
    Could you share the working code (with the SHARP sensor integrated) with us?

  • Cool project! I like the LED ring. But not near as cool as a traffic signal. Just sayin'.

  • Thank you for great project. I built it, it works fine except occasionally it starts flashing red when was left along for couple of hours without any objects moving in front of the sensor. It happens at least couple times per day. Sensor replacement did not fix it. The only way to get out of it is to restart Arduino. Any idea what is going on?

    Found fix for this problem at https://forum.mysensors.org/topic/1734/parking-sensor/57 by Dan.S. Please update the library.

Log in to reply

Suggested Topics

  • 3
  • 347
  • 109
  • 109
  • 10
  • 2