Unless you really need the I2C support, the simplest method, over such a small distance, is to just use the Serial port. Connect the TX on one mbed to the RX on the other and vice-versa. Then use some code like this:
// config serial port for connection to other mbed
Serial mbed1Serial(p13,p14); // tx, rx
char a = 0;
...
mbedSerial.putc(a); // send char
...
and then on the other mbed, have it waiting for the character to come though:
// config serial port for connection to other mbed
Serial mbed2Serial(p13,p14); // tx, rx
char char_rx = 0;
...
char_rx=mbed2Serial.getc(); //get char
...
Or instead of sitting there waiting, it could be set up to respond to the interrupt generated when there is a serial character just received.
To go longer distances (in my case 30m of ethernet cable, in a noisy environment) I have used a MAX3232 chip at either end between the two mbeds and that seems to have worked OK (though I need to do some more testing to be sure).
Hope that helps in some way.
Hi, i am trying to communicate 2 mbed, by using the I2C lines with optocoupler. But i did not get any result. I am not sure if its the connection. I found the above picture from the internet, and connected it this way. Is it the right connection? or must i reduce the frequency.
Thank you.