i2c problems

hi, i am interfacing SureElectronic's Dual-axis magnetic sensor, and i cant "translate" datasheet instructions into the Wire library command. Please help.

pdf - http://www.sure-electronics.net/download/down.php?name=DC-SS503_Ver1.0_EN.pdf
(cant copy text from within)

here's what i got so far but its not working, i dont understand those Cycles at all.

 Wire.beginTransmission(0x60);
 Wire.send(0x00); 
 Wire.endTransmission();

  Wire.beginTransmission(0x60);
 Wire.send(0x01); 
 Wire.endTransmission();
 delay(6);
  Wire.requestFrom(0x60, 5);
  while(Wire.available())
 {
   val = Wire.receive();
   Serial.print(val);Serial.print(" ");
 }

The data sheet says the address is 0110000,
Your code has the address as 0x60, this in binary is 1100000, so you should be using an address of 0x30.

thanks for the info, (in the example it says 0x60 somewhere),
but the thing is still not working as it should. i keep getting the same data: 0 0 16 0 128 27
i dont understand the cycles to get the 5 byte data form the chip. Please help

(in the example it says 0x60 somewhere),

Yes it says that once in the data sheet but all the other times it referrers to the address it shows a binary value of 0x30.
have you tried 0x30 ?

It is odd that you get a pattern of 6 values as there are only 5 internal registers.
Anyway you are not writing a "1" into the device to initiate a data conversion cycle. Therefore you keep reading back the last value.

I would change the code so that you read all five bytes at a time as well as writing the "Take measurement" bit into it.
Then as it says in the application note cited at the end of the data sheet a set and reset of the coils might be required. However I would write a separate sketch to do this once in the setup and not incorporate it into your normal sketch.

hi, i know i should "write 00000001" to indicate the data aquisition but the problem is i dont know how to "write" or "read" or "start","stop" or how to "send acknowledge" in terms of Wire library. I have read the Reference (and the manual for this sensor like 10times) but still i cant piece them together.

Here is my current code:

#include <Wire.h>
int val; 
void setup()
{
  Serial.begin(9600);
  Wire.begin();
   Wire.beginTransmission(0x30);
   Wire.send(0x00); 
   Wire.endTransmission();
  Wire.requestFrom(0x30, 1);
  while(Wire.available())
   {
   val = Wire.receive();
   Serial.print("start: ");Serial.println(val);
   }   
}
void loop()
{ 
 Wire.beginTransmission(0x30);
 Wire.send(0x01);
 Wire.endTransmission();
 Wire.beginTransmission(0x30);
 delay(6);
 Wire.requestFrom(0x30, 5);
 while(Wire.available()) {
   val = Wire.receive();
   Serial.print(val,BIN);Serial.print(" ");
 }
 Wire.endTransmission();
 Serial.println();

delay(100);
}

The really strange thing is that the output is always:

...
0 10000 0 0 1101 
0 10000 0 0 1101 
0 10000 0 0 1101 
0 10000 0 0 1101 
0 10000 0 0 1101 
0 10000 0 0 1101 
0 10000 0 0 1101 
...

even if i unplug GND or 5V connecting to the sensor board. (if i unplug both it stops receiving this data).

Try this:-

#include <Wire.h>
int val[5]; // array to hold your data
void setup()
{
  Serial.begin(9600);
  Wire.begin();  // start the I2C interface
}
void loop()
{
  int i;
  // first send 0x01
 Wire.beginTransmission(0x30);
 Wire.send(0x01);
 Wire.endTransmission();
 
 // now read five bytes back
 Wire.requestFrom(0x30, 5);
 for(i = 0; i<5; i++){
 while(!Wire.available()) { } // do nothing until data arrives
   val[i] = Wire.receive();
 }
 // now print it out
 for (i = 0; i<5; i++){
   Serial.print(val[i],BIN);Serial.print(" ");
 } 
 Serial.println();
delay(1000);
}

output:

...
0 11100 100 10100100 11011 
0 11100 100 10100100 11011 
0 11100 100 10100100 11011 
0 11100 100 10100100 11011 
0 11100 100 10100100 11011 
...

OK,
Try sending it 0x00 just before you read from it.
So send 0x01
send 0x00
read 5 bytes.

...
0 0 11100 100 10100100 
0 0 11100 100 10100100 
0 0 11100 100 10100100 
0 0 11100 100 10100100 
0 0 11100 100 10100100 
0 0 11100 100 10100100 
...

maybe i have it connected wrong? +5V,GND,SDA,SCL, anything else?
(i think Opt pin is only for UART version, it seems to have no effect)

Try giving it the zero memory address pointer like this:-

#include <Wire.h>
int val[5]; // array to hold your data
void setup()
{
  Serial.begin(9600);
  Wire.begin();  // start the I2C interface
}
void loop()
{
  int i;
  // first send 0x01
 Wire.beginTransmission(0x30);
 Wire.send(0x01);  // initilise sequence
 Wire.send(0x00);  // zero memory address pointer
 Wire.endTransmission();

 // now read five bytes back
 Wire.requestFrom(0x30, 5);
 for(i = 0; i<5; i++){
 while(!Wire.available()) { } // do nothing until data arrives
   val[i] = Wire.receive();
 }
 // now print it out
 for (i = 0; i<5; i++){
   Serial.print(val[i],BIN);Serial.print(" ");
 }
 Serial.println();
delay(1000);
}

SDA and SCL could do with external pullups of about 4K7 but in this case I do think we are talking to the device, it's just we are not doing it write. The data sheet is not too clear on this.
It does say the 4 MSBs should be zero and we are seeing this.
Also try the 0x60 address again.

...
10100 100 10100100 11011 1101010 
10100 100 10100100 11011 1101010 
10100 100 10100100 11011 1101010 
10100 100 10100100 11011 1101010 
...

i have also been experimenting with beginTransmission, endTransmission placements, but no luck so far. This thing is really frustrating..
(also with address 0x60, i get nothing)

i have sent an email to the SureElectronics' tech department requesting an example for this sensor, here is the C example:

void getMagValue(void)
{        int a;
         i2c_Open(0b01100000,I2C_WRITE);
         DelayUs(10);
         i2c_PutByte(0b00000000);
         DelayUs(10);
         i2c_PutByte(0b00000001);
         DelayUs(10);    
         i2c_Stop();
         for(a=0;a<600;a++)DelayUs(100);
         i2c_Start();
         i2c_PutByte(0b01100001);
         b[0]=i2c_GetByte(I2C_MORE);
         b[1]=i2c_GetByte(I2C_MORE);
         b[2]=i2c_GetByte(I2C_MORE);
         b[3]=i2c_GetByte(I2C_MORE);
         b[4]=i2c_ReadByte();
         i2c_Stop();
         
}
 
And there may be something wrong with your program, Wire.beginTransmission(0x30);.
The 0x30 should be 0x60.

can you please help me translate this into an Wire library code?