03-22-2022 11:32 AM
Hello,
I am calling the function bhy2_perform_self_test() of the C API using the virtual sensor IDs of the Accelerometer, Gyrosscope and Magnetometer. The call succeeds, but the test result returns test_status=9. It seems one has to use the BSX physical sensor IDs?
I found this: https://github.com/BoschSensortec/BSX4-HAL-4.1NoFusion/blob/master/sensord/bsx/inc/bsx_physical_sens...
With these IDs the self test succeed. Are these the correct IDs to use?
Solved! Go to Solution.
03-23-2022 07:14 AM
Hi sebp,
As you call the function bhy2_perform_self_test() to do self test, sensor ID should use BSX input physical sensor ID, not use virtual sensor ID.
Yes, you could use them.
04-09-2022 11:21 PM
Hi!
Can you share an example of a self-test code?
It will be very helpful! Thanks!
04-10-2022 11:33 AM
I am using the Arduino IDE. Because the Arduino_BHY2 lib does not expose all functionality of the bhy2 C API and also does not give access to the bhy2_dev structure, you have to add the following code to the BoschSensortec class in BoschSensortec.h:
public:
bhy2_dev& dev() {return _bhy2;};
In the setup() function of the Arduino sketch I do this:
void setup()
{
...
struct bhy2_self_test_resp accel_result;
int err = bhy2_perform_self_test(BSX_PHYS_SENS_ID_ACCEL, &accel_result, &sensortec.dev());
if (err != BHY2_OK) {
goto Error;
}
if (accel_result.test_status != 0) {
goto Error;
}
...
set_LED_color(0xff,0xff,0); // yellow
return;
Error:
set_LED_color(0xff,0,0);
}
"sensortec" is a global variable defined by the Arduino_BHY2 lib.