Jump to content
Sign in to follow this  

I2C problem between PcDuino V2 ans Arduino Mega 2560

Recommended Posts


I have a problem with the I2C communication between Arduino Mega 2560 and PcDuino V2. I search from 2 days for resolved my problem but is not good...


I have setup the I2C speed at 200 kHz as the PcDuino.


please see my code and send me your opinion...



void setup()


  Wire.begin(0x02);        // Active I2C en esclave
  Wire.setClock(200000L); // Configure la vitesse a 200 kHz comme le PcDuino




void receiveEvent(int howMany)
  while (1 < Wire.available()) // loop through all but the last
    char c = Wire.read(); // receive byte as a character
    Serial.print©;         // print the character
  x = Wire.read();    // receive byte as an integer
  Serial.println(x);         // print the integer
} // Fin du void receiveEvent(int howMany)


void requestEvent()
// Attends la demande du PcDuino pour envoyer les données en I2C
  Hydrometrie = 1;
  Temperature = 2;
  Luminosite = 3;


} // Fin du void requestEvent()



Et cote PcDuino:


def Reception_Donnees_I2C():

    global Hydrometrie, Temperature, Luminosite


    Hydrometrie = i2c.read_byte(Pcb_Relayage) # Lit un octet sur la carte relayage
    Temperature = i2c.read_byte(Pcb_Relayage) # Lit un octet sur la carte relayage
    Luminosite = i2c.read_byte(Pcb_Relayage) # Lit un octet sur la carte relayage


    print Hydrometrie
    print Temperature
    print Luminosite


I received 3 variables in RF 433 MHz by the Mega 2560 (Hydrometrie, Temperature, Luminosite)

and i send it to the PcDuino in I2C communication when the master want...

My problem is in the terminal, i received just 3x the number 3 and not 1,2,3...

Please see my code and send me your comments






Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this