Skip to content

Problem with Wire Library #110

@st9040215

Description

@st9040215

I want to achieve I2C Read by using Wire library
Wire.endTransmission(false) always return 4
this code is OK with MEGA 2560 Board

I check this website: https://www.arduino.cc/en/Reference/WireEndTransmission
0:success
1:data too long to fit in transmit buffer
2:received NACK on transmit of address
3:received NACK on transmit of data
4:other error

7697 does not support wire library?

#include <Wire.h>

void setup()
{
Wire.begin();
Wire.setClock(50000L);
Serial.begin(9600);
}

uint8_t address = 0x0A;
uint8_t reg = 0x01;
uint8_t numBtyes = 2;
uint8_t R_code = 0;
uint8_t Buffer[64];

void loop()
{
int i = 0;
Wire.beginTransmission(address);
Wire.write(reg);
Serial.print(Wire.endTransmission(false));
delay(1);
Wire.requestFrom(address, numBtyes );
while(Wire.available())
{
Wire.read();
i++;
}

delay(1000);

}

Environment

  • Arduino BSP Version: 1.8.7
  • OS(Windows/macOS/Linux): Windows 7

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions