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

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
BruinBear
Posts: 27
Joined: Sat Jan 14, 2017 11:59 am

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

Post by BruinBear » Sun Apr 02, 2017 9:53 pm

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.

rhubarbdog
Posts: 168
Joined: Tue Nov 07, 2017 11:45 pm

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

Post by rhubarbdog » Sun Dec 02, 2018 3:48 am

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

rhubarbdog
Posts: 168
Joined: Tue Nov 07, 2017 11:45 pm

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

Post by rhubarbdog » Sun Dec 02, 2018 12:22 pm

The buffer is big enough for distances upto 4m. All my problems were lack of voltage, even 4.5v isn't enough.

Post Reply