Connecting AS5600 through I2C

Hi there,
After trying to find it on google with no result I'll try to formulate my question here:
I can't connect to my AS5600 encoder, I tried many wiring diagrams but the same issue persists, it doesn't connect or receive anything.

Now it is wired up as the following:

  • 5v to vcc on AS5600
  • gnd to gnd
  • a4 to SDA on AS5600
  • a5 to SCL on AS5600

I am using the library by rob tillaart GitHub - RobTillaart/AS5600: Arduino library for AS5600 magnetic rotation meter
From the code:

  Serial.println(as5600.getAddress());
  int b = as5600.isConnected();
  Serial.print("Connect: ");
  Serial.println(b);

I get:
17:54:58.049 -> 54
17:54:59.031 -> Connect: 0

Help would be greatly appreciated

First run the I2C scan program and see if its address shows up. Also post a simple schematic showing exactly how it is wired up, we cannot see what you do. We have no clue as to what Arduino you are using. It also appears the code is secret, without the code we cannot help with that.

Hi,
if I scan for I2C adresses, I find 0x60 and 0x6B.

I used the following schematic, without the screen. Arduino is Nano RP2040 Connect

And want to use the following example code:

//
//    FILE: AS5600_position.ino
//  AUTHOR: Rob Tillaart
// PURPOSE: demo
//    DATE: 2022-12-20


#include "AS5600.h"
#include "Wire.h"

AS5600 as5600;   //  use default Wire


void setup()
{
  Serial.begin(115200);
  Serial.println(__FILE__);
  Serial.print("AS5600_LIB_VERSION: ");
  Serial.println(AS5600_LIB_VERSION);

  //  ESP32
  //  as5600.begin(14, 15);
  //  AVR
  as5600.begin(4);  //  set direction pin.
  as5600.setDirection(AS5600_CLOCK_WISE);  // default, just be explicit.

  Serial.println(as5600.getAddress());
  int b = as5600.isConnected();
  Serial.print("Connect: ");
  Serial.println(b);
  delay(1000);
}


void loop()
{
  static uint32_t lastTime = 0;
  Serial.print("test");
  //  set initial position
  as5600.getCumulativePosition();

  //  update every 100 ms
  //  should be enough up to ~200 RPM
  if (millis() - lastTime >= 100)
  {
    lastTime = millis();
    Serial.print(as5600.getCumulativePosition());
    Serial.print("\t");
    Serial.println(as5600.getRevolutions());
  }

  //  just to show how reset can be used
  if (as5600.getRevolutions() >= 10)
  {
    as5600.resetPosition();
  }
}


// -- END OF FILE --

I do not see how you pass the I2C address to the AS5600. I have not used this part or library so I am only taking a SWAG.

The address is assigned in the AS5600.h

I am not familiar with the part but it appears it is connected properly. Rob Tillaart is a genius with the arduino libraries and I have yet to have a problem with any of his libraries. The data sheet at: https://www.mouser.com/pdfdocs/AMS_AS5600_Datasheet_EN.PDF shows how to set it up in figure 24, have you followed that? I would assume the library works and you may have a bad part.

Yes, I tried three different AS5600 so I don't understand what the problem is...
Maybe the arduino is at fault.

I do not know either. If you can try something else that uses the I2C system and be sure your pull up resistors are in the 3-4K range for 5V. I have seen 10K pull up resistors behave a bit flakey on some setups.

To prevent a rookie mistake; the pull up resistors should be between the 5v and the output channels of the AS5600 right?

Not exactly but probably yes. You need to connect them between the 5V (assuming the processor runs at 5V) one to SCL and another to SDA. Can you post a link to your exact unit, I am finding 5V and 3.5 volt units. The pull up cannot exceed the chips operating voltage so if the arduino and the AS5600 are at 5 volts great. Check this link, I think this is what you have.

I dont know why, but with a good nights sleep and turning everything off and on. It now works.
Thanks for the replies

1 Like

I am glad it is all working:-)

You might be interested in library for as5600

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.