BeagleBone Black connect to ultrasonic sensor Hcsr04

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:
https://github.com/luigif/hcsr04.
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?

What voltage are you using? For the HC-SR04 VCC should be 5V.

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

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 ?

unless you use a level translator you will blow up that gpio pin and or
the whole processor

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

This is the sensor hcsr04 datasheet:
http://www.micropik.com/PDF/HCSR04.pdf

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?

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

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

I’ve tried derek’s example and it worked perfect
https://github.com/derekmolloy/exploringBB/tree/master/chp13/ultrasonic

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…

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.