Skip to main content
Improved formatting.
Source Link
sa_leinad
  • 3.2k
  • 2
  • 24
  • 53

I am trying to read data from the registers 6, 7, 8 and 9 of the STC3100 ( Data Sheet: enter link description hereData Sheet) using an arduino uno. 

I followed this tutorial: https://howtomechatronics.com/tutorials/arduino/how-i2c-communication-works-and-how-to-use-it-with-arduino/ And adjusted the device and register adress accordingly. 

This isn't working and instead of returning the data on the register I'm just getting 16 over and over again.

Here is my code:

#include <Wire.h>
int ADXLAddress = 0x70; 

#define X_Axis_Register_DATAX0 0x08 

#define X_Axis_Register_DATAX1 0x09 

#define Power_Register 0x00 

int X0,X1,X_out;

void setup() {

  Wire.begin(); 

  Serial.begin(9600);
  delay(100);
  Wire.beginTransmission(ADXLAddress);
  Wire.write(Power_Register);
  Wire.write(16);  
  Wire.endTransmission();
}
void loop() {
  delay(2000);
  Wire.beginTransmission(ADXLAddress);  
  
  Wire.write(X_Axis_Register_DATAX0);
  Wire.write(X_Axis_Register_DATAX1);
  
  Wire.endTransmission();

  Wire.requestFrom(ADXLAddress,2); 
  
  if(Wire.available()<=2) {  
    X0 = Wire.read(); 
    X1 = Wire.read();   
  }
  
  Serial.print("X0= ");
  Serial.print(X0, BIN);
  Serial.print("   X1= ");
  Serial.println(X1, BIN);
}

I am trying to read data from the registers 6, 7, 8 and 9 of the STC3100 ( Data Sheet: enter link description here) using an arduino uno. I followed this tutorial: https://howtomechatronics.com/tutorials/arduino/how-i2c-communication-works-and-how-to-use-it-with-arduino/ And adjusted the device and register adress accordingly. This isn't working and instead of returning the data on the register I'm just getting 16 over and over again.

Here is my code

#include <Wire.h>
int ADXLAddress = 0x70; 

#define X_Axis_Register_DATAX0 0x08 

#define X_Axis_Register_DATAX1 0x09 

#define Power_Register 0x00 

int X0,X1,X_out;

void setup() {

  Wire.begin(); 

  Serial.begin(9600);
  delay(100);
  Wire.beginTransmission(ADXLAddress);
  Wire.write(Power_Register);
  Wire.write(16);  
  Wire.endTransmission();
}
void loop() {
  delay(2000);
  Wire.beginTransmission(ADXLAddress);  
  
  Wire.write(X_Axis_Register_DATAX0);
  Wire.write(X_Axis_Register_DATAX1);
  
  Wire.endTransmission();

  Wire.requestFrom(ADXLAddress,2); 
  
  if(Wire.available()<=2) {  
    X0 = Wire.read(); 
    X1 = Wire.read();   
  }
  
  Serial.print("X0= ");
  Serial.print(X0, BIN);
  Serial.print("   X1= ");
  Serial.println(X1, BIN);
}

I am trying to read data from the registers 6, 7, 8 and 9 of the STC3100 (Data Sheet) using an arduino uno. 

I followed this tutorial: https://howtomechatronics.com/tutorials/arduino/how-i2c-communication-works-and-how-to-use-it-with-arduino/ And adjusted the device and register adress accordingly. 

This isn't working and instead of returning the data on the register I'm just getting 16 over and over again.

Here is my code:

#include <Wire.h>
int ADXLAddress = 0x70; 

#define X_Axis_Register_DATAX0 0x08 

#define X_Axis_Register_DATAX1 0x09 

#define Power_Register 0x00 

int X0,X1,X_out;

void setup() {

  Wire.begin(); 

  Serial.begin(9600);
  delay(100);
  Wire.beginTransmission(ADXLAddress);
  Wire.write(Power_Register);
  Wire.write(16);  
  Wire.endTransmission();
}
void loop() {
  delay(2000);
  Wire.beginTransmission(ADXLAddress);  
  
  Wire.write(X_Axis_Register_DATAX0);
  Wire.write(X_Axis_Register_DATAX1);
  
  Wire.endTransmission();

  Wire.requestFrom(ADXLAddress,2); 
  
  if(Wire.available()<=2) {  
    X0 = Wire.read(); 
    X1 = Wire.read();   
  }
  
  Serial.print("X0= ");
  Serial.print(X0, BIN);
  Serial.print("   X1= ");
  Serial.println(X1, BIN);
}
added 1527 characters in body
Source Link
John
  • 21
  • 2

I am trying to read data from the registers 6, 7, 8 and 9 of the STC3100 ( Data Sheet: enter link description here) using an arduino uno. I followed this tutorial: https://howtomechatronics.com/tutorials/arduino/how-i2c-communication-works-and-how-to-use-it-with-arduino/ And adjusted the device and register adress accordingly. This isn't working and instead of returning the data on the register I'm just getting 16 over and over again.

Here is my code

#include <Wire.h>
int ADXLAddress = 0x70; 

#define X_Axis_Register_DATAX0 0x08 

#define X_Axis_Register_DATAX1 0x09 

#define Power_Register 0x00 

int X0,X1,X_out;

void setup() {

  Wire.begin(); 

  Serial.begin(9600);
  delay(100);
  Wire.beginTransmission(ADXLAddress);
  Wire.write(Power_Register);
  Wire.write(16);  
  Wire.endTransmission();
}
void loop() {
  delay(2000);
  Wire.beginTransmission(ADXLAddress);  
  
  Wire.write(X_Axis_Register_DATAX0);
  Wire.write(X_Axis_Register_DATAX1);
  
  Wire.endTransmission();

  Wire.requestFrom(ADXLAddress,2); 
  
  if(Wire.available()<=2) {  
    X0 = Wire.read(); 
    X1 = Wire.read();   
  }
  
  Serial.print("X0= ");
  Serial.print(X0, BIN);
  Serial.print("   X1= ");
  Serial.println(X1, BIN);
}

I am trying to read data from the registers 6, 7, 8 and 9 of the STC3100 ( Data Sheet: enter link description here) using an arduino uno. I followed this tutorial: https://howtomechatronics.com/tutorials/arduino/how-i2c-communication-works-and-how-to-use-it-with-arduino/ And adjusted the device and register adress accordingly. This isn't working and instead of returning the data on the register I'm just getting 16 over and over again.

I am trying to read data from the registers 6, 7, 8 and 9 of the STC3100 ( Data Sheet: enter link description here) using an arduino uno. I followed this tutorial: https://howtomechatronics.com/tutorials/arduino/how-i2c-communication-works-and-how-to-use-it-with-arduino/ And adjusted the device and register adress accordingly. This isn't working and instead of returning the data on the register I'm just getting 16 over and over again.

Here is my code

#include <Wire.h>
int ADXLAddress = 0x70; 

#define X_Axis_Register_DATAX0 0x08 

#define X_Axis_Register_DATAX1 0x09 

#define Power_Register 0x00 

int X0,X1,X_out;

void setup() {

  Wire.begin(); 

  Serial.begin(9600);
  delay(100);
  Wire.beginTransmission(ADXLAddress);
  Wire.write(Power_Register);
  Wire.write(16);  
  Wire.endTransmission();
}
void loop() {
  delay(2000);
  Wire.beginTransmission(ADXLAddress);  
  
  Wire.write(X_Axis_Register_DATAX0);
  Wire.write(X_Axis_Register_DATAX1);
  
  Wire.endTransmission();

  Wire.requestFrom(ADXLAddress,2); 
  
  if(Wire.available()<=2) {  
    X0 = Wire.read(); 
    X1 = Wire.read();   
  }
  
  Serial.print("X0= ");
  Serial.print(X0, BIN);
  Serial.print("   X1= ");
  Serial.println(X1, BIN);
}
Source Link
John
  • 21
  • 2

Can't read data from registers using I2C

I am trying to read data from the registers 6, 7, 8 and 9 of the STC3100 ( Data Sheet: enter link description here) using an arduino uno. I followed this tutorial: https://howtomechatronics.com/tutorials/arduino/how-i2c-communication-works-and-how-to-use-it-with-arduino/ And adjusted the device and register adress accordingly. This isn't working and instead of returning the data on the register I'm just getting 16 over and over again.