Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
12 years, 5 months ago.
my sensors have different voltage and want them on the same bus(I2C)
i have already connected several sensors one by one to the mbed, so i changed the bus voltage from 3.3 to 5 if necessary. but now i want them all connected on the same time do i use both i2c pins (9/10 and 27/28) ?? 1 for the 5v, and 1 for the 3.3V? do i have to change something in my code?
or can i just feed the sensors with the right voltage and put the bus on 5V?
thnx!!
4 Answers
12 years, 5 months ago.
Logic level converters like this one will fit on a breadboard when you solder some pins in the connecting holes. I have used this module for I2C levelconversion between 3V3 and 5V. It works fine even above 400kbit/s.
There are also more advanced levelconverters available eg https://www.sparkfun.com/products/10403
12 years, 5 months ago.
You should use levelshifters to go from 3.3V to 5V. If you use a 5V sensor and pull-ups to 3.3V The high level may not be reliably detected by the sensor (although in practice it can be OK). If you however use pull-ups to 5V you will exceed the limits of the mbed (although in practice the mbed will clamp it to 3.3V). See http://ics.nxp.com/support/documents/interface/pdf/an97055.pdf for correct level shifting. You can use both voltages on the same logical bus (i.e. 3.3V sensors directly to mbed and 5V sensors behind shifter) and you don't have to change anything in your code.
They are available as IC but it is easy to build them from mosfets and the pullups that you need anyway. You can also consider: http://dx.com/p/jy-mcu-5v-3v-iic-uart-level-2-way-converter-module-adapter-178301
posted by 20 Mar 201312 years, 5 months ago.
anybody knows a levelshifter i can use on a breadboard, the ones i find are smd
Logic level converters like this one will fit on a breadboard when you solder some pins in the connecting holes. I have used this module for I2C levelconversion between 3V3 and 5V. It works fine even above 400kbit/s.
There are also more advanced levelconverters available eg https://www.sparkfun.com/products/10403
posted by 21 Mar 201312 years, 5 months ago.
You can use both I2C busses with one on 3.3V and one on 5V, thats one level shifter less. Generally I wouldnt expect it to work to 5V due to ESD diodes, the 3.3V device will probably clip the signal. But you can just have a look at your datasheet for the 5V devices what their minimum voltage for a logical high is, if that is below 3.3V you can just stick to pull-ups to 3.3V.