I2C hall effect sensors

Hi there.

I'm doing a project where I am using magnetic hall effect position sensors. They interface with I2C but I can't seem to get them to work. I am using the Austria Micro Systems AS5510 10 bit linear position sensor.
Can anyone please help me get these things to start.

Thank you.

Here is the code:

#include <Wire.h>
#define addr 0x56

void setup() {
  // put your setup code here, to run once:
  Wire.begin();
  Serial.begin(9600);
}

void getData(byte *a, byte *b){
  Wire.beginTransmission(addr);
  Wire.write(addr);
  Wire.endTransmission();
  
  Wire.requestFrom(addr, 2);
  *a = Wire.read();
  *b = Wire.read();
}

void showData(){
  byte aa,bb;
  float iets = 0;
  getData(&aa,&bb);
  Serial.println(iets);
  delay(1000);
}

void loop() {
  // put your main code here, to run repeatedly:
  showData();
}

attached is the setup I am using.

AS5510_Datasheet_EN_v7.pdf (577 KB)

(deleted)

They interface with I2C but I can't seem to get them to work.

First make sure the two I2C lines have 4K7 pull up resistors on them.
Then get an I2C scanner and look to see if it appears on the bus where you expect it to be.

But yes spycatcher2K is quite right we do need more information. Schematic and code would be good for a start. Remember to stick to the rules at:-
How to use this forum

Sorry about that guys... I will post more information soon, thank you.

I modified the original post

All I am trying to do for now is get some sort of reading from the sensor when I move the magnetic strip over it.
I tried using the master read example with the address provided in the sketch and it gave me an output but the magnet had no affect on the output.

TiaanKilian:
I modified the original post

So what part of the how to use the forum said that!

In fact it specifically said do not change the contents of the original post apart from adding code tags, because it makes subsequent posts look stupid. Thanks for that. >:(

Now what Arduino are you using? The chip is a 3V3 chip and you have no level translator so you must use a 3V3 Arduino. You can not use a Uno or other 5V Arduino because the wire library pulls up the I2C lines to 5V which can damage the sensor.

Next you software is wrong.
I would advise against using pointers and why use floating point variables for integers that you will need to concatenate.
Also please read the data sheet, what do you expect from just reading two bytes from the sensor. You first need to write the register address you want and then read it. Figure 19 shows you what the registers do.
I also notice you have not set the sensitivity and so it is working at its least sensitive.

Thank you for your advice, I was using the uno but did not think about the signal voltage. Sorry about breaking all the rules.

I only want to read the data from the sensor, so I need to write the register for read access (0x00 or 0x01) to the sensor and then read the same register?

so I need to write the register 0x00 or 0x01 to the sensor and then read the same register?

Not quite
so I need to write the register 0x00 or 0x01 to the sensor and then read the sensor.
But as the pointer auto increments all you need to do is to write zero to the device and then read two bytes from it.

I know, this thread is a bit old. But I wrote a library for this sensor during a recent electronics project and I wanted to share it with others who are using the AS5510 too. My code is under a creative commons licence, so feel free to edit and improve it.

Regards

ThX1138

AS5510.zip (4.92 KB)