Page 2 of 2

Re: Ultrasonic (US-100/HC-SR04) and sound sensor (KY038) libraries

Posted: Sun Apr 02, 2017 9:53 pm
by BruinBear
I tried a range of resistances to attentuate the echo signal but it had no effect on the distance measurement.

It's a shame about the 5v requirement for this sensor. Your library gives consistent results so it's quite useable for collision avoidance.

Re: Ultrasonic (US-100/HC-SR04) and sound sensor (KY038) libraries

Posted: Sun Dec 02, 2018 3:48 am
by rhubarbdog
You do need 5 volts for HCSR04. I was running the code with flat batteries powering a 5 volt regulator.
The sensor consistently only returned 1mm and -1mm.
I only have 3 new batteries so i powered it up with 4.5volts. Things were better, but the sensor only measured distances of a few centimetres.
I made the buffer bigger. It now sometimes returns results of 16m. The sensor is only rated at 3cm to 4m.
I need a good 5 volt supply before doing any more.
Please note i have a bi-directional logic level shifter between the sensor and microbit

Re: Ultrasonic (US-100/HC-SR04) and sound sensor (KY038) libraries

Posted: Sun Dec 02, 2018 12:22 pm
by rhubarbdog
The buffer is big enough for distances upto 4m. All my problems were lack of voltage, even 4.5v isn't enough.