Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wire.end() function does not seem to work #382

Open
Pascal2739 opened this issue Oct 16, 2024 · 1 comment
Open

Wire.end() function does not seem to work #382

Pascal2739 opened this issue Oct 16, 2024 · 1 comment

Comments

@Pascal2739
Copy link

Pascal2739 commented Oct 16, 2024

I am using the I2C outputs of an Arduino R4 minima board to make it communicate with other boards. I notice that the Wire.end() function does not seem to work. I commonly use this instruction to alternately switch the Uno R4 board to a "master" controller and a "slave" controller. Is this an error on my part?

Below is the sketch I am using for my tests.

"master" controller

/*  Test de fonctionnement du bus I2C
    Test d'envoi en controleur maitre de la carte
    uno R4.*/

#include <Wire.h>

void setup() {
  while (!Serial && millis() < 4000);
  Serial.println("Demarrage");
  Wire.begin(50);

}

void loop() {
  Wire.end();
  Wire.begin();
  Serial.println("Envoi d'un texte");
  Wire.beginTransmission(52);
  Wire.write("Test d'envoi en maitre");
  Wire.endTransmission();
  Wire.end();
  Wire.begin(50);
  /*Serial.println("Demande 6 caractères");
  Wire.requestFrom(52, 6);    // request 6 bytes from peripheral device #8
  while (Wire.available()) { // peripheral may send less than requested
    char c = Wire.read(); // receive a byte as character
    Serial.print(c);         // print the character
  }*/
  delay(10000);
}

"slave" controller

/*  Test de fonctionnement du bus I2C
    Test de réception en controleur esclave de la carte
    Arduino Nano-Every.*/

#include <Wire.h>

void setup() {
  Serial.begin(115200);
  Serial.println("Demarrage");
  Wire.begin(52);
  Wire.onReceive(receiveEvent);
  Wire.onRequest(requestEvent);

}

void loop() {
  delay(100);
}

void receiveEvent(int howMany)  {
  Serial.print("Nombre d'octets : "); Serial.println(howMany);
  while(Wire.available()) // loop through all but the last
  {
    char c = Wire.read(); // receive byte as a character
    Serial.print(c);         // print the character
  }
  Serial.println();
}

void requestEvent() {
  Wire.write("hello "); // respond with message of 6 bytes
}
@per1234 per1234 changed the title Wire library with Arduino Uno R4 minima Wire.end() function does not seem to work Oct 16, 2024
@Pascal2739
Copy link
Author

Hello, It seems that no one can answer me. However, I had already reported this problem on a previous version of the library in November 2023 (UNO R4 access to DS1307 only works if board is used as a master exclusively #180) and this problem had then been fixed. Perhaps this correction could be made to this library. Thank you for your answers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant