Go Down

Topic: Need to reset arduino for i2c to work (Read 661 times) previous topic - next topic

Nick Gammon

My point is you may well write this:

Code: [Select]

    while (Wire.requestFrom(12, 1) == 0)

Wire.requestFrom waits until it has a response (or a NAK) and the length of that response is returned from Wire.requestFrom. So, you may as well test that.

I can't reproduce your results.

Connecting two Unos, if I reset the Master, a moment later the LED flashes, indicating it read from the Slave.

If I reset the Slave, nothing happens (because the Master has already entered loop), unless I hold the Slave in reset, reset the Master, and then release the Slave from reset.


i'd save time and effort and use softserial why do so many go for i2c/spi over uart?

Nick Gammon

SoftSerial has quite a few limitations because it is bit banged. It's fine if you need to print something on an attached printer, while checking for RFID cards (as I do). But if you need to do a number of things at once, then its limitations become more apparent. They may or may not matter in a particular application.

Both SPI and I2C use the hardware features to output quite fast, and receive incoming data using interrupts (I know SoftSerial uses interrupts too, but once it starts a byte it has to sit in a tight loop).

Your comment about "softserial" ... "over uart" doesn't make much sense on its own, because SoftSerial doesn't use the UART.

With a larger chip like the Mega you could indeed use multiple hardware serial ports, if your application required it.


I was referring to the kind of communication used, to me recv/send is via 2 wires, eg hardware support pin 0 & 1

Go Up