I have to find a way to use the I2C bus communication using only wire.h classes (begin, read, write, beginTransmission, ecc...) but, if I do like so, I get only random values as a result.
I'm wondering if there's a way to make it work, because I tried to read some Adafruit libraries but I didn't find the information I needed.
Here you can find my code:
Code: Select all
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
}
int numOfBytes = 4;
byte x = 0;
void loop() {
/*I send to the slave its address and the register I want to read
In this way it should return the data I need /*
Wire.beginTransmission(0x69);
Wire.write(0x69); //sensor address
Wire.write(0x28); //register I want to read
Wire.requestFrom(0x69, numOfBytes);
while(Wire.available()){
count++;
x = Wire.read();
Serial.print(x);
Serial.print("\t");
}
Serial.println();
delay(1000);
}