Arduino Arduino I2C problem

Hi great forum!

After solving the problem of programming Arduino chips with my one and only Arduino board by your helps, I decided to connect them via I2C.

I used this:

which I picked up from playground.

Kept is simple and just as diagrammed on the tutorial there, but id does not work!

Arduinos are being programed right (tested), all connections 4 times checked, but what could be the reason? how to debug?

please help!

Edit: just to make sure, Analogue 4 of both connected, Analogue 5 of both connected, and both of these connections are connected to +5 via 1.5k resistors each.

Thank you, well I didn't do anything other than what the tutorial instructed and the code also. I didn't copy/pasted the code here to save space (they are on that link). I needed I'll do.

The test:
A master slave configuration. One Arduino - the master - changes a variable from 0 to 10 incrementally, and sends its through i2c to the other. The slave one test if it is 0, and blinks one LED or the other. In the slave program in the setup() the same var (being read) is set to zero. In my test it is always kept on zero (the related LED) blinking. Seems the connection is not active, but I didn't do anything other that what is stated in the tutorial (from playground).

Analogue 4 of both connected, Analogue 5 of both connected

What is with GROUND? They call it TWI just for marketing ....

Grounds are connected together, as in that tutorial. I used just the diagram there as a start to implement the first time i2c.

Edit: my connection setup:

My Wire library contains a master_writer and a slave_receiver example which should work together.... I am sure I tested that some months ago

So could you please point me to an "i2c hello world" please?

My exact case is communicating of 2 Arduinos, but googling also gives that same tut as a result.

Here's a very simple example I threw together. The slave simply returns 1 character at a time. The master fetches it and prints it to the serial port.

I wrote this code by referencing the documentation at Wire \ Libraries \ Wiring

Maybe this will get you started.


Thank you, I programmed Arduinos with given new tutorial, and again no results. I only receive the messages: "master sleeping...go" that shows that Arduino is working and then nothing, as in the pic bellow. All connections checked.

Same configuration with both analogue 4s connected and go to +5 by a (now) 4.6k resistor, the same setup for analogue 5s, grounds joined, and nothing else in the configuration.

How to step out of this situation please?

how long are the wires between the arduinos?


You didn't state explicitly what type of Arduino(s) you are trying to wire together. If one or both is a Mega board the I2C pins numbers used are different then the standard 168/328 boards. Just a shot in the dark. :wink:


Kg4wsv, I set up the wires today. I can't get your point, is it important how long they are there?

Retrolefty, one of them is 168 and the other 328. I am following this map:

I have no idea why this simple 2wires should not work for me, I tested everything!

Gurus please give some ideas!

Gurus please give some ideas!

Novice give some data please! we can't read your mind, and I can't see your hardware from here.

Yes, it matters very much how long the wires are. I2C is designed for Inter-Integrated Circuit communications - i.e., communicating between chips on a typical PCB. It is not, for example, meant to communicate between 2 boards with 100m of cable between them.


Jason the wires are 30cm, and my hardware is ordinary Atmega168 and Atmega328 with Arduino bootloader tested, and connected simply this way:

The 168 chip is powered by the Arduino standard board. The 328 one by the 5v regulator of SparkFun (also tested). I'm confused because everything is tested and all implementation is standard, nothing mine, and still does not work!

I programmed both with the code you kindly gave, had no errors and successfully downloaded to the chips.

I tested all connections with multimeter, no error found.

If a photo needed I can send it only by tomorrow, but till tomorrow headache may kill me (I can't sleep with having errors on Arduinos!) :smiley:

30cm is fairly long. Try it with the wires as short as possible, e.g. a couple of inches.

Are you in a noisy environment, EMI-wise? Any large motors, fluorescent lights, etc nearby?


I'm in bedroom, and in the bedroom I don't usually keep large motors, fluorescent lights, you know :smiley:

Radio Swiss Jazz is the only sound wave generator around me.

I'll now try it with very short wires and post the results :smiley:

Jason, I used a 10cm wire, and brought everything into one breadboard to keep a.s.a.p.

Didn't work either.

I don't bother the forum further I think the problem must be something trivial like lots of novice issues. I'll get a TC74 temp. sensor which is I2C based, and implement this tutorial separately with each Arduino I have. This differentiates the procedure and may help to clear the problem: