So I’ve decided to use an arduino for this job, and use the pi for non-realtime applications. Time elapsed: 1000253.0 microseconds, expected 1000000 microseconds Time elapsed: 1000445.0 microseconds, expected 1000000 microseconds Time elapsed: 1000388.0 microseconds, expected 1000000 microseconds Time elapsed: 1001183.0 microseconds, expected 1000000 microseconds Time elapsed: 2668.0 microseconds, expected 1000 microseconds Time elapsed: 1669.0 microseconds, expected 1000 microseconds
![raspberry pi sonarr setup nzbdrone raspberry pi sonarr setup nzbdrone](https://forums-sonarr-tv.s3.amazonaws.com/original/2X/8/867ee72baf0e7ce2f0a520a354cb79193eec0d82.png)
Time elapsed: 1455.0 microseconds, expected 1000 microseconds Time elapsed: 2451.0 microseconds, expected 1000 microseconds The accuracy gets better at larger time scales, e.g. Time elapsed: 1786.0 microseconds, expected 10 microseconds Time elapsed: 3488.0 microseconds, expected 10 microseconds Time elapsed: 1201.0 microseconds, expected 10 microseconds Time elapsed: 3583.0 microseconds, expected 10 microseconds I verified this with the following simple code: I believe this is because of the non-pre-emptive multi-tasking OS on the pi – it’s not able to guarantee the required time-precision (10 microseconds). Arduino works fine with the equivalent code. I found that I cannot get an accurate reading on the HC-SR04 using a raspberry pi. Print (“Measured Distance = %.1f cm” % dist) # and divide by 2, because there and back # multiply with the sonic speed (34300 cm/s) # time difference between start and arrival tup(8, GPIO.OUT) # Set pin 8 to be an output pin and set initial value to low (off)
![raspberry pi sonarr setup nzbdrone raspberry pi sonarr setup nzbdrone](https://smarthomepursuits.com/wp-content/uploads/2020/01/image-8.png)
twarnings(False) # Ignore warning for now I made little changes, but it does not light up the LED when the distance is less than 50 cm. If low cost ultrasonic distance sensors aren’t effective in this environment then an optical approach using something more like what a camera uses for infrared assisted autofocus may work. Once you get something mounted cover the sensor(s) with something like polyester cushion fill and get the signal is quiet enough to make figuring out the echo signal from the hole so you aren’t measuring vibration from the engine, hydraulic system, and boom arm as much as the hole. It may or may not be necessary to do something more elaborate depending on the design details.
![raspberry pi sonarr setup nzbdrone raspberry pi sonarr setup nzbdrone](https://user-images.githubusercontent.com/9874656/36800003-c2ad3226-1cae-11e8-85af-db2b7f1a58f3.png)
Secure the cable in a flexible shape (a hairpin bend, an S bend, or a clock spring spiral in order of isolation and durability) to avoid transmitting vibration up the cable. One way to avoid multiple evolutions of a vibration damping scheme is to begin with a multiple step approach something like conventional rubber vibration mounts to fix an 1/8 inch thick steel plate and then a layer of cork/tar adhesive to fix a lower mass aluminum plate to secure a sensor housing. One of the key steps to making a successful sensor is going to be isolating the sensor platform from the vibration of the excavating machine. It will also add a large interfering signal to the echo return signal picked up. Make sure modules with clock circuits use a ceramic resonator not a quartz crystal. Subjecting the raspberry pi components to any significant vibration may shorten the operating life to minutes/hours/days.
![raspberry pi sonarr setup nzbdrone raspberry pi sonarr setup nzbdrone](https://smarthomepursuits.com/wp-content/uploads/2020/01/nzb360-og.png)
Everything changes when it has to operate in a vibrating environment, even the choice of solder alloy. The components aren’t made for that environment. The sensor, whether mounted on the cab or the hydraulic arm will be mounted on a platform attached to a steel structure that transmits and mechanically amplifies vibration. You may need multiple sensors to determine what’s happening at the sides of the hole to determine what’s happening at the bottom. The echo from a complex surface of stone(s), hard packed natural contour, loosened earth and material falling/fallen back into the hole will be a more complex and return from the sides of the hole will mimic a soft bottom to some extent, making it even more difficult to determine the hole depth. The echo from a hard flat surface is easy to interpret. The sensor measures the time delay of a sonic echo returning to infer distance. Re: mount in backhoe … two significant challenges beyond mounting it somewhere it can make the measurement and, assuming that it’s not mounted on the cab, finding shielded cable with fine stranding and soft insulation that can withstand the bending at the arms joints, and a flexible plastic armor to encase it in.