5

I'm using a rPi 3 with Windows IoT.

I connected a PN7120 NFC Reader and was able to use it successfully.

I am also able to connect the official Touchscreen display and it works fine.

My problem is when I connect both of them. Right now I have both devices wired to the same SDA and SCL Ports. The display is connected to a 5v pin and the NFC reader is using a 3.3v pin.

I tried powering from the display and jumping the power to the Pi as well as using separate power supplies.

5

i2c does not need usually conversion, because its an open-drain bus, practically all modern 5V devices understand 3V3 logic. In either case, it is safe to use without any converters in most cases. However, the open drain configuration requires pullup resistors.

The operating voltage of i2c bus is set by a pullup resistor. Proper pullups are critical.

Since either device communicates fine on its own, this is likely the cause of your issues. The internal pull-up of raspberry pi will struggle with more devices on the bus.

Bus Configuration


schematic

simulate this circuit – Schematic created using CircuitLab

Logic Levels

The reason this scheme works with 5V devices is that I2C does not use logic 1= HIGH, logic 0 = LOW but is an open-drain bus. Which means logic 0 = LOW logic 1 = X

So the i2c pins will drive to 0V for logic 0, but only "float" the line for logic 1, with the voltage set by the pull-up resistor attached to the bus.

5V logic is generally sensitive to 3.3V inputs, but this is not always the case, you should always verify with the datasheet of the touch screen, or test empirically. There is a very high probability it will be fine.

The very first CMOS logic devices had high thresholds for 5V, they have been superseded, occasionally you find one in the wild. Most 5V CMOS input devices made in the last 20 years are sensitive enough to respond to 3V3 inputs.

Device Safety

As a slave device there should be never be a condition where the touch screen drives the Bus HIGH, sometimes devices are wonky and terribly designed, so you may want to check. To protect the bus you can insert zener diodes that would clamp the voltage to 3.3V, as shown in the schematic.

NOTE These diodes are required in the opposite configuration with a 5V master with 3V3 slave. Because, for example, there is a good chance that a 5V arduino will drive the bus because of a software bug or mis-wiring and destroy a 3V3 sensor. So in this case the zener clamps are critical to protect your devices.

Translators

Using BUS translators can be problematic with an open-drain bus. You have to be careful with selecting an appropriate device that is open-drain outputs and not active drive. There are translator and bus coupler IC's that are i2c aware or have an open-drain topology, but they must be explicitly picked.

i2c uses a simple method to detect bus contention. Since logic 0 = LOW and logic 1 = X, logic 0 "beats" logic 1. If two devices try to communicate on the bus at the exact same time, the first one who tries to write a logic 1 to the bus while the other writes logic 0, will detect that the bus did not change (logic 0 wins in rochambeau) and stop transmitting. If a bus translator is driving logic 1 = 1 and some device tries to use logic 0 = 0, this will cause a short circuit.

If you absolutely have to bridge an isolation barrier, or communicate with multiple devices at different voltage level, you are better off using an i2c extender IC over a simplex active bus like SPI, which can be safely bridged with simple one-directional translators (even opto-isolators will work for low speeds)

  • As I mentioned in an earlier comment, I'm new to the electronics side. If I understand correctly, based on your wiring diagram, I should add 10k resistors between the SDA and SCL pins and a 3.3v source. I tried that and still get the same results. Individually the components work but together the display works but not the NFC reader. – Shmuly Aug 7 '17 at 14:54
  • @Shmully lower resistance, 1K resistors – crasic Aug 7 '17 at 14:58
  • thanks. I guess I'll have to go shopping :). As a techie, I constantly have to balance between just following instructions and my desire to really understand what I'm doing. Originally I thought this project will be the former. But this problem and resulting conversation is pushing me to learn more about this. If you have any good source for a total newbie, I would love to hear. – Shmuly Aug 7 '17 at 15:21
  • @Shmuly If you have anything <4.7K on hand it will be good to try. Trial and error is a good way to learn, many people recommend The Art of Electronics, which is a fantastic book, one caveat - it doesn't get you too far into the digital side of things – crasic Aug 7 '17 at 15:36
  • I would also highly recommend purchasing an oscilloscope, your problem could be found probing the i2c communication on oscilloscope. When you can visually see the root cause it makes it easier to appreciate why the fix works. – crasic Aug 7 '17 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.