We are trying to communicate between multiple Arduino's (in this example a Nano and a Mega) and a Raspberry Pi. The Raspberry pi is defined as master and the Arduino's as slaves. We would also like that the Arduino's communicate between each other. For example: The Mega requests from the Nano and at some point, the Mega also communicates with the Raspberry Pi. This is the short version of what we are trying to accomplish but we ran into the problem that the i2c communication failed between the Nano and Mega upon the request from the Mega to the Nano.

Schematic Schematic


After some time the i2c bus 'fills' up...


Code Nano

(We send RFID data to Mega)

#include <Wire.h>
#include "SPI.h"
#include "MFRC522.h"

#define SS_PIN 10
#define RST_PIN 9
#define SP_PIN 8

MFRC522 rfid(SS_PIN, RST_PIN);

MFRC522::MIFARE_Key key;

void setup() {


void loop() {


void requestEvent() {
  if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial())

  // Serial.print(F("PICC type: "));
  MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
  // Serial.println(rfid.PICC_GetTypeName(piccType));

  // Check is the PICC of Classic MIFARE type
  if (piccType != MFRC522::PICC_TYPE_MIFARE_MINI &&
      piccType != MFRC522::PICC_TYPE_MIFARE_1K &&
      piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
    Serial.println(F("Your tag is not of type MIFARE Classic."));

  String strID = "";
  for (byte i = 0; i < 4; i++) {
    strID +=
      (rfid.uid.uidByte[i] < 0x10 ? "0" : "") +
      String(rfid.uid.uidByte[i], HEX) +
      (i != 3 ? ":" : "");
  Serial.print("Send to Mega: ");




Code Mega

#include <Wire.h>

void setup() {

void loop() {
  Wire.requestFrom(0x10, 11);

  String uid = "";

  while (Wire.available()) {
    char c = "";
    c = Wire.read();
    uid += c;

  if (uid.indexOf(':') != 2) {



We would like to communicate between the Arduino's when the Raspberry Pi is master.


Pi and arduino works at different logic level bro. Also you gotta check if pull up resistors are needed in the SDA lines of I2C bus. I suspect internal pullups of UNO are not really useful. Use 2.2K pull-ups externally.

  • 1
    Thanks! Also you gotta check if pull up resistors are needed in the SDA lines of I2C bus. I placed a 1K pull-up between 3.3V and SDA and also a 1K pull-up between 3.3V and SCL according to this article: link. Thank you! Is the 1K between 3.3V and SCL needed? – Michielvk Nov 21 '17 at 19:06
  • Yea i guess you need pull up in both SDA and SCL. – Mitu Raj Nov 21 '17 at 19:22

Its a long time since I used a Pi, but isn't it a 3.3V device and the Arduinos are 5V devices. I think you may need a logic level shifter (not a resistor divider). I suspect that's the reason I2Cdetect isn't working and without that working, nothing else will.

  • Thanks for the suggestion, we'll try and let you know if it worked! – Michielvk Nov 21 '17 at 15:30
  • The level shifter isn't necessary I think (I'm not quite sure). But just to be sure; we'll put them in, thanks! – Michielvk Nov 21 '17 at 19:02

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.