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

A Wire.requestFrom() should not be encapsulated by Wire.beginTransmission() and Wire.endTransmission(). #8

Open
Koepel opened this issue Mar 17, 2018 · 0 comments

Comments

@Koepel
Copy link

Koepel commented Mar 17, 2018

The Wire.beginTransmission() and Wire.endTransmission() should only be used when writing data. They should not be used together with Wire.requestFrom().

The next files have that:

  • g33k/ArduinoProjects/2016 Arduino/PCF8574_Client/PCF8574_Client.ino
  • g33k/ArduinoProjects/2016 Arduino/132-PCF8574/PCF8574_I2C_IO_Expander_Explosion/PCF8574_I2C_IO_Expander_Explosion.ino
  • g33k/ArduinoProjects/2016 Arduino/132-PCF8574/PCF8574_I2C_IO_Expander_Explosion2/PCF8574_I2C_IO_Expander_Explosion2.ino
  • g33k/ArduinoProjects/2016 Arduino/132-PCF8574/PCF8574_I2C_IO_Expander_Explosion3/PCF8574_I2C_IO_Expander_Explosion3.ino

For example this:

Wire.beginTransmission( address );
Wire.requestFrom((int)address, 1); // Ask for 1 byte from slave
val = Wire.read(); // read that one byte
error = Wire.endTransmission();

should be this:

Wire.requestFrom((int)address, 1); // Ask for 1 byte from slave
val = Wire.read(); // read that one byte
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