Let's Make Robots!

How to connect SRF05 to Picaxe 28 pin Project board

  • Sensors / input devices:

If you are a newbee, you may only have learned that the Picaxe 28 pin Project Board has some inputs and outputs.. And you may have purchesed an SRF05 (that Picaxe refers to as SRF005), and you are trying to connect the darn thing.. without resoult?

Reason is likely to be that you are connecting the output from the Picaxe to the SRF05 through the darlington on the board.

The SRF05 needs (like many other things) a Pulse-signal, not just a "power on / off". The signal therefore must come directly from the Picaxe chip.

Luckely the board has little "hidden" holes for that kind of conections. (Blue wire, the signal in to the SRF05 directly from the chip). These holes, however, are not described, simply omitted in the manual for the board. So I wonder how a newbee should ever find out, personaly I burned a SRF05 or two in my frustrated attempts to get it right :)

If you follow the illustration above, you should be able to make the below code work just fine. You will know that the SRF05 is getting a pulse-signal when the little red LED on it´s back is flashing red.


symbol trig = 3 ‘ Define output pin for Trigger pulse
symbol echo = 6 ‘ Define input pin for Echo pulse
symbol range = w1 ‘ 16 bit word variable for range

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)
pulsin echo,1,range ‘ measures the range in 10uS steps
pause 10 ‘ recharge period after ranging completes
‘ now convert range to cm (divide by 5.8) or inches (divide by 14.8)
‘ as picaxe cannot use 5.8, multiply by 10 then divide by 58 instead
let range = range * 10 / 58 ‘ multiply by 10 then divide by 58
debug range ‘ display range via debug command
goto main ‘ and around forever



I did not have a fresh SRF05, and so there are drilled extra holes and soldered pins on the one on the picture.

Be aware that if you also connect servo(s) to the same Picaxe chip, program execution may be bumpy with little iregular breaks when using things as the SFR05 that needs pulses. If it is important for you to have a steady program execution, or if a servo acts totally irrational, it sometimes helps to have a smal pause or turn off a servos pulse for a short time in the code:

"low 3" or "pause 10". Aparently there is no system, it is just trial and error with your particular setup.


These pages might have your interest: See what Robot Sees, 28 pin Project Board (AXE020), Picaxe for dummies




Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

How would i go about connecting multiple sensors to the same board, would everything be the same just a different output for each sensor?


It's really well explained, good job!

Could you please tell me how to connect ttl( GND,TXD,RXD,VCC, it's a bluetooth) to a 18m2+?



It's a bluetooth what?

Connect the ground the ground.

Connect the VCC to 5V.

Connect the TXD to one digital I/O pin

Connect the RXD to another digital I/O pin.

More, I cannot say without knowing what device you are talking about.

thanks, it was a Bluetooth receiver, i already found the solution but you helped me confirming it.



The 2011 article on YDM shows a 4 wire (5 hole) SRF05  but the parts list calls for a 3 wire. And that's what I got when following the ordering instructions. How do I hook it up?

Yeah, it's a known issue. Frits will post a correction on LMR soon.

In the meantime, try this article.

Did anybody ever get readings from about 2.5 meters away ? Technically it can go up to 3m but I never got it pas 2m .

Has anyone tried triggering the SRF05 with a dedicated astable circuit?

 a simple 555 timer iC should do the trick IMO.

 I'm not sure what kind of pulse the SRf would need exactly.  however with the right combination of resistors and capacitor you should be able to get a 20us pulse which is switched on and off really quickly and I think this should solve the problem of introducing lag in the microprocessor.




I have not tried that specific solution, But I have over time tried to send all sorts of strange things to the SRF05. And while it fries quite easily if it is handled wrong, send in to out etc.. it is not very demanding when it comes to the accuracy of the input pulse, I think.

I have often used input ports to do the triggering - while they cannot send pulses, I just switch them on and off, works fine!

Although I haven't tried using a 555 with an SRF05, I have used this method with an IR emitter to generate a 40kHz carrier signal. I used a small potentiometer to tune the 555 for maximum IR receiver strength, and the microcontroller used the 555's reset pin to turn it on and off. That setup greatly reduced the load on the micro, and had the added bonus of much greater frequency stability, even when the supply voltage started to drop (whereas the internal oscillator for my microcontroller slowed down noticeably as the supply voltage sagged).

I'm certain that the same technique could be applied as you've suggested for the SRF05.