I am setting up a system for my first projects. I have just got a SV-328 Orangutan plus a collection of sensors including a LS20031 GPS, BMP085 Barometer and a LSM303DLH compass. Now to hook them all up!
The Orangutan is 5V, the GPS, barometer and Compass are 3V. I see the Compass has both the regulator (with spare grunt to run the GPS) but it also provides the level shift back to 5V (Vin) on the interface signals so it can talk to the controller.
The GPS and barometer, however, do not offer the level shift on its signals. I assume 5V input TTL to the GPS is going to damage the GPS, and/or 3V out from the GPS is not enough to feed the controller.
What do I need or do to shift the signals up and down between the 3V of the sensors and the 5V of the controller on devices that don’t offer the level shifting of the Compass? Is it as simple as putting a pull-up resistor on each input to the voltage of the that device, or do i need to do more?
You can look online for all kinds of level shifter circuits. What you are saying with the pull-up resistor is not a level converter. For the 3V output to 5V input, you might be able to get away with nothing since the 3V will likely get correctly read as high by the 5V device (though you’ll lose some noise margin). For 5V output to 3V input, the easiest thing is to use a voltage divider.
You can look at this thread for some more information and a part someone else is using for doing level translation:
Sorry, I just noticed you said you were using the BMP085 pressure sensor. If you want to put that on the same I2C bus as the compass, you probably will want to have a level-shifting circuit like the one on the compass. There is a schematic of it on the compass product page.
I thought if the 3V output was just a sink/pull-down it might be OK to be pulled up to 5V without hurting the 3V circuit - but i will forget that.
If I have multiple I2C devices then I don’t think I can just put a 3V output into the 5V input as the other 5V device on the bus will drive the line to 5V which the 3V device will see. So it sounds like for multiple devices on I2C I cannot avoid a voltage shifter.
I will have to see what our local electronics store has today - I doubt they will have the MC74VHC1GT50 on the shelf! But I get the idea now.
For the record - I am hoping to set up a system for my son so he can autopilot an RC car to a sequence of GPS points.
Thought we might also make a Skiing logger - recording the distance and vertical meters. (Yes I know - the GPS can do both but we got the barometer just for fun, or to just do vertical meters if we struggle with the GPS.)
Just to follow up on the level converter aspect: If you have a genuine open collector/drain output, your pull-up resistor approach is fine as long as the pin can take the higher voltage. However, open-drain operation is often approximated on microcontrollers by switching between tri-state (being an input) and driving low, and if the pins are regular pins, they usually have protective diodes from the pin to the positive rail, which would prevent the output voltage from exceeding the lower power supply (e.g. 3V) plus a diode drop. So, the pin you’re thinking you’re pulling up to 5V might not get past about 3.5V
The GPS is now connected via dedicated TX/RX UART (Another thread coming on that one.) so it is just the barometer that will be dual on the I2C, so i think i will try just using the hopefully-OC pull down.