Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. Parking Sensor

Parking Sensor

Scheduled Pinned Locked Moved My Project
74 Posts 28 Posters 45.0k Views 18 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • rvendrameR Offline
    rvendrameR Offline
    rvendrame
    Hero Member
    wrote on last edited by
    #43

    Just to add my two cents, as I have a window nearby, I'm planning to run my parking sensor with a solar battery bank, like this one.

    http://www.dx.com/p/solar-powered-13800mah-external-battery-charger-power-source-bank-silver-white-281953#.Ve8ICLTOmNM

    I'm waiting for the ring now. It is the last piece missing ;-)

    Home Assistant / Vera Plus UI7
    ESP8266 GW + mySensors 2.3.2
    Alexa / Google Home

    1 Reply Last reply
    0
    • M Offline
      M Offline
      msebbe
      wrote on last edited by
      #44

      This was fun to build :)

      However, my HC-SR04 is making a high pitch sound when distance is close and a more static sound when distance is further. I have tried with 3 different modules and 2 different Nanos and 2 different power sources. Is this normal?

      SparkmanS BulldogLowellB hekH 3 Replies Last reply
      0
      • M msebbe

        This was fun to build :)

        However, my HC-SR04 is making a high pitch sound when distance is close and a more static sound when distance is further. I have tried with 3 different modules and 2 different Nanos and 2 different power sources. Is this normal?

        SparkmanS Offline
        SparkmanS Offline
        Sparkman
        Hero Member
        wrote on last edited by
        #45

        @msebbe It's normal for a :dog: or a bat. :laughing: Either you have really good hearing, or there's something wrong with your HC-SR04. The ultrasound is supposed to be well above human hearing range (40 KHz). My HC-SR04 is quiet and I don't hear any sound from it.

        M 1 Reply Last reply
        0
        • M msebbe

          This was fun to build :)

          However, my HC-SR04 is making a high pitch sound when distance is close and a more static sound when distance is further. I have tried with 3 different modules and 2 different Nanos and 2 different power sources. Is this normal?

          BulldogLowellB Offline
          BulldogLowellB Offline
          BulldogLowell
          Contest Winner
          wrote on last edited by
          #46

          @msebbe

          building on @Sparkman , perhaps it is some kind of resonance... something attached with a natural frequency that is excited by the vibrations of the speaker.

          1 Reply Last reply
          0
          • M msebbe

            This was fun to build :)

            However, my HC-SR04 is making a high pitch sound when distance is close and a more static sound when distance is further. I have tried with 3 different modules and 2 different Nanos and 2 different power sources. Is this normal?

            hekH Offline
            hekH Offline
            hek
            Admin
            wrote on last edited by
            #47

            @msebbe

            I could hear mine as well when being close to it.

            1 Reply Last reply
            0
            • SparkmanS Sparkman

              @msebbe It's normal for a :dog: or a bat. :laughing: Either you have really good hearing, or there's something wrong with your HC-SR04. The ultrasound is supposed to be well above human hearing range (40 KHz). My HC-SR04 is quiet and I don't hear any sound from it.

              M Offline
              M Offline
              msebbe
              wrote on last edited by
              #48

              @Sparkman

              It is correct that I have really good hearing.. But if I use the distance sensor sketch the HC-SR04 is not making any sound at all, first now with this sketch I hear it. Could it have something to do with the LED-strip I got from china?

              1 Reply Last reply
              0
              • Dan S.D Offline
                Dan S.D Offline
                Dan S.
                Hero Member
                wrote on last edited by
                #49

                Was checking out operation of parking sensor after changing MAX_Distance to 200 from original 100--wanted earlier start from wall. Also changed the Panic distance to 60--more space from wall during testing. Noticed that the led ring did not start from 1 pixel and increase from there as the distance closed. It started at 7 lit pixels. Examined the formula for newLightPixels and made a change which corrected this.

                The current newLightPixels formula is:

                int newLightPixels = NUMPIXELS - (NUMPIXELS*(displayDist-PANIC_DISTANCE)/MAX_DISTANCE);

                The portion of the newLightPixels formula (displayDist-PANIC_DISTANCE)/MAX_DISTANCE) is intended to map the interval between PANIC_DISTANCE and MAX_DISTANCE to the interval (0,1). In other words, when you are at the PANIC_DISTANCE it should calculate to 0 and when you are at MAX_DISTANCE it should calculate to 1, advancing linearly between the two values as the distance closes and vice versa. Clearly when a displayDist = PANIC_DISTANCE, the numerator of the division of the formula calculates to 0. However when displayDist = MAX_DISTANCE, it does not calculate to 1.

                In order to correct this I changed the portion of the formula to:
                (displayDist-PANIC_DISTANCE)/(MAX_DISTANCE-PANIC_DISTANCE))
                Note the only difference is subtracting the PANIC_DISTANCE from the MAX_DISTANCE in the denominator. Now when the displayDist = MAX_DISTANCE, the formula returns the value 1. So the proposed new newLightPixels formula is:

                int newLightPixels = NUMPIXELS - (NUMPIXELS*(displayDist-PANIC_DISTANCE)/(MAX_DISTANCE-PANIC_DISTANCE));

                I tested it both by plugging values into the formula and in operation of the Parking Sensor. Now the leds climb smoothly from 0 as you enter the MAX_DISTANCE zone. rather than starting at some number other than 1 (7 in my case).

                1 Reply Last reply
                1
                • Lawrence HelmL Offline
                  Lawrence HelmL Offline
                  Lawrence Helm
                  wrote on last edited by
                  #50

                  Cool, I had this happen as well, so great fix! Now all I need it to do is talk to domoticz, not picking it up yet... :)

                  1 Reply Last reply
                  0
                  • Dan S.D Offline
                    Dan S.D Offline
                    Dan S.
                    Hero Member
                    wrote on last edited by
                    #51

                    Have one more proposed change to parking sensor code. Noticed that even when I was standing still there seemed to be quite a few changes in number of leds lit. In checking the internet, learned that variability of distance readings was particularly a problem for those using the sensor in robots. The preferred solution seemed to be taking the median of several readings.
                    See:
                    http://blog.microcentertech.com/2013/05/minipingbot-construction.html

                    Fortunately, the Newping library has a built in function to address this issue by taking the median of several readings (default = 5). So I modified the code as follows:

                    // int fullDist = sonar.ping_cm(); original code
                    unsigned int fullDist = (sonar.ping_median() / US_ROUNDTRIP_CM);
                    // Get average distance for 5 pings, convert to cm
                    // US_ROUNDTRIP_CM = distance sound travels in cm/sec

                    As a result, the jumping around of the number of leds appears to have decreased significantly and the response is much more stable. Hope this helps others.

                    M 1 Reply Last reply
                    3
                    • Dan S.D Dan S.

                      Have one more proposed change to parking sensor code. Noticed that even when I was standing still there seemed to be quite a few changes in number of leds lit. In checking the internet, learned that variability of distance readings was particularly a problem for those using the sensor in robots. The preferred solution seemed to be taking the median of several readings.
                      See:
                      http://blog.microcentertech.com/2013/05/minipingbot-construction.html

                      Fortunately, the Newping library has a built in function to address this issue by taking the median of several readings (default = 5). So I modified the code as follows:

                      // int fullDist = sonar.ping_cm(); original code
                      unsigned int fullDist = (sonar.ping_median() / US_ROUNDTRIP_CM);
                      // Get average distance for 5 pings, convert to cm
                      // US_ROUNDTRIP_CM = distance sound travels in cm/sec

                      As a result, the jumping around of the number of leds appears to have decreased significantly and the response is much more stable. Hope this helps others.

                      M Offline
                      M Offline
                      msebbe
                      wrote on last edited by msebbe
                      #52

                      @Dan-S. Thanks for your investigation! I made the changes and it seems to work well!

                      About the high pitch sound I mentioned earlier; I changed NEO_KHZ400.

                      Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, NEO_PIN, NEO_GRB + NEO_KHZ400);
                      

                      to

                      NEO_KHZ800
                      

                      This removed the annoying high pitch sound :D

                      Dan S.D 1 Reply Last reply
                      1
                      • M msebbe

                        @Dan-S. Thanks for your investigation! I made the changes and it seems to work well!

                        About the high pitch sound I mentioned earlier; I changed NEO_KHZ400.

                        Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, NEO_PIN, NEO_GRB + NEO_KHZ400);
                        

                        to

                        NEO_KHZ800
                        

                        This removed the annoying high pitch sound :D

                        Dan S.D Offline
                        Dan S.D Offline
                        Dan S.
                        Hero Member
                        wrote on last edited by
                        #53

                        @msebbe Glad everything worked out well for you. Your comment made me think about changing mine to 800 also. From what I could glean from looking on the internet, 800 is more appropriate for newer devices, e.g., the led ring. So I am going to change to 800 also. Thanks.

                        1 Reply Last reply
                        2
                        • W Offline
                          W Offline
                          wergeld
                          wrote on last edited by
                          #54

                          Just built this with my 4 year old. She loved it! She did the project management and directed me which wire goes where. Got to start them young!

                          I was really shocked at the brightness of the LED ring. I mean, I knew it would be bright from looking at the videos, but wow.

                          My setup was to connect my UNO to the PC, load code and branch power directly from the UNO's 5v pin. I had no cap or resistor in place either (neither was there a radio hooked-up). This was just a bench-top proof of concept and it worked right out the box (after I soldered leads to the ring). I went through all the adafruit example codes and worked without a hitch. I may, or may not, exceeded WAF level 10. Now she is giving me more projects for these "neopixel" lights.

                          1 Reply Last reply
                          2
                          • hekH Offline
                            hekH Offline
                            hek
                            Admin
                            wrote on last edited by
                            #55

                            My girls like liked the neopixels as well ;)

                            1 Reply Last reply
                            0
                            • Dan S.D Offline
                              Dan S.D Offline
                              Dan S.
                              Hero Member
                              wrote on last edited by
                              #56

                              Had some issues with the operation of my parking sensor which I resolved and now it seems to be working perfectly.
                              Thought I would pass on what I did in the hope that it might help others having the same problem.

                              There were 2 issues.

                              The first issue was random lighting of the led ring after the car was pulled out of the garage and the door was closed. My guess was that the sensor, in the absence of having the solid car to bounce off of, was picking up stray sensor ping echoes from other objects in the garage. Checking on internet revealed that others using the HC-SR04 Distance sensor had experienced this problem. Checking further, I discovered that there were updates to the NewPing library, the latest being version V1.7 and specifically that V1.6 included an update to the sonar.ping_median function used for distance measurement in the parking sensor code. The MySensors library current version is V1.5. After I updated to V1.7 I no longer had random readings when the car was not in the garage. First problem solved.
                              bolded textSo I would recommend updating to NewPing V1.7.

                              I then reinstalled the parking sensor in the garage for further testing. Everything appeared to be going well but when I returned to park my car in the garage later in the day I was greeting by the led ring flashing bright red with all its leds which is supposed to be a panic signal that the car was parked as close as it should be. But I had just entered the garage and was not anywhere near the range of being parked. Took the sensor down and brought it in for testing. Found out that everything worked fine except if it was left on in the condition where it was not sensing any object in range for an extended period of time, it went into the flashing led mode. Too me it had the symptom that given enough time, a variable was being overrun (an integer variable exceeding its capacity). Checking over the code I noted the following lines:

                              if (displayDist == 0) {
                              // No reading from sensor, assume no object found
                              numLightPixels--;}

                              So everytime the displayDist = zero (and it is zero when no object is detected) numLightPixels is decremented by 1. So if there is no car in the garage (and since I had fixed the random detection problem), the sensor returns a steady stream of zeros to indicate there is no car in the garage and the numLightPixels is decremented with no limit. Given enough time it will eventually decrement to -32,768 at which point it rolls over to +32,767 and at that point the red leds will all flash in the panic mode. To fix this, I changed the above code to read:

                              if (displayDist == 0) {
                              // No reading from sensor, assume no object found
                              //Make sure you don’t go below zero
                              if (numLightPixels>0) {
                              numLightPixels--;}

                              So now it won’t decrement numLightPixels below 0. That solved the problem.

                              There is also one related efficiency change I made. At the beginning of the loop there is code to skip 10 zero readings:

                              if (displayDist == 0 && skipZero<10) {
                              // Try to filter zero readings
                              skipZero++;
                              return;
                              }

                              I changed that code to skip all zero readings if numLightPixels is less the one (i.e., 0), since if numLightPixels is at zero all of the pixels are already off and if the sensor continues to read zeroes, they should all be skipped (don’t go through the rest of the loop) until a nonzero reading is obtained (something is found).

                              if (displayDist == 0 && numLightPixels<1) {
                              // Filter zero readings
                              return;
                              }

                              Mounted the sensor in the garage again and now everything works perfectly. Hope this helps someone else.

                              1 Reply Last reply
                              6
                              • Lawrence HelmL Offline
                                Lawrence HelmL Offline
                                Lawrence Helm
                                wrote on last edited by
                                #57

                                Haven't had the chance to put this in the garage yet, but awesome work!

                                1 Reply Last reply
                                0
                                • msevM Offline
                                  msevM Offline
                                  msev
                                  wrote on last edited by
                                  #58

                                  This sketch doesn't support MQTT right? Has anyone maybe a version of this sketch which outputs MQTT? Or could you guys maybe guide me on how I would do it?

                                  1 Reply Last reply
                                  0
                                  • TD22057T Offline
                                    TD22057T Offline
                                    TD22057
                                    Hardware Contributor
                                    wrote on last edited by
                                    #59

                                    @msev said:

                                    This sketch doesn't support MQTT right? Has anyone maybe a version of this sketch which outputs MQTT? Or could you guys maybe guide me on how I would do it?

                                    MySensors uses radios to communicate with a gateway over RF. The gateway can be set up to convert those messages to/from MQTT (or use software to convert the serial messages to/from MQTT). So there aren't going to be any sensor sketches with MQTT in them. If you use an ESP, then you could send MQTT directly but then you're on WIFI and don't need MySensors.

                                    msevM 1 Reply Last reply
                                    0
                                    • TD22057T TD22057

                                      @msev said:

                                      This sketch doesn't support MQTT right? Has anyone maybe a version of this sketch which outputs MQTT? Or could you guys maybe guide me on how I would do it?

                                      MySensors uses radios to communicate with a gateway over RF. The gateway can be set up to convert those messages to/from MQTT (or use software to convert the serial messages to/from MQTT). So there aren't going to be any sensor sketches with MQTT in them. If you use an ESP, then you could send MQTT directly but then you're on WIFI and don't need MySensors.

                                      msevM Offline
                                      msevM Offline
                                      msev
                                      wrote on last edited by
                                      #60

                                      I meant for the esp8266.

                                      @TD22057 said:

                                      @msev said:

                                      This sketch doesn't support MQTT right? Has anyone maybe a version of this sketch which outputs MQTT? Or could you guys maybe guide me on how I would do it?

                                      MySensors uses radios to communicate with a gateway over RF. The gateway can be set up to convert those messages to/from MQTT (or use software to convert the serial messages to/from MQTT). So there aren't going to be any sensor sketches with MQTT in them. If you use an ESP, then you could send MQTT directly but then you're on WIFI and don't need MySensors.

                                      1 Reply Last reply
                                      0
                                      • hekH Offline
                                        hekH Offline
                                        hek
                                        Admin
                                        wrote on last edited by
                                        #61

                                        Should work, start with the MQTT ESP gateway (in development branch) and copy the relevant parts from the parking sensor example.

                                        msevM 1 Reply Last reply
                                        0
                                        • hekH hek

                                          Should work, start with the MQTT ESP gateway (in development branch) and copy the relevant parts from the parking sensor example.

                                          msevM Offline
                                          msevM Offline
                                          msev
                                          wrote on last edited by msev
                                          #62

                                          @hek I'll try, then I'll show the sketch for fixing mistakes :D...Also Newping library doesn't work on ESP, so I'll have to use Ultrasonic library. :/

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          11

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular