I2C on Arduino Due just... Not working

Hi guys,
I came here to beg for help due to my ignorance on this topic.

I am aware that out there are a thousand millon post with those words "DUE" and "I2C" + (not working). However, (thousand millon - 1) get you nowhere and the one left is so confusing that even who wrote it, does not understand what is on it.

facts: I'm working on a AUV. As you can imagine the maths, the number of sensors, and the complexity involved in this project, require an enourmous computing power that my old friends (Arduino Uno/Mega/Nano) can not provide, unfourtunately!!
I tested every sensor (BNO055, SAM-M8Q) separately on my Nano, getting to the point where everything worked as I need. Next step, naturally, was to get a CPU powerful enough to deal with the entire system at once, so I bought a super well recommended Arduino DUE.
As you can guess at this instance, I CAN NOT READ ANYTHING CONNECTED BY I2C ON MY DUE.
I tried first with my Melopero SAM-M8Q to request info and.. Nothing, it says there is nothing connected to the wires... I ran the I2C_Scanner, and here is what gave me the last punch, it claims there is something connected with 0x42 address. Nonetheless, I cant read any sensor because, from their perspective, there is nothing out there.

  • 10K pullups in I2C (pins 20 and 21) or I2C_1 - Did not work
  • Some people claim that removing the resistors of I2C (pins 20 and 21). I have not gor to the point where I want to perform a surgery in my brand new Arduino Due, nevertheless if someone says it works, I'd do it.
  • Others argue that because, and it is true, in the Arduino folder there is not such a thing as ARM Architecture, Wire.h was not designed for somthing different than AVR.
  • A few said that because of the 3.3V of Due..... But, SAM-M8Q also runs on 3.3. Furthermore, it has its on pullup resistors (10k).

So my commarades, has anyone ever fixed this communication problem on Arduino Due? And if so, could you please ,contemporaneous Einstein of computer sience, tell me how?

I am currently utterly frustrated with the big borther of Arduino.

Thanks a lot,

Martin.

Hi, welcome to the forum.

What you describe is exactly what is going on with the Due :cry:

First, let's get a few things out of the way:

AUV = Autonomous Underwater Vehicle

It is advised to NOT buy the Due. It is no longer actively maintained. It has bugs. It has design mistakes. It has troubles.
The MKR Zero is a fine board and even the ESP32 or a Teensy board are better to make a working project.

Do it. Remove the 1k5 pullup resistors. It probably does not make the project work, but it is a step in the right direction.

Lies.

More lies.

What is going on ?

The Nano has a input filter and a output slew rate limiter for the I2C bus and it can sink much more current to make the signal low. It can therefor overcome problems with the I2C bus.
Did you use a I2C voltage level shifter for the 3.3V sensors ? Or have you damaged your 3.3V sensors ?
The Due has just processor pins. When the SDA and SCL pins turn low they are smashed to 0V at a high speed, that edge travels as a electronic noise pulse over the I2C bus. You can add 100Ω resistors in the signal line for a lower slew rate. The SDA from the board to the resistor and the other side to the resistor to the I2C bus. The same for SCL.

How to solve it

You could buy an other board. I think it is also possible to make it work with the Due.

Give a lot of information. A lot. Really a lot. More than a lot. Tell about everything that is connected to the I2C bus. Give links to where you bought the modules. If sensors are on modules, do you have the schematic of the modules ? With links to datasheets. Do you use long wires or cables or motors ? Can you show a photo of your wiring ?
Maybe you have to use a shielded cable and shield your sensors.

Just a few things to think about:

The I2C bus is not designed to go into wires or cables. As soon as you try to bring the I2C bus somewhere else with wires, then you are asking for trouble. I know that everyone uses wires, but it is not that kind of "bus".

The GND wire of the I2C bus is more as important than SDA or SCL. Treat it with care. It should be together with SDA and SCL to the sensor. It may not be used for something else.
The SDA wire should not be next to the SCL wire.
The total pullup should be not too weak and not too strong. It can be calculated and it can be measured in the circuit itself.
A sensor module with a onboard I2C level shifter makes the I2C bus even weaker. A signal from a 3.3V processor to a 3.3V sensor is the best. Sometimes there are two level shifters in the signal path, then it will no longer work.

Some projects will never work. For example with strong motors and long I2C wires. For such projects the RS-485 bus can be used.

Loud and clear mate! Much appreciated!!

Ops! Typing mistake. I am actually working on a UAV (Unmanned Aerial Vehicle) which... To some degree is pretty much the same than an AUV, just a couple of kgm2 density medium difference :P!
I am going to try a bit more to sort it out with the Due and, in case of getting nowhere, I will happily order one Teensy 4.0!

  • The sensors are still working, i tried them with the nano again and all good!
    -About wiring, not at all... I got everything on my desk, intertwined on a breadboard with cables no longer than 10 cm.
  • Going to check the resistor to get a lower slew rate
  • If nothing works, I will proceed with the surgery (last option).

Thanks a lot Koepel for your help!

Best regards!

Get rid of the elephant in the room first, worry about the mouse later.
What I'm trying to say is: remove the 1k5 resistors.

Its been quite a while since I've used a DUE, but maybe something like this in setup could help ...

It is possible that a sensor gets stuck. It should not happen and it is very rare.
I wrote something about it on my Github Wiki with a link to Matthew Ford's clearing the I2C bus.
It seems possible with a DS1307 when pressing the reset button many times. I have never encountered this myself.

Unless running many slaves, or very long wires, the existing I2C pullups on the Due will work just fine. I've used both I2C ports on Dues MANY times at up to 2MHz, with zero problems.

On the SW side, the Due is no different from the AVR-based boards, and the same code should work on either. If it doesn't, then you probably got a bad Due board, which is not at all uncommon, especially when using brand-X Chinese clones.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.