Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with using second I2C bus on ESP32 for two AS5600 encoders #39

Closed
jtran03 opened this issue Jun 27, 2023 · 9 comments · Fixed by #41
Closed

Bug with using second I2C bus on ESP32 for two AS5600 encoders #39

jtran03 opened this issue Jun 27, 2023 · 9 comments · Fixed by #41
Assignees
Labels
bug Something isn't working

Comments

@jtran03
Copy link

jtran03 commented Jun 27, 2023

I have been trying to implement two AS5600's on the same ESP32 using its two I2C bus interfaces. However, after running this code here:

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

const int SCL_1 = 23; 
const int SDA_1 = 22;
const int SCL_2 = 19;
const int SDA_2 = 18; 

AS5600 as5600_0(&Wire);
AS5600 as5600_1(&Wire1);


void setup()
{
  // Initialise Serial Connection
  Serial.begin(115200); 

  // Initialise as5600_0 Connection
  as5600_0.begin(SDA_1, SCL_1); 
  Serial.print("Connect device 0: ");
  Serial.println(as5600_0.isConnected() ? "true" : "false");
  
  // Initialise as5600_1 Connection
  as5600_1.begin(SDA_2, SCL_2); 
  Serial.print("Connect device 1: ");
  Serial.println(as5600_1.isConnected() ? "true" : "false");
}


void loop()
{
  Serial.print(millis());
  Serial.print("\t");
  Serial.println(as5600_0.rawAngle() * AS5600_RAW_TO_DEGREES);
  Serial.print("\t");
  Serial.println(as5600_1.rawAngle() * AS5600_RAW_TO_DEGREES);
  Serial.print("\n");
  delay(100);
}

It caused the 2nd AS5600 is to copy the readings of the 1st AS5600. I found that temporary fix is to comment out line 68 of AS5600.cpp:

// _wire = &Wire;

@RobTillaart RobTillaart self-assigned this Jun 27, 2023
@RobTillaart
Copy link
Owner

I will look into this issue asap, but it might take a few days.

@RobTillaart RobTillaart added the bug Something isn't working label Jun 27, 2023
@RobTillaart
Copy link
Owner

Will merge -#40 first today.

@RobTillaart
Copy link
Owner

@jtran03
As I have no hardware setup nearby, are you able to do some testing when I provide a new branch?

@RobTillaart
Copy link
Owner

Will merge -#40 first today.

done

@RobTillaart
Copy link
Owner

RobTillaart commented Jun 27, 2023

@jtran03

I found that temporary fix is to comment out line 68 of AS5600.cpp:

Thanks
Your analysis is correct, it has been in the code since initial release.
New release will be 0.4.0 as this is serious bugfix.

@jtran03
Copy link
Author

jtran03 commented Jun 27, 2023

@jtran03 As I have no hardware setup nearby, are you able to do some testing when I provide a new branch?

Yep

RobTillaart added a commit that referenced this issue Jun 27, 2023
@RobTillaart
Copy link
Owner

Created develop branch and a PR - #41

  • minimal code change, only removed that one line.
  • includes minor edit in readme.md about pull ups when using an UNO.

I'll wait for your test results, thanks!

@RobTillaart RobTillaart linked a pull request Jun 27, 2023 that will close this issue
@jtran03
Copy link
Author

jtran03 commented Jun 27, 2023

Hi,

Tested both sensors using as5600.readStatus() and as5600_0.readAngle and it seems to be working fine

@RobTillaart
Copy link
Owner

Thanks, will merge and release

RobTillaart added a commit that referenced this issue Jun 28, 2023
- fix #39 support for Wire2 on ESP32
- update readme.md
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants