Pages: [1]   Go Down
Author Topic: Arduino Due to Mega i2C not working  (Read 690 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I have an arduino due connected via i2c to a mega. I am using the SDA and SCL channels on the mega which are connected to the SDA and SCL channels on the Due respectively. The two channels are powered by the 3.3 V from the Due, which runs through 1.5k Ohm pullup resistors. When transmitting data from the Due to the mega, I am not receiving any data from the Mega. I am using arduino 1.5.4. Here is the code for the Due:

#include <Wire.h>
#include <Timer.h>

Timer t;

void setup()
{
  Serial.begin (9600);
  Wire.begin(2);
  Serial.println("Starting");
  t.every(1000,transmitData);
}
void loop()
{
  t.update();
}

void transmitData()
{
  Serial.println("Transmitting data...");
  Wire.beginTransmission(1);
  Wire.write('G');
  Wire.endTransmission();
  Serial.println("Data transmitted.");
}


And the mega

under setup..
  // receive incoming data from uno board for shaft encoder
  Wire.begin(1);
  Wire.onReceive(receiveEvent);

....

void receiveEvent(int byteCount)
{
  Serial.println("Receive event");
  while(Wire.available())
  {
    char c = Wire.read();
    Serial.println("received from secondary board");
    Serial.println(c);
  }
}

The code previously worked fine with connecting to an arduino Uno but when I use the Due I get a very different result. Are there any quirks about the Due I should be aware of, such as the fact it takes 3.3V?
« Last Edit: September 21, 2013, 05:03:53 pm by Timboh56 » Logged

Italy
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
you probably need a voltage translator (page 10 http://www.nxp.com/documents/application_note/an97055.pdf) between the two boards.
Both the UNO and the MEGA run at 5V and so their SCL and SDA channels will take for logic level something like <0.3*Vdd is LOW and >0.7Vdd is HIGH. If you make the calculation 0.7Vdd with Vdd= 5V is 3.5V which is ok for a UNO to MEGA connection with the pull ups at 5V but it is higher than the 3.3V at which you are pulling up your lines when having the DUE to MEGA connection.
I would also suggest you to change the pullups. Rip out the one on the arduino Due (which on the schematic is said to be 1.5K but in reality is just 1K) and add an external 4.7K on both sides of the translator.
Bye,
Georgi
Logged

Pages: [1]   Go Up
Jump to: