Arduino I2C and mod-tc-mk2-31855 [SOLVED]

Started by enricocas, May 24, 2013, 06:47:09 PM

Previous topic - Next topic

enricocas

Hi everybody,
I'm trying to interface an arduino to the MOD-TC-MK2-31855 sensor board, but I'm having many difficulties getting data. I post here the sketch I wrote. Is it correct, or am I doing something wrong?? I'm getting all 255 int values.
Thank you very much,



#include <Wire.h>

void setup(){
  pinMode(A4, INPUT);
  pinMode(A5, INPUT);
  Wire.begin();
  Serial.begin(9600);
}
void loop(){
  Wire.beginTransmission(byte(0x48));
  Wire.write(0x01);
  Wire.write(0xA0);
  Wire.write(byte(0x23));
  Wire.endTransmission();
  //Wire.beginTransmission(byte(0x48));
  Wire.requestFrom(0x48,4);
  //Wire.endTransmission();
  byte c[4];
  int i=0;
  Serial.print("Start geting data");
  while(Wire.available())
  {
    c[i] =Wire.read();
    Serial.print(int(c[i]));
    i++;
  }
  delay(1000);
}




selfbg

Hi Enrico,

Replace

Wire.write(byte(0x23))

with

Wire.write(byte(0x21))


If this doesn't work for you try to reduce slightly I2C speed to 80kHz.
Edit twi.h file (Arduino_dir/libraries/Wire/utilites/):

#define TWI_FREQ 80000L

olimex



jack

do you know if you can connect together 2or more of mk2 to A4, A5?

olimex

yes, many MK2 can be connected on same I2C bus as they could have different addresses

jack

how to change address?
do you have a picture of how to connect to arduino? thanks


jack