BeagleBone Black connect to ultrasonic sensor Hcsr04

1,916 views
Skip to first unread message

claudiu claudiu.furca@yahoo.com

unread,
May 5, 2015, 10:24:39 AM5/5/15
to beagl...@googlegroups.com
I have currently tried to connect a ultrasonic sensor hcsr04 to my BBB with no success. 
The support material I was using is to establish the connection and execute a trigger to my sensor and read the output is: 
When I`m executing the ./hcsr04 file I receive accordingly the being msg: >> Initializing PR >> Executing HCSR-04 code, which after it seems to wait for the signal to be triggered but never receives one.

Could you give me some advises? or if you experience working with this model of sensor and have some tips? 

Dennis Meade

unread,
May 6, 2015, 5:42:29 PM5/6/15
to beagl...@googlegroups.com
What voltage are you using? For the HC-SR04 VCC should be 5V. 

claudiu claudiu.furca@yahoo.com

unread,
May 7, 2015, 4:44:57 AM5/7/15
to beagl...@googlegroups.com
For the sensor's VCC im using the VDD_5V from BBB. 


On Wednesday, May 6, 2015, Dennis Meade <meade....@gmail.com> wrote:
What voltage are you using? For the HC-SR04 VCC should be 5V. 

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/Cd9xj0AabcU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

doog

unread,
May 7, 2015, 10:23:03 AM5/7/15
to beagl...@googlegroups.com

On Thursday, May 7, 2015 at 1:44:57 AM UTC-7, claudiu <clip> wrote:
For the sensor's VCC im using the VDD_5V from BBB. 

and you do know that the BBB is a 3.3v device so level shifting is probable?

Doug 

claudiu claudiu.furca@yahoo.com

unread,
May 7, 2015, 11:45:12 AM5/7/15
to beagl...@googlegroups.com
Well yes i do know that the BBB is a 3.3v with a 4-6 mA output. Therefore I have used the following configuration: 
* TRIGGER       P8_12 gpio1[12] GPIO44  out pulldown        Mode: 7 
* ECHO          P8_11 gpio1[13] GPIO45  in  pulldown        Mode: 7 *** with R 1KOhm
* GND           P9_1 or P9_2    GND
* VCC           P9_5 or P9_6    VDD_5V(from BBB)
but am I right ? 

--

evilwulfie

unread,
May 7, 2015, 12:24:20 PM5/7/15
to beagl...@googlegroups.com
unless you use a level translator you will blow up that gpio pin and or the whole processor
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

Chad Baker

unread,
May 7, 2015, 12:44:36 PM5/7/15
to beagl...@googlegroups.com
The sensor is expecting a 5V signal on the trigger input and generates a 5V signal on echo.
You are feeding a 3.3V signal from the BBB and accepting a 5V signal from the sensor.
Will the output of the BBB, 3.3V, be seen as a 5V input by the sensor?
Will the 5V signal from the sensor fry the gpio pin which is expecting a max voltage of 3.3V?
This is just looking at the voltages and not considering currents, dig out the spec sheets for the sensor to see what the voltage/currents are that it is expecting.
The MOSFET level shifters will transform the 3.3V to 5V and vice versa.
Transistors/resistors will do the same operation.
Chad
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

claudiu claudiu.furca@yahoo.com

unread,
May 7, 2015, 1:13:04 PM5/7/15
to beagl...@googlegroups.com
This is the sensor hcsr04 datasheet:
vol = 5V;
cur = 15mA;
As Chad said if I will attach a resistor between the the sensor echo and BBB will perform the level shift accordingly.Thus, as I previously mention I have attached a 1kohm resistor between the sensor pin echo and BBB so I could convert the voltage to the BBB expected 3.3V, as far as my calculations showed with a 1KOHM resistor. 
But will be the sensor satisfied  if I have plug it in the VDD_5V from the BBB? 

 


Harvey White

unread,
May 7, 2015, 1:16:04 PM5/7/15
to beagl...@googlegroups.com
On Thu, 07 May 2015 11:45:01 -0500, you wrote:

>The sensor is expecting a 5V signal on the trigger input and generates a
>5V signal on echo.
>You are feeding a 3.3V signal from the BBB and accepting a 5V signal
>from the sensor.
>Will the output of the BBB, 3.3V, be seen as a 5V input by the sensor?

The cmos threshold is 75% of VCC, so 25% of 5 volts is 1.25 volts,
which gives a desired 1 threshold of 3.75 volts on the sensor.

Not likely to see the signal as a 1.

>Will the 5V signal from the sensor fry the gpio pin which is expecting a
>max voltage of 3.3V?

Yes. See the warnings in the manual.

>This is just looking at the voltages and not considering currents, dig
>out the spec sheets for the sensor to see what the voltage/currents are
>that it is expecting.

>The MOSFET level shifters will transform the 3.3V to 5V and vice versa.
>Transistors/resistors will do the same operation.

TI (and others) make unidirectional (can be switched for direction)
level translators that protect both sides of the load and translate
logic levels. The part number (typical) is something on the order of
74LVC8T245, IIRC. I'd recommend them highly. There are DIP packages
more suitable for breadboards.

Transistors can work, as can resistors, but the packaged device is a
neater solution.

Harvey

>Chad
>
>
>On 5/7/15 10:45 AM, claudiu claudi...@yahoo.com wrote:
>> Well yes i do know that the BBB is a 3.3v with a 4-6 mA output.
>> Therefore I have used the following configuration:
>> |* TRIGGER P8_12 gpio1[12] GPIO44 out pulldown Mode: 7
>> * ECHO P8_11 gpio1[13] GPIO45 in pulldown Mode: 7 *** with R 1KOhm
>> * GND P9_1 or P9_2 GND
>> * VCC P9_5 or P9_6 VDD_5V(from BBB)
>> |
>> |but am I right ? |
>>
>> On 7 May 2015 at 16:23, doog <doug....@gmail.com
>> <mailto:doug....@gmail.com>> wrote:
>>
>>
>> On Thursday, May 7, 2015 at 1:44:57 AM UTC-7, claudiu <clip> wrote:
>>
>> For the sensor's VCC im using the VDD_5V from BBB.
>>
>>
>> and you do know that the BBB is a 3.3v device so level shifting is
>> probable?
>>
>> Doug
>> --
>> For more options, visit http://beagleboard.org/discuss
>> ---
>> You received this message because you are subscribed to a topic in
>> the Google Groups "BeagleBoard" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/beagleboard/Cd9xj0AabcU/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email
>> to beagleboard...@googlegroups.com
>> <mailto:beagleboard...@googlegroups.com>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> For more options, visit http://beagleboard.org/discuss
>> ---
>> You received this message because you are subscribed to the Google
>> Groups "BeagleBoard" group.
>> To unsubscribe from this group and stop receiving emails from it, send
>> an email to beagleboard...@googlegroups.com
>> <mailto:beagleboard...@googlegroups.com>.

Chad Baker

unread,
May 7, 2015, 1:26:08 PM5/7/15
to beagl...@googlegroups.com
I don't think that I said that.
I gave you some thinking material to think about.
But I did miss saying "transistor/resistor circuit", the circuit disappeared between the brain and the fingers.
Chad

Karteek YV

unread,
May 10, 2015, 9:24:45 AM5/10/15
to beagl...@googlegroups.com
I've tried derek's example and it worked perfect
https://github.com/derekmolloy/exploringBB/tree/master/chp13/ultrasonic

seniord...@gmail.com

unread,
Dec 4, 2015, 10:28:18 PM12/4/15
to BeagleBoard
Hi, did you ever figure out the problem? I'm also using luigif's example and I have the same problem where the code just waits for an interrupt and never receives it....

senthilv...@gmail.com

unread,
Jun 21, 2016, 9:15:13 AM6/21/16
to BeagleBoard, seniord...@gmail.com
Hi, even I was facing the same issue wherein my code was waiting for the interrupt, then when I started to debug the hardware connections, I found that I had interchanged the connections for echo & trigger pins, so after rectifying the connections, the code works fine and I am getting the distance output prints.
Reply all
Reply to author
Forward
0 new messages