HC-SR04 driver and tester

Post details of your projects here.
Post Reply
logictechs
Posts: 6
Joined: Sat Dec 27, 2014 2:35 am

HC-SR04 driver and tester

Post by logictechs »

Hi All,

Still tinkering with the LPC812 capabilities and have come up with another driver that should work for all the other boards here. It's for the HC-SR04 ultrasonic distance measurement device. I bought the last 6 that GHI Electronics LLC had of their modules on sale near the end of last year. I found a source of about 469 of the "raw" modules for almost the same price at MPJA http://www.mpja.com/Ultrasonic-Ranging- ... 19605%20UT .

Not sure why yet but the first reading is a zero until it settles. I tried setting the trigger input pin upon startup to low and then wait a bit before trying it and it still reads zero the first reading. So there may be an issue I cannot figure out in the PULSIN function I used in the driver.

In my tester program, I have it wait for you to send a "1" to it over the serial in line. It seemed ok to run with at least a 1 second WAIT also for free running.

This module has a decent size sensory lobe. So you'll have to make sure there is nothing in it's way to the target the farther it is. It is also not temperature compensated. So you'll have to add that if your air temps the target is in is not at normal air temp range between 70F and 80F.
HCSR04driverandtester.zip
(715 Bytes) Downloaded 847 times
Regards,

David Kaleta



Post Reply