04-16-2022 12:59 AM
I am trying to bring up a board with a BHI160B. Is the library found at https://github.com/BoschSensortec/BoschSensorHub known to work for this sensor?
The circuit involves a BHI160B with no attached secondary devices, should I be using the Bosch_PCB_7183_di03_BMI160-7183_di03.2.1.11696_170103.h firmware? The application only requires reading the accelerometer and gyroscope virtual sensors.
Solved! Go to Solution.
05-11-2022 12:07 AM
Hi BSTRobin,
Thanks again for your reply. The code you pasted didn't compile. I made a few changes:
"""
/* get virtual sensor information from sensor hub */
Serial.println("Supported Virtual Sensor Information:\n");
Serial.println("Supported Virtual Sensor Information:");
Serial.println("-wakeup-");
for(int i = 1; i < 32; i++)
{
//bhi160.getSensorInformation(BHY_VS_ORIENTATION, true, &information);
bhi160.getSensorInformation((bhyVirtualSensor)i, true, &information);
if(information.type == i){
Serial.print("id=");
Serial.println(i);
}
}
Serial.println("-non-wakeup-");
for(int i = 1; i < 32; i++)
{
bhi160.getSensorInformation((bhyVirtualSensor)i, false, &information);
if(information.type == i){
Serial.print("id=");
Serial.println(i);
}
}
//PDEBUG("");
"""
the above code produced the following output:
"""
Serial working
Sensor found over I2C! Product ID: 0x83
Uploading Firmware.
Firmware booted
Supported Virtual Sensor Information:
Supported Virtual Sensor Information:
-wakeup-
-non-wakeup-
id=1
id=2
id=3
id=4
id=9
id=10
id=11
id=14
id=15
id=16
id=17
id=18
id=19
id=20
id=22
id=23
id=24
id=25
id=31
BHY_VS_ORIENTATION wakeup
type: 35
driver_id: 254
driver_version: 1
power: 0
max_range: 1
resolution: 16
fifo_reserved: 0
fifo_max: 1893
event_size: 8
min_rate: 1
BHY_VS_ACCELEROMETER wakeup
type: 33
driver_id: 48
driver_version: 1
power: 1
max_range: 4
resolution: 16
fifo_reserved: 0
fifo_max: 1893
event_size: 8
min_rate: 1
Orientation callback installed
Failed to enable virtual sensor (Orientation (Non Wake-up)). Loaded firmware may not support requested sensor id.
"""
Thanks again for your help. It is odd to me that no wakeup virtual sensors appeared supported.
05-11-2022 04:07 AM
Hi bgfas,
From your print information, non-wakeup sensor ID BHY_SID_ACCELEROMETER and BHY_VS_ORIENTATION had been supported. You could enable virtual sensor like this and test it again.
bhi160.installSensorCallback(BHY_SID_WAKEUP_OFFSET + BHY_SID_ACCELEROMETER, false, accelerometerHandler))
bhi160.configVirtualSensor(BHY_SID_WAKEUP_OFFSET + BHY_SID_ACCELEROMETER, false, BHY_FLUSH_ALL, 25, 0, 0, 0))
05-11-2022 04:13 PM
Hi BSTRobin,
Unfortunately those modifications do not work. I had to change the lines to get them to compile:
bhi160.installSensorCallback((bhyVirtualSensor)(BHY_SID_WAKEUP_OFFSET + BHY_SID_ACCELEROMETER), false, accelerometerHandler)
bhi160.configVirtualSensor((bhyVirtualSensor)(BHY_SID_WAKEUP_OFFSET + BHY_SID_ACCELEROMETER), false, BHY_FLUSH_ALL, 25, 0, 0, 0)
However the accelerometer callback failed to install:
"""
Failed to install accelerometer callback
Error code: (-4). Out of range
"""
The wakeup accelerometer (32 + 1) was not present in the output for the code you previously suggested (no wakeup sensors appeared supported, so no sensor ids >32). Does that help to explain why the callback registration fails? If so, what might be the issue?
If I attempt to register a non-wakeup accelerometer (1), the callback registration does not return an error but the configuration does:
"""
Accelerometer callback installed
Failed to enable virtual sensor (Accelerometer (Non Wake-up)). Loaded firmware may not support requested sensor id.
"""
Thanks again for your help.
05-12-2022 04:16 AM
Hi bgfas,
From your prevous test information, sensor ID 33, 35 have been supported in sensor list for the firmware. But it is strange you couldn't enable them.
05-12-2022 08:02 AM
Hi bgfas,
1. Previous code I provided had some mistake. Now you could use the following code to print sensor ID list.
/* get virtual sensor information from sensor hub */
Serial.println("Supported Virtual Sensor Information:\n");
Serial.println("Supported Virtual Sensor Information:");
Serial.println("-wakeup-");
for(int i = 1; i < 32; i++)
{
bhi160.getSensorInformation((bhyVirtualSensor)i, true, &information);
if(information.type == (i + BHY_SID_WAKEUP_OFFSET)){
Serial.print("id=");
Serial.println(i);
}
}
Serial.println("-non-wakeup-");
for(int i = 1; i < 32; i++)
{
bhi160.getSensorInformation((bhyVirtualSensor)i, false, &information);
if(information.type == i){
Serial.print("id=");
Serial.println(i);
}
}
2. Your previous code that use API to install and config ACC sensor ID is correct. But as the API return failed value, could you check where there is an error return in the function?
bhi160.installSensorCallback(BHY_VS_ACCELEROMETER, true, accelerometerHandler);
bhi160.configVirtualSensor(BHY_VS_ACCELEROMETER, true, BHY_FLUSH_ALL, 25, 0, 0, 0);