# How to connect 5V sensors to 3.3V digital input (Due)?

I'm completely new with Arduino and microcontrollers in general.

I have several 5V sensors, and need 3.3V because that's the max for the Due. Is it possible to use a resistor to connect it to the Arduino? Do I have to measure the current from the sensor and calculate the needed resistor like this?

$$\frac{5.0 - 3.3}{\text{Measured current}}$$
(5.0 - 3.3)/(Measured current)

• It really depends on what you mean by sensor. An awful lot of boards can be given 3.3V instead of 5V – Cybergibbons Mar 18 '14 at 16:20
• @Cybergibbons I'm talking about ultrasonic sensors, altimeters, accelerometers, gyroscopes, magnetometers, GPSes, bluetooth masters, SPI RF-modules and an LCD display. Wouldn't giving 3.3V to an ultrasonic sensor limit its maximum range? – Friend of Kim Mar 18 '14 at 16:58
• I'm thinking generally anything that is connected to the Arduino Due. Some things will work with 3.3V, but is there an easy way of lowering the voltage? Being completely fresh to electronics, I can't see any other way of doing this with a cheap resistor than by measuring the current. – Friend of Kim Mar 18 '14 at 17:02
• For bidirectional level shifting (like I2C) refer to this reply. For unidirectional level shifting you can use just a single diode with a pullup resistor, refer to the second part of this reply. – alexan_e Mar 18 '14 at 18:30

Well if you're not sure of what you're doing, you can always go with level-converters for your sensors (that does not apply to shields though)

Level-converters (sometimes called level-shifters) come in different flavors:

• breakout board (the easiest to work with)
• IC
• DIY circuits with a few components

Some are "one-way": they have pin-pairs with converters 3.3V -> 5V, and other pin-pairs with 5V -> 3.3V conversion; others are bi-directional, i.e. you can use the same pair of pins in 2 directions 3.3V <-> 5V.

There are plenty of these converters, and they are rather cheap; here are just a few examples:

• I know 90% what I'm doing. There is so little power it's not dangerous. I'm not concerned about the components themselves, they can be replaced. However, I'm building an octocopter that's lifting my \$2000 camera, and I don't want anything to break during flight! – Friend of Kim Mar 18 '14 at 20:11
• Are these level-shifters simply variable resistors controlled by an IC? – Friend of Kim Mar 18 '14 at 20:11
• Is my method of finding a suitable resistor wrong? If not, why not just use it? – Friend of Kim Mar 18 '14 at 20:11
• No level shifter generally use active components (transistors , MOSFET, or CMOS), they are not just simple resistors. – jfpoilpret Mar 18 '14 at 20:57
• A resistor will allow you to lower voltage from 5V to 3.3V but not to increase it. Also, there's a lot of energy waste using resistors to lower voltage, I guess power consumption is important for you if you build a copter. – jfpoilpret Mar 18 '14 at 20:59