Hi everyone,
I’m having some issues with a custom library I am creating to add a custom I2C sensor (a magnetic encoder, AS 5600) to the existing code so I can make measurements during flight. I’m not sure if I ought to be posting this here or under the dev forum, but I don’t have posting privileges for the dev forum anyways.
The issue I am having is in actually communicating with the I2C device. I have successfully written and built the new library, added it to the waf, and uploaded it to the pixhawk4 mini which I am using for this project. The library is meant to get the angle measurement from the AS5600 sensor and then write it to the onboard flight log. I know that my code is running on the device because it is creating the log files, however it is recording a value of -1, which I programmed the software to do when the I2C data transfer is unsuccessful.
I have successfully tested the sensor using an Arduino, and checked my wire connections multiple times to ensure I haven’t gotten them wrong. I am using the uart/I2C port on the PH4-mini to supply the 5V and ground connections, as well as using the sda2 and scl2 pins for communications.
My first instinct was the bus number was wrong, as I was setting it manually, but I have now tried all the bus numbers from 0-3 (all available I2C bus numbers for the PH4-mini) with the same result.
I believe this to be a software problem and not a hardware issue, so I’ve attached my library files below. To use the library I simply create an instance of the AS_5600 class in the plane.h file and then created a function in Ardupilot.cpp which calls the .getRawAngle() function, and added it to the scheduler.
Thanks in advance for any help anyone can provide!
AS5600_AOA.cpp (7.6 KB) AS5600_AOA.h (1.9 KB)