Olimex Support Forum

DUINO => ARDUINO => Topic started by: enricocas on May 24, 2013, 06:47:09 PM

Title: Arduino I2C and mod-tc-mk2-31855 [SOLVED]
Post by: enricocas on May 24, 2013, 06:47:09 PM
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);
}



Title: Re: Arduino I2C and mod-tc-mk2-31855
Post by: selfbg on May 27, 2013, 02:45:47 PM
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
Title: Re: Arduino I2C and mod-tc-mk2-31855
Post by: olimex on May 28, 2013, 05:46:49 PM
AVR-T32U4 #Arduino Leonardo measure temperatures from -250C to +1600C with thermocouples http://olimex.wordpress.com/2013/05/28/measuring-temperatures-from-250c-to-1600c-with-avr-t32u4-arduino-leonardo-and-mod-tc-mk2-31885-thermocouple/ ...
Title: Re: Arduino I2C and mod-tc-mk2-31855
Post by: enricocas on June 02, 2013, 08:50:11 PM
Thank you :D
Title: Re: Arduino I2C and mod-tc-mk2-31855 [SOLVED]
Post by: jack on June 28, 2013, 06:44:46 PM
do you know if you can connect together 2or more of mk2 to A4, A5?
Title: Re: Arduino I2C and mod-tc-mk2-31855 [SOLVED]
Post by: olimex on June 28, 2013, 07:11:25 PM
yes, many MK2 can be connected on same I2C bus as they could have different addresses
Title: Re: Arduino I2C and mod-tc-mk2-31855 [SOLVED]
Post by: jack on June 28, 2013, 10:08:44 PM
how to change address?
do you have a picture of how to connect to arduino? thanks
Title: Re: Arduino I2C and mod-tc-mk2-31855 [SOLVED]
Post by: jack on June 29, 2013, 12:35:13 AM
now it works!! WOW
Title: Re: Arduino I2C and mod-tc-mk2-31855 [SOLVED]
Post by: jack on July 03, 2013, 12:36:51 AM
sorry, how to change address?