I2C Slave No Response - Networking, Protocols, And Devices Home » Arduino I2c Slave Response » I2C Slave No Response - Networking, Protocols, And Devices Maybe your like Arduino Ide Avr/io.h No Such File Or Directory Arduino Ide Multiple If Conditions Arduino If Caractères Arduino Ifdef Endif Arduino If Digitalwrite High I2C slave no response Projects Networking, Protocols, and Devices Thomasx August 23, 2020, 8:23pm 1 Hi I have tried the below code on both an Arduino Uno and a Due (with correct voltages) to run them as I2C slaves, but I am not getting any response when trying to make a write to the Arduino. I have measured the I2C bus with an oscilloscope to verify that the signalling from the master is correct, start bit, address and write bit are all ok, but no ack from the Arduino. Any suggestions on what could be wrong? Thanks! // Wire Slave Receiver // by Nicholas Zambetti <http://www.zambetti.com> // Demonstrates use of the Wire library // Receives data as an I2C/TWI slave device // Refer to the "Wire Master Writer" example for use with this // Created 29 March 2006 // This example code is in the public domain. #include <Wire.h> void setup() { Wire.begin(8); // join i2c bus with address #4 Wire.onReceive(receiveEvent); // register event Serial.begin(9600); // start serial for output Serial.println("Ready to receive"); } void loop() { } // function that executes whenever data is received from master // this function is registered as an event, see setup() void receiveEvent(int howMany) { while(1 < Wire.available()) // loop through all but the last { char c = Wire.read(); // receive byte as a character Serial.print(c); // print the character } int x = Wire.read(); // receive byte as an integer Serial.println(x); // print the integer } Thomasx August 23, 2020, 9:50pm 2 Ok, so I got the Due to acknowledge the address and some data. I noticed the master and slave handles the addresses differently. The master sends bit1-bit7 as the 7-bit address, while the slave (due) treats the 7-bit address as bit0-bit6. So, sending address 0x10 equals address 0x08 on receiver side in my case. I also found someone saying it's not allowed to have Serial commands in the interrupt routine, and that makes sense. So I re-wrote a bit. But I am not getting any output even though the Due acknowledges data transfer. Any ideas why that may be? // Wire Slave Receiver // by Nicholas Zambetti <http://www.zambetti.com> // Demonstrates use of the Wire library // Receives data as an I2C/TWI slave device // Refer to the "Wire Master Writer" example for use with this // Created 29 March 2006 // This example code is in the public domain. #include <Wire.h> char buffer[100]; int incount=0; int outcount=0; int x=0; void setup() { Wire.begin(8); // join i2c bus with address #4 Wire.onReceive(receiveEvent); // register event Serial.begin(9600); // start serial for output Serial.println("Ready to receive"); } void loop() { if(incount!=outcount){ Serial.print(buffer[outcount++]); if(outcount==100) outcount=0; } if(x!=0){ Serial.println(x); x=0; } } // function that executes whenever data is received from master // this function is registered as an event, see setup() void receiveEvent(int howMany) { while(1 < Wire.available()) // loop through all but the last { buffer[incount++] = Wire.read(); // receive byte as a character if(incount==100) incount=0; //Serial.print(c); // print the character } x = Wire.read(); // receive byte as an integer //Serial.println(x); // print the integer } Thomasx August 23, 2020, 9:59pm 3 Ok, Got it working! Turns out if the data sent to the Arduino on the I2C bus is more than 32 bytes long, it won't return anything. As I understand it, it doesn't even call the receiveEvent IRQ routine. It just disappears into the binary universe. 1 Like Related topics Topic Replies Views Activity Due won't write I2C data when slave Networking, Protocols, and Devices 12 1993 May 6, 2021 I2C Error Networking, Protocols, and Devices 6 5626 May 6, 2021 I2C Problem, Communicating Between Two Arduinos Networking, Protocols, and Devices 25 18292 May 6, 2021 I2C on DUE - only address is output on serial, no data! Due 3 1058 May 6, 2021 Arduino DUE I2C Issues Due 4 4480 May 6, 2021 Tag » Arduino I2c Slave Response I2C Slave Reply - Programming Questions - Arduino Forum Arduino I2c Slave Not Replying On Request Delay I2C Slave Response - Clock Stretching - Arduino Forum I2C Communication Between Master And Slave - Arduino Forum Wire Library - How Can A Slave Reply Without Using OnRequest? Wire Lib Question: As I2C Slave, How To Read The Request From Master Master Reader/Slave Sender - Arduino Arduino I2C Slave Response Wrong Value - Stack Overflow Send Command To Slave And Receive Response Over I2c Arduino I2C And Multiple Slaves : 8 Steps - Instructables [PDF] A-level (1st Sem.) Subject:IoT Topic: I2C In Arduino Date: 20.04.2020 I2C/Wire In Arduino Uno - Tutorialspoint WEEK14 - Fab Academy Arduino - MasterReader - GitHub Pages