Issues connecting MKR1000 and MKR1010 via I2C

I have a very simple Master-Slave example using the Wire.h library over I2C. I have tested this example with a UNO and a Nano and it works perfectly. I have tried the exact same example with a MKR1000 as a Master and the Nano / Uno as slave and it does not work. I made sure to use the proper pull up resistors and even tried to rule out a voltage difference issue (3v vs 5v) by using a Logic Level Converter for this purpose and it still does not work.

As an apples to apples test, I connected the MRK1000 (master) to a MKR1010 (slave) and it still does not work.

I would really appreciate some help as my research has not been successful in finding a fix. I am wondering if there is some incompatibility issue with these devices and the Wire library.

Thanks in advance.

Ignacio

Post a wiring diagram of your setup. Post the code you're using (the SAMD platform is a bit less tolerant for programming errors in the Wire library than the AVR platform)!

I am posting the diagram (note: I tried it with and without the pull up resistors and I get the same result)

The code to the simple master and slave programs can be found on:

This library facilities transition of more complex structures.

I'm missing the pull-ups you mentioned in your diagram. Without them it won't work on the SAMD platform.

I didn’t draw them in but they are in the circuit per this diagram (see attachment). Although most documentation states they are not really necessary. The resistors are 4k7.

i2c-3v3-sensor-connect.png

That diagram doesn't show an Arduino->Arduino connection.

Although most documentation states they are not really necessary.

Most documentation is not for the SAMD platform but for the AVR (UNO). There internal pull-ups are activated on the master but they are weak and with a bit longer wires you need them even there.

I didn't draw them in but they are in the circuit per this diagram (see attachment).

What else did you forget to draw? How are the boards powered? A wiring diagram should show all connections!

All the diagrams for pull up resistors for I2C communication were identical so I used those. If you believe the issue is the value of the resistors or the way they are wired, could you please point out what you believe to the proper diagram.

I didn’t leave anything else out. The 2 devices are right next to each other in the same protoboard and powered by USB connected to a pc. I am attaching a photo of the circuit and an updated diagram.

If you believe the issue is the value of the resistors or the way they are wired, could you please point out what you believe to the proper diagram.

The pull-ups must go to 3V3, pulling up to 5V might fry the pin. For the 3V3 boards I would use 2k2 pull-ups to get a faster response, especially if you use a breadboard with jumper wires.

The second picture isn't sharp enough to recognize the connections but there are far to many resistors on the board. Pull-ups are used only once per bus not per device.

I tried 3V as well for the pull up resistors but it didn't work either. I will try with 2K2 instead of 4K7.

There are multiple resistors because I didn't have a 4K7 so I used 3 in a serial configuration to add up to 4K7, in the end there is only one per line (SDA, SCL).

Thank you.

I tried the configuration that you suggested using 3V3 and the 2K2 pull up resistors between the Arduino MKR1000 and an Arduino Nano and there is no communication between the two. (Attaching the latest diagram)

The software has been triple checked and works perfectly with other devices so I am 99.99% sure the issue is on the wiring side. Do you have any other suggestions on what would be causing the issue?

Thank you

I tried the configuration that you suggested using 3V3 and the 2K2 pull up resistors between the Arduino MKR1000 and an Arduino Nano and there is no communication between the two. (Attaching the latest diagram)

Did you check if the I2C pins on the MKR are still working? After the last setup with applying 5V to them they may be fried.

How long are the wires between the two boards? An I2C bus should be less than 50cm in total.

The MKR1000 seems fine. I am not sure how I would test the pins other than see if current is passing through when plugged in. I am getting ~3V on both pins. I also used a brand new one that was never been wired and also there is no communication.

The distance of from end to end is about less than 10 cms. They are literally next to each other with short jumper wires as you so on the picture.

During my research I have seen simpler diagrams with the MKR1000 and MKR1010 that seem to work, although it's always connected to sensors and not a controller to controller configuration. They use the same Wire.h library so there is no difference there. Could there be some other conflict? Maybe an address issues?

I am out of ideas.

Could there be some other conflict? Maybe an address issues?

Although that’s not very likely: post your code (both parts) and we can take a look if there’s code that won’t run on the ARM platform.

The code is right here: https://github.com/nickgammon/I2C_Anything

For both the Master (MKR1000 or MKR1010) and Slave device (Nano)

As an update, I have been able to confirm the both the MRK 1000 and MKR 1010 are working correctly communicating over the I2C bus when connected to other devices, but not from arduino to arduno.

I connected a display that works over I2C (https://www.adafruit.com/product/879) using a logic level converter (no pull up resistors added) and it works as expected. But when I use the same configuration to connect the Arduino Nano, the MKR1000 just stops and no data is sent.

Any idea what could be causing the communication from Arduino to Arduno to fail? Same code works fine from an Arduino Uno to a Nano as I mentioned before, but not with either of the MKR10XX,

As a second update I have been able to make serial communication work between the MKR1000 and the Nano but only when sending the bytes directly using the Wire class. There seems to be something wrong with the I2C_Anything library when the Master is the MKR10XX.

AVR and ARM are different architectures. The simple approach Nick has chosen to use direct pointers to the byte representation in memory doesn’t work across architecture boundaries in many cases.

AVR is little-endian while ARM is bi-endian and defaults to big-endian if I remember correctly. So to transfer data other than simple bytes you have to convert them to network endianess to have a reliable transfer.

Do you have an example using htons and htonl?

What kind of data do you need to transfer?

These are the 2 structures I need to transfer:

enum class One {X, Y, Z}; enum class Two {A, B, C};

struct SCP{ byte Source; One A; char Code[6]; Two B; };

struct SRP{ byte Source; One A; };