I2C Issue connecting between Arduino Unos

Thread Starter

SamR

Joined Mar 19, 2019
1,474
First time I have tried this and it's not working. Second Uno is power but the sketch is not loading into it apparently. Seems to work on 1st UNO and after the 2nd UNO times out failing to connect the sketch runs in the 1st UNO.

C:
//Communicating Between Arduino Units
#include<Wire.h>
#include<TimerOne.h>

int state = 0;
int value;
long int newtime;

void setup() {
  Wire.begin(1);
  Wire.onReceive(gotRate);
  pinMode(13, OUTPUT);
  digitalWrite(13, state);
}

void loop() {
  }

void gotRate(int howMany){
  if(Wire.available())
  {
    value=Wire.read();
    newtime=value*1000000;
    Timer1.initialize(newtime);
    Timer1.attachInterrupt(blinkme);
  }
}

void blinkme(){
  state=!state;
  digitalWrite(13,state);
}
ERROR Msg:
Sketch uses 2852 bytes (1%) of program storage space. Maximum is 253952 bytes.
Global variables use 194 bytes (2%) of dynamic memory, leaving 7998 bytes for local variables. Maximum is 8192 bytes.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
An error occurred while uploading the sketch

Using pins A4 A5 to communicate and yes they are crossed w/ 1kΩ pullup resistors on the lines
IMG_0567[1].JPG
 

smp4616

Joined Oct 31, 2019
30
what's the resistance on the led hooked to pin 13? afaik that's one of the pins needed to program the 328p, if the impedance of something you have connected to it is too low it won't program correctly
 

Papabravo

Joined Feb 24, 2006
12,684
Why are they crossed? Schematic! Schematic! Schematic!
You should have SCL to SCL and SDA to SDA.
The SDA is common to both systems and passively pulled up. SCL is common to both systems and passively pulled up.
Wassa matter u?
Also one Uno must be the master and the other Uno must be the slave.
 

Thread Starter

SamR

Joined Mar 19, 2019
1,474
I guess I was on Autopilot from all the years working with RS-232. I2C is fairly new to me. No probs...
 
Top