What is the best way to convert voltage to 5 V? Is there anything else I should pay attention to?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
First of all, according to the datasheet for the HC-SR04 that you linked to, it appears to run on 5v, not 3.3v.
What you need is a level shifter, to convert the I/O signals on the BeagleBoard-xM expansion header from 1.8v to the 5v levels (and back again) as required by the sensor.
A device that will perform this function is the Logic Level Converter from SparkFun. It has 4 channels, which is more than you need. You could build your own with just two channels, but for the price ($3) its not worth it.
There are other ways of interfacing the BeagleBoard-xM to that HC-SR04 without using a 'level shifter'.
The pins on the HC-SR04 are not bi-directional, they are either input, or output only, and so don't need a level-shifter.
The Echo pulse pin, provides an input to the BeagleBoard-xM, and is the easiest to interface, you just need two resistors in a voltage divider, in close to 1.8:5 (total=1.8+3.3 which is pretty close) ratio:
(The resistors could be other values, e.g. 3.3K and 6.8K would likely work)
The Trigger pin requires close to 5V for on, and close to 0V for off. Use an ordinary, cheap, easy to get NPN BJT to actively pull the signal to 0V, and a pull-up resistor to reach 5V.
Almost any general purpose NPN BJT will do, and the resistor values can be varied too, though there isn't much point in significantly smaller resistor values. You might use the same values as the voltage divider to remove the hassle of getting other value resistors.
NB: The sense of the beagleboard output pin is inverted, LOW for triggering, and HIGH for off.
You might even have a local electronics store which has the parts, otherwise postage & packing will likely cost more than the parts (I guess well under 50¢ if you can buy them one off)