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. Announcements
  3. šŸ’¬ Distance Sensor

šŸ’¬ Distance Sensor

Scheduled Pinned Locked Moved Announcements
92 Posts 18 Posters 27.7k 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.
  • ben999B Offline
    ben999B Offline
    ben999
    wrote on last edited by ben999
    #61

    DYP measuring range starts at 30cm -ish

    When water tank is full-up, water level is near the top of the cistern...

    So to achieve the minimum reading distance I used a big PVC pipe placed vertically on top of cistern (about 30cm) through a hole...
    I went from 5cm to 8cm but no luck : I guess there must be some "echo" in the pipe that fools the reading...

    I will end-up with a plastic bucket (dia 30cm height 30cm) on top of cistern opening (not tested yet)

    Final word : be aware of confined spaces, that sensor is kind of claustrophobic ;)

    1 Reply Last reply
    0
    • ben999B Offline
      ben999B Offline
      ben999
      wrote on last edited by ben999
      #62

      I don't quite like the idea of the DYP board being powered full-time...
      It "ticks" every one second and i only need a few updates of water level per day.

      I would like to power it via a transistor (itself being triggered by arduino)

      What would be your thoughts on that ?

      • powering that board say 4 times a day for 10 seconds would be more deadly than being powered on all the time ?
      • looks like the serial "conversation" kicks-in as soon as power is applied to the board... could it damage either board if serial link is cut anytime ?
      • DYP board uses on average less than 15mA. What transistor would be a good contender for that job ?

      Thanks again for reading and thanks even more for your input :)

      zboblamontZ 3 Replies Last reply
      0
      • ben999B ben999

        I don't quite like the idea of the DYP board being powered full-time...
        It "ticks" every one second and i only need a few updates of water level per day.

        I would like to power it via a transistor (itself being triggered by arduino)

        What would be your thoughts on that ?

        • powering that board say 4 times a day for 10 seconds would be more deadly than being powered on all the time ?
        • looks like the serial "conversation" kicks-in as soon as power is applied to the board... could it damage either board if serial link is cut anytime ?
        • DYP board uses on average less than 15mA. What transistor would be a good contender for that job ?

        Thanks again for reading and thanks even more for your input :)

        zboblamontZ Offline
        zboblamontZ Offline
        zboblamont
        wrote on last edited by
        #63

        @ben999 Surprised if you are getting echoes in a pipe, there are no surfaces to reflect the signal. Both the tanks I am looking to monitor are quite big, I might have to use a pipe in the water tank as it is a plastic moulding which has vertical facing flats on the ribs. Will report back once tested in place.

        I looked at transistor switching the device due to RTC and radio occupying all but 4 analogue lines on the node, but there were reportedly some issues with switching ground, so I settled on the latching dpdt relay I posted further up the thread. It needs two pins to open or close by changing outputs from high to low. It opened or closed in less than 30ms, about 33mA from memory, zero consumption once latched.

        In my own case the node is 3.3v, the 5v boosted line for the DYP power was originally controlled by the relay.
        Having established now that the DYP requires a 5v trig/echo, the relay is being reworked so one contact switches the 3.3v the other the 5v to power both the DYP and the level switcher, hopefully resolving earlier failures.

        1 Reply Last reply
        0
        • N Offline
          N Offline
          Newzwaver
          wrote on last edited by
          #64

          Hi Everyone,

          Just trying to get everything set back up correctly and I def have something wrong, my distance sensors show Zero.
          0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
          3 TSM:INIT
          4 TSF:WUR:MS=0
          11 TSM:INIT:TSP OK
          13 TSF:SID:OK,ID=254
          15 TSM:FPAR
          51 TSF:MSG:SEND,254-254-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
          2059 !TSM:FPAR:NO REPLY
          2061 TSM:FPAR
          2097 TSF:MSG:SEND,254-254-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
          2615 TSF:MSG:READ,0-0-254,s=255,c=3,t=8,pt=1,l=1,sg=0:0
          2620 TSF:MSG:FPAR OK,ID=0,D=1
          4105 TSM:FPAR:OK
          4106 TSM:ID
          4107 TSM:ID:OK
          4109 TSM:UPL
          4118 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
          4128 TSF:MSG:READ,0-0-254,s=255,c=3,t=25,pt=1,l=1,sg=0:1
          4133 TSF:MSG:PONG RECV,HP=1
          4136 TSM:UPL:OK
          4137 TSM:READY:ID=254,PAR=0,DIS=1
          4150 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
          4157 TSF:MSG:READ,0-0-254,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
          4166 TSF:MSG:SEND,254-254-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
          4177 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
          4211 TSF:MSG:READ,0-0-254,s=255,c=3,t=6,pt=0,l=1,sg=0:M
          4234 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=11,pt=0,l=15,sg=0,ft=0,st=OK:Distance Sensor
          4246 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
          4265 TSF:MSG:SEND,254-254-0-0,s=1,c=0,t=15,pt=0,l=0,sg=0,ft=0,st=OK:
          4272 MCO:REG:REQ
          4282 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
          4289 TSF:MSG:READ,0-0-254,s=255,c=3,t=27,pt=1,l=1,sg=0:1
          4294 MCO:PIM:NODE REG=1
          4296 MCO:BGN:STP
          4298 MCO:BGN:INIT OK,TSP=1
          Ping: 0 cm
          4336 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
          4341 MCO:SLP:TPD
          4343 MCO:SLP:WUP=-1
          Ping: 0 cm
          4380 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
          4386 MCO:SLP:TPD
          4387 MCO:SLP:WUP=-1
          Ping: 0 cm
          4425 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
          4430 MCO:SLP:TPD

          Any idea why? Pins are set correctly 5 and 6.

          Thanks

          ben999B 1 Reply Last reply
          0
          • N Newzwaver

            Hi Everyone,

            Just trying to get everything set back up correctly and I def have something wrong, my distance sensors show Zero.
            0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
            3 TSM:INIT
            4 TSF:WUR:MS=0
            11 TSM:INIT:TSP OK
            13 TSF:SID:OK,ID=254
            15 TSM:FPAR
            51 TSF:MSG:SEND,254-254-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
            2059 !TSM:FPAR:NO REPLY
            2061 TSM:FPAR
            2097 TSF:MSG:SEND,254-254-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
            2615 TSF:MSG:READ,0-0-254,s=255,c=3,t=8,pt=1,l=1,sg=0:0
            2620 TSF:MSG:FPAR OK,ID=0,D=1
            4105 TSM:FPAR:OK
            4106 TSM:ID
            4107 TSM:ID:OK
            4109 TSM:UPL
            4118 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
            4128 TSF:MSG:READ,0-0-254,s=255,c=3,t=25,pt=1,l=1,sg=0:1
            4133 TSF:MSG:PONG RECV,HP=1
            4136 TSM:UPL:OK
            4137 TSM:READY:ID=254,PAR=0,DIS=1
            4150 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
            4157 TSF:MSG:READ,0-0-254,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
            4166 TSF:MSG:SEND,254-254-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
            4177 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
            4211 TSF:MSG:READ,0-0-254,s=255,c=3,t=6,pt=0,l=1,sg=0:M
            4234 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=11,pt=0,l=15,sg=0,ft=0,st=OK:Distance Sensor
            4246 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
            4265 TSF:MSG:SEND,254-254-0-0,s=1,c=0,t=15,pt=0,l=0,sg=0,ft=0,st=OK:
            4272 MCO:REG:REQ
            4282 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
            4289 TSF:MSG:READ,0-0-254,s=255,c=3,t=27,pt=1,l=1,sg=0:1
            4294 MCO:PIM:NODE REG=1
            4296 MCO:BGN:STP
            4298 MCO:BGN:INIT OK,TSP=1
            Ping: 0 cm
            4336 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
            4341 MCO:SLP:TPD
            4343 MCO:SLP:WUP=-1
            Ping: 0 cm
            4380 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
            4386 MCO:SLP:TPD
            4387 MCO:SLP:WUP=-1
            Ping: 0 cm
            4425 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
            4430 MCO:SLP:TPD

            Any idea why? Pins are set correctly 5 and 6.

            Thanks

            ben999B Offline
            ben999B Offline
            ben999
            wrote on last edited by
            #65

            @Newzwaver which sensor are you using? And which library?

            1 Reply Last reply
            0
            • N Offline
              N Offline
              Newzwaver
              wrote on last edited by
              #66

              Thanks for the reply, I am using the HC SR04

              1 Reply Last reply
              0
              • ben999B ben999

                I don't quite like the idea of the DYP board being powered full-time...
                It "ticks" every one second and i only need a few updates of water level per day.

                I would like to power it via a transistor (itself being triggered by arduino)

                What would be your thoughts on that ?

                • powering that board say 4 times a day for 10 seconds would be more deadly than being powered on all the time ?
                • looks like the serial "conversation" kicks-in as soon as power is applied to the board... could it damage either board if serial link is cut anytime ?
                • DYP board uses on average less than 15mA. What transistor would be a good contender for that job ?

                Thanks again for reading and thanks even more for your input :)

                zboblamontZ Offline
                zboblamontZ Offline
                zboblamont
                wrote on last edited by
                #67

                @ben999 Finally good news at least on getting the DYP-SR04T-2.0 to behave with the 3.3v Pro Mini, currently arrangement like wire spaghetti. How it all fits in the weatherproof box is another day's work, as is coding it up to send hourly data back to the Gateway.

                Earlier trials using the 5v Mini worked perfectly, so ended up with latching relay and booster on separate battery pack, unfortunately I did not realise the complications of using a single coil latching relay on the Arduino.

                Needed to get some work done on the house, so delayed getting back to until last week.

                So the working hardware is now 10k resistor to DIODES DMG6968U-7 switching a NEC EE2-3TNU double coil relay, a level converter for trig/echo, and a 5v booster to power the ultrasonic. Works fine now even though the first reading is still always a Zero.
                Relay switch on and switch off is less than 10ms- Arduino and low current..
                0_1504352019537_WP_20170902_13_56_09_Pro[1].jpg

                1 Reply Last reply
                0
                • ben999B ben999

                  I don't quite like the idea of the DYP board being powered full-time...
                  It "ticks" every one second and i only need a few updates of water level per day.

                  I would like to power it via a transistor (itself being triggered by arduino)

                  What would be your thoughts on that ?

                  • powering that board say 4 times a day for 10 seconds would be more deadly than being powered on all the time ?
                  • looks like the serial "conversation" kicks-in as soon as power is applied to the board... could it damage either board if serial link is cut anytime ?
                  • DYP board uses on average less than 15mA. What transistor would be a good contender for that job ?

                  Thanks again for reading and thanks even more for your input :)

                  zboblamontZ Offline
                  zboblamontZ Offline
                  zboblamont
                  wrote on last edited by
                  #68

                  @ben999 As a postscript to the above, I puzzled over how quickly I could get a valid result before being able to power down the secondary circuit of relay, booster, level converter etc...

                  I looked at the results coming in (in this case from the JSN sensor) and read up on median analysis and gave up pretty quickly on that level of sophistication, as I realised only the first result was incorrect, that puzzling zero, all the rest were consistent and repetitive.

                  Inserting a while statement in the Void Setup (instead of the forever version in the Void Loop) checking the time duration < 1, I got a valid result immediately after the first ping, and the secondary circuit could be shut down.

                  As I only need one valid result to switch the relay off and radio the reading in once and hour, this seems to satisfy my requirements while limiting power drain on the secondary circuit.

                  1 Reply Last reply
                  1
                  • P Offline
                    P Offline
                    peerv
                    wrote on last edited by
                    #69

                    I had to add some lines to the sample sketch to get console printouts:

                    #include <SoftwareSerial.h>

                    and in the void setup():
                    Serial.begin(115200);

                    Is everybody so specialized that they see immediately this omission? :-)

                    mfalkviddM 1 Reply Last reply
                    0
                    • P peerv

                      I had to add some lines to the sample sketch to get console printouts:

                      #include <SoftwareSerial.h>

                      and in the void setup():
                      Serial.begin(115200);

                      Is everybody so specialized that they see immediately this omission? :-)

                      mfalkviddM Offline
                      mfalkviddM Offline
                      mfalkvidd
                      Mod
                      wrote on last edited by
                      #70

                      @peerv strange. Those lines should not be needed. I've never had to add them.

                      What board are you using? Did you change anything in the example sketch?

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        peerv
                        wrote on last edited by
                        #71

                        I am using a Nano V3.
                        Apart from the above lines I didn't change anything in the sketch.
                        Before the change I only got debug messages and no Serial.print lines!

                        Is the SoftwareSerial.h included in one of the other libraries?

                        mfalkviddM 1 Reply Last reply
                        0
                        • P peerv

                          I am using a Nano V3.
                          Apart from the above lines I didn't change anything in the sketch.
                          Before the change I only got debug messages and no Serial.print lines!

                          Is the SoftwareSerial.h included in one of the other libraries?

                          mfalkviddM Offline
                          mfalkviddM Offline
                          mfalkvidd
                          Mod
                          wrote on last edited by
                          #72

                          @peerv SoftwareSerial should not be needed at all, the hardware serial is used.

                          1 Reply Last reply
                          0
                          • P Offline
                            P Offline
                            peerv
                            wrote on last edited by
                            #73

                            Thanks. Due to some bad dupont cable connection the program was not entering the void loop() and not printing to the console. Was not aware about a hardware serial print. It is stable now.

                            1 Reply Last reply
                            1
                            • P Offline
                              P Offline
                              peerv
                              wrote on last edited by peerv
                              #74

                              Found a new distance sensor HC-SR04P .
                              De spec shows that the input voltage of this model is 3-5V. So this model can be used with a 3.3V arduino.
                              https://www.aliexpress.com/snapshot/0.html?spm=a2g0s.9042647.6.2.1AslKf&orderId=89862296499774&productId=32711959780

                              1 Reply Last reply
                              0
                              • R Offline
                                R Offline
                                Ritesh T
                                Banned
                                wrote on last edited by mfalkvidd
                                #75

                                Sorry for bumping up an old question but I’m in the same boat of requirement.

                                And to my surprise there are quite a few new sensors in town:

                                This one has 2 transducers instead of 1 therefore has less minimum detection distance as compared to JSN SR04T. It is also completely sealed and waterproof.

                                Ebay spam link removed by moderator

                                Before finalizing on this I had bought another one which was a waterproof modified version of HC-SR04 from here

                                Ebay spam link removed by moderator

                                The 1st one is much more rugged and waterproof as compared to the latter one

                                zboblamontZ 1 Reply Last reply
                                0
                                • R Ritesh T

                                  Sorry for bumping up an old question but I’m in the same boat of requirement.

                                  And to my surprise there are quite a few new sensors in town:

                                  This one has 2 transducers instead of 1 therefore has less minimum detection distance as compared to JSN SR04T. It is also completely sealed and waterproof.

                                  Ebay spam link removed by moderator

                                  Before finalizing on this I had bought another one which was a waterproof modified version of HC-SR04 from here

                                  Ebay spam link removed by moderator

                                  The 1st one is much more rugged and waterproof as compared to the latter one

                                  zboblamontZ Offline
                                  zboblamontZ Offline
                                  zboblamont
                                  wrote on last edited by
                                  #76

                                  @ritesh-t Dual sensor types were the first on the market, send on one sensor receive on the other from memory, but could suffer in high water vapour Zones.
                                  The single sensor types switches between send and receive on the same head, commonly used as car parking sensors.

                                  The cheaper one you show has exposed diaphragms and says it is water resistant not waterPROOF ;)
                                  Aside the smaller deadband of 3cm the more expensive one used more robust moulded sensors but steep on price, 3 times the JSN single sensor head device, but 20cm deadband is adequate for my use.
                                  Both need 5v supply same as the JSN single sensor type, for a 3.3v Node this adds complication.

                                  1 Reply Last reply
                                  0
                                  • A Offline
                                    A Offline
                                    APL2017
                                    wrote on last edited by
                                    #77

                                    Are there any tricks to configure one node with two distance sensors? I tried, it generally works, shows two distances, but periodically shows first or second distance =0

                                    1 Reply Last reply
                                    0
                                    • A Offline
                                      A Offline
                                      APL2017
                                      wrote on last edited by
                                      #78

                                      Actually, even when I use this example without any changes with single sensor, quite often node sends out 0cm. Real distance in my office from table top to ceiling is about 160cm. Maximum distance set to 300.

                                      zboblamontZ 1 Reply Last reply
                                      0
                                      • A APL2017

                                        Actually, even when I use this example without any changes with single sensor, quite often node sends out 0cm. Real distance in my office from table top to ceiling is about 160cm. Maximum distance set to 300.

                                        zboblamontZ Offline
                                        zboblamontZ Offline
                                        zboblamont
                                        wrote on last edited by
                                        #79

                                        @apl2017 There are many techniques to get avoid bogus or wrong results, assuming there are no environmental effects (reflective side objects to make readings difficult).
                                        On the setup here the sensor is a single transducer, and the sketch is a basic single pulse, time the echo to calculate the distance, with a sufficient delay to ensure the preceding pulse has decayed (hard surface underground tank) - The sketch tests for two consective results within the expected range, if it does not succeed in X attempts it does not update the Gateway and goes back to sleep for the next event, hence not flattening batteries.

                                        1 Reply Last reply
                                        0
                                        • A Offline
                                          A Offline
                                          APL2017
                                          wrote on last edited by
                                          #80

                                          zboblamont . Thank you, I understand all of this except I really don't see in sketch testing of two consecutive results in X attempts. I see that node will wake up and update the distance if new data is different than old data, but, anyway, question was about something different. Why, single sensor node based on this example periodically generates 0 distance? Are there different models of these sensors, so NewPing library needs to be altered?

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


                                          9

                                          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