1
votes

The master board is a Arduino Uno and the slave is a Arduino Yun. I have them both wired up using A4 & A5 of one board to attach to the A4 & A5 pin on the other. They are both powered separately but share the same ground like the diagram below.

Board setup

The code for both master and slave are below. If the slave board is not powered the master knows it can not talk to the slave and won't print out Loop until the slave is powered. This suggests that the master knows of the slave.

However the slave never receives this signal from the master. receiveEvent is never called.

I am doing this as I have ran out of pins on the master and want the slave to control a LCD display that takes up several pins as I'm sure you all know.

Any help would be great, thanks.

Master

#include <Wire.h>

#define SLAVE_ADDRESS 0x9

void setup() {
  Serial.begin(9600); 

  Wire.begin();

  delay(1000);
}

void loop() {
    Wire.beginTransmission(SLAVE_ADDRESS);
    Wire.write('T');
    Wire.endTransmission();
    Serial.println("Loop");
    delay(1000);
}

Slave

#include <Wire.h>

#define SLAVE_ADDRESS 0x9

void setup() {
  Serial.begin(9600); 

  delay(1000);

  Wire.begin(SLAVE_ADDRESS);
  Wire.onReceive(receiveEvent);

  Serial.println("Setup");
}

void loop() {
//  Serial.println("Loop");
}

void receiveEvent(int howMany){
  Serial.println("Receive event");

  while (Wire.available() > 0)
  {
    char c = Wire.read();
    Serial.println(c);
  }
}

1

1 Answers

1
votes

Maybe you should think about the wiring.
Your Yun is using a different layout see: http://forum.arduino.cc/index.php?topic=191974.0
If the UNO is a R3 layout you can use the pins above AREF as far as I know. Check the exact pin-out of your Arduino(s).