HY-SRF05 Ultrasonic Distance Sensor Info

EDP

New Member
After doing a lot of searching for information on the HY-SRF05 ultrasonic distance sensor (the Chinese HC-SR05 clone available on eBay) and how to use it, I thought I'd post here with the information that I collected. Maybe it will be of use to someone in the future.

Attached is the Chinese datasheet for the module, which I translated as best I could into English. The datasheet is split into two parts so that it will fit within this forum's file size limits. The module's circuit schematic (with a few annotations about the major components) will follow in a subsequent post.

The code that I used for this module is as follows (08M2 at 4MHz) (PULSIN):

Code:
symbol DistSensor = C.1
symbol Distance = w0
high DistSensor
pulsin DistSensor,1,Distance
The ULTRA and PULSOUT commands have been shown to work also. Those would look like this:

Code:
symbol DistSensor = C.1
symbol Distance = w0
ultra DistSensor,Distance
Code:
symbol DistSensor = C.1
symbol Distance = w0
pulsout DistSensor,1
pulsin DistSensor,1,Distance
The first code block above is what I tried first, based on an example I found elsewhere; it worked, so I used it.

My circuit uses a single PICAXE pin to send the trigger pulse and read the reply. I wired the module's TRIG pin to C.1, then also tied the ECHO pin to C.1 through a 1.8kΩ resistor (as suggested in other threads here). This worked perfectly as an emulation of the genuine HC-SR05's single-pin mode.
 

Attachments

Technical

Technical Support
Staff member
My circuit uses a single PICAXE pin to send the trigger pulse and read the reply. I wired the module's TRIG pin to C.1, then also tied the ECHO pin to C.1 through a 1.8kΩ resistor (as suggested in other threads here). This worked perfectly as an emulation of the genuine HC-SR05's single-pin mode.
Actually both HY-SR05 and HC-SR05 are clones. The original UK part is just SRF05!
 

EDP

New Member
Actually both HY-SR05 and HC-SR05 are clones. The original UK part is just SRF05!
Haha! The Chinese clone factories have made so many versions I was tricked into thinking one of them was the original. Thanks for the clarification.
 

cdimelow1

Member
Hi - thank you for your guidance - but I am really stupid and don't understand what I need to do in order to get my HY-SRF05 ultra-sonic sensor to work.

I have tied both the 'trigger' and 'echo' pins to 'input 1 (C1)' on a PICAXE18M2 IC (I am using a PICAXE 18 Project board (CHI030 )) - but what do I do with the 'Digital Out' pin? - do I leave this disconnected? - currently I have.

I am also not that confident programming using 'Basic' - I tend to use PIC Logicator - which I realise is very old and out dated - but I find most GCSE Engineering (DT) students are able to use it and write programs independently.

I have connected a dc motor through a L293D motor driver IC using output pins B4 and B5 on the PICAXE18M2 (please note - I have used the holes before the ULN2803A transistor array IC). I am going to use two dc motors to drive an 'autonomous vehicle' using output pins 4/5 and 6/7.

How can I program the PICAXE18M2 IC using the HY-SRF05 (Chinese) ultra-sonic sensor using PIC Logicator (or a flow chart) to spin the motor 'clockwise' until it senses a obstacle 5cm away - before stopping the motor - and spinning the motor 'anticlockwise' in order to move the vehicle away from the obstacle?

I don't have a problem achieving this using 'long lever micro switches' - but a number of students are trying to use ultra-sonic sensors - I also realise that I should purchase some official SRF0005 ultra-sonic sensors but £14.99 is really expensive when you are charging students for project components. And I still don't think I would be able to incorporate the sensor into my program.

Any further advice would be gratefully received. Thank you.

C Dimelow
 

Technical

Technical Support
Staff member
PIC-Logicator has not been supported for many years now and assumes each pin is either an input or an output. This would work with a two pin connection to a genuine SRF005 but not with the chinese clones, which require a single pin connection (which flips between input/output status). The flowchart mode of PICAXE Editor would do this for you.
 

AllyCat

Senior Member
Hi,
The flowchart mode of PICAXE Editor would do this for you.
Obviously also a PICaxe Basic Program, but what about directly with Blockly? It has Input > Read Ultrasonic (2 pins) with an "Echo" pin, but a "!" insists that different pins should be selected.

Cheers, Alan.
 

hippy

Technical Support
Staff member
but what about directly with Blockly? It has Input > Read Ultrasonic (2 pins) with an "Echo" pin, but a "!" insists that different pins should be selected.
Just above that should be a "Read Ultrasonic [X.Y] to [varZ]" block which caters for single pin use.
 
Top