This document is meant as a reference guide on how to design using Bosch Sensortec’s BHy1. BHy1 family includes two parts, one is BHA250 series, the other is BHI160 series.
Selecting the right part
The BHA250 contains part number: BHA250 and BHA250B. The BHA250/BHA250B is sensor hub which integrated Accelerometer. Figure1 shows the BHA250 laser marking.
Fig1
The BHI160 contains part number: BHI160and BHI160B. The BHI160/ BHI160B is smart sensor which integrated IMU(ACC+Gyro). Figure2 shows the laser marking.
Fig2
Common Characteristics
Key features
1xI2C(3.4MHz) Host Interface; 1xI2C(1MHz) Aux Interface; up to 3 GPIOs
32-bit Floating-point; 96 KB ROM; 48 KB RAM
Max ODR is 200Hz
Difference between products
Table 1: Difference on BHA250 and BHI160
Table 2: Accelerometer Parameter on BHA250 and BHI160
Table 3: BHI160 Gyroscope Parameter
Available evaluation tools and software
To best to evaluate the products from the BHy1 family is the following combination of evaluation tools:
Data parsing for activity recognition is available in COINES. The user can open the “bhy_activity_recognition.c” in COINES, compile and run. The output will be shown in the COINES console.
The code is shown as below.
/* @brief This API is used for parsing the activity recognition data from BHY
*
* @param[in] sensor_data: bhy data
* @param[in] sensor_id: bhy id
*
* @return void
*
*/
void sensors_callback(bhy_data_generic_t * sensor_data, bhy_virtual_sensor_t sensor_id)
{
float temp;
u8 index;
/* Since a timestamp is always sent before every new data, and that the callbacks */
/* are called while the parsing is done, then the system timestamp is always equal */
/* to the sample timestamp. (in callback mode only) */
temp = g_system_timestamp / 3200000.;
for (index = 6; index <= 8; index++)
{
outBuffer[index] = floorf(temp) + '0';
temp = (temp - floorf(temp)) * 10;
}
for (index = 10; index <= 12; index++)
{
outBuffer[index] = floorf(temp) + '0';
temp = (temp - floorf(temp)) * 10;
}
/* if there are no changes then it will read X */
outBuffer[22] = 'X';
outBuffer[35] = 'X';
outBuffer[48] = 'X';
outBuffer[61] = 'X';
outBuffer[74] = 'X';
outBuffer[87] = 'X';
/* '0' means "end of activity and '1' means start of activity */
if (sensor_data->data_scalar_u16.data & 0b0000000000000001)
outBuffer[22] = '0';
if (sensor_data->data_scalar_u16.data & 0b0000000000000010)
outBuffer[35] = '0';
if (sensor_data->data_scalar_u16.data & 0b0000000000000100)
outBuffer[48] = '0';
if (sensor_data->data_scalar_u16.data & 0b0000000000001000)
outBuffer[61] = '0';
if (sensor_data->data_scalar_u16.data & 0b0000000000010000)
outBuffer[74] = '0';
if (sensor_data->data_scalar_u16.data & 0b0000000000100000)
outBuffer[87] = '0';
if (sensor_data->data_scalar_u16.data & 0b0000000100000000)
outBuffer[22] = '1';
if (sensor_data->data_scalar_u16.data & 0b0000001000000000)
outBuffer[35] = '1';
if (sensor_data->data_scalar_u16.data & 0b0000010000000000)
outBuffer[48] = '1';
if (sensor_data->data_scalar_u16.data & 0b0000100000000000)
outBuffer[61] = '1';
if (sensor_data->data_scalar_u16.data & 0b0001000000000000)
outBuffer[74] = '1';
if (sensor_data->data_scalar_u16.data & 0b0010000000000000)
outBuffer[87] = '1';
fprintf(stderr, "%s", outBuffer);
/* activity recognition is not time critical, so let's wait a little bit */
mdelay(200);
}
Gesture recognition example
Data parsing for gesture recognition is available in COINES. The user can open the “bhy_gesture_recognition.c” in COINES, compile and run. The output will be shown in COINES console.
In the example code, three gestures are enabled, which are “Glance, Pickup and Significant Motion”. The code is shown as below.
/* @brief This API is used for parsing the activity recognition data from BHY
*
* @param[in] sensor_data: bhy data
* @param[in] sensor_id: bhy id
*
* @return void
*
*/
void sensors_callback(bhy_data_generic_t * sensor_data, bhy_virtual_sensor_t sensor_id)
{
float temp;
u8 index;
/* Since a timestamp is always sent before every new data, and that the callbacks */
/* are called while the parsing is done, then the system timestamp is always equal */
/* to the sample timestamp. (in callback mode only) */
temp = g_system_timestamp / 3200000.;
for (index = 6; index <= 8; index++)
{
outBuffer[index] = floorf(temp) + '0';
temp = (temp - floorf(temp)) * 10;
}
for (index = 10; index <= 12; index++)
{
outBuffer[index] = floorf(temp) + '0';
temp = (temp - floorf(temp)) * 10;
}
sensor_id &= 0x1F;
/* gesture recognition sensors are always one-shot, so you need to */
/* re-enable them every time if you want to catch every event */
bhy_enable_virtual_sensor(sensor_id, VS_WAKEUP, 1, 0, VS_FLUSH_NONE, 0, 0);
switch (sensor_id)
{
case VS_TYPE_GLANCE:
strcpy(&outBuffer[24], "Glance \r\n");
break;
case VS_TYPE_PICKUP:
strcpy(&outBuffer[24], "Pickup \r\n");
break;
case VS_TYPE_SIGNIFICANT_MOTION:
strcpy(&outBuffer[24], "Sig motion\r\n");
break;
default:
strcpy(&outBuffer[24], "Unknown \r\n");
break;
}
fprintf(stderr, "%s", outBuffer);
fflush(stderr);
}
Gravity vector example
Data parsing for gravity vector is available in COINES. The user can open the “bhy_gravity_vector.c” in COINES, compile and run. The output will be shown in COINES console.
Data parsing for Rotation Vector is available in COINES. The user can open the “bhy_rotation_vector.c” in COINES, compile and run. The output will be shown in COINES console.
Customer can create their own case based on the sensor they used in the folder “examples”, for example, BHI160 Shuttle board, we can create a new folder “acc_gyro data output”
Create the file and copy “Makefile” from other bhy example(like gravity_vector)
Modify the Makefile
#CCE_Board_Definitions:BHI160;BHI160B;BHA250;BHA250B
COINES_INSTALL_PATH ?= ../../../..
EXAMPLE_FILE ?= acc_gyro data output.c
SHUTTLE_BOARD ?= BHI160
CFLAGS += -DBST_APPBOARD_VIA_USB -D$(SHUTTLE_BOARD)
include $(COINES_INSTALL_PATH)/examples/c/examples.mk
Now, you can make, compile and run your own code via COINES.