Thank you for the reply @BSTRobin, We are working on attached Orientation.ino code got from https://github.com/BoschSensortec/BoschSensorHub/tree/master/examples/orientation We are able to read Dev ID and Sensor Configuration But it is getting struck In the void loop. where newOrientation data condition was not true. Please see the attached code and help me. void setup()
{
disableCore0WDT();
disableLoopWDT();
Serial.begin(115200);
Wire.begin();
if (Serial)
{
Serial.println("Serial working");
}
attachInterrupt(BHY_INT_PIN, bhyInterruptHandler, RISING);//RISING
bhi160.begin(BHY_I2C_ADDR);//BHY_I2C_ADDR2-->if SA_GPIO7(high)
/* Check to see if something went wrong. */
if (!checkSensorStatus())
return;
Serial.println("Sensor found over I2C! Product ID: 0x" + String(bhi160.productId, HEX));
Serial.println("Uploading Firmware.");
bhi160.loadFirmware(bhy1_fw);
if (!checkSensorStatus())
return;
intrToggled = false; /* Clear interrupt status received during firmware upload */
waitForBhyInterrupt(); /* Wait for meta events from boot up */
// Serial.println("Firmware booted");
/* Install a metaevent callback handler and a timestamp callback handler here if required before the first run */
bhi160.run(); /* The first run processes all boot events */
/* Install a vector callback function to process the data received from the wake up Orientation sensor */
if (bhi160.installSensorCallback(BHY_VS_ORIENTATION, true, orientationHandler))
{
checkSensorStatus();
return;
}
else
Serial.println("Orientation callback installed");
/* Enable the Orientation virtual sensor that gives you the heading, roll, pitch
based of data from the accelerometer, gyroscope and magnetometer.
The sensor is set into wake up mode so as to interrupt the host when a new sample is available
Additionally, the FIFO buffer of the sensor is flushed for all previous data
The maximum report latency of the sensor sample, the sensitivity and the dynamic range
are set to 0
*/
if (bhi160.configVirtualSensor(BHY_VS_ORIENTATION, true, BHY_FLUSH_ALL, 200, 0, 0, 0))
{
Serial.println("Failed to enable virtual sensor (" + bhi160.getSensorName(
BHY_VS_ORIENTATION) + "). Loaded firmware may not support requested sensor id.");
}
else
Serial.println(bhi160.getSensorName(BHY_VS_ORIENTATION) + " virtual sensor enabled");
status = bhi160.getSensorInformation(BHY_VS_ORIENTATION, true, &informations);
if (bhi160.status == BHY_OK)
{
gu8InformBuf[0] = (uint16_t)informations.driver_id;
gu8InformBuf[1] = (uint16_t)informations.max_range;
gu8InformBuf[2] = (uint16_t)informations.resolution;
gu8InformBuf[3] = (uint16_t)informations.max_rate;
Serial.println("Sensor Information:"); Serial.println(gu8InformBuf[0], HEX);
Serial.println(gu8InformBuf[1], HEX); Serial.println(gu8InformBuf[2], HEX); Serial.println(gu8InformBuf[3], HEX);
Serial.println("Sensor Information:"); Serial.print("Sample Rate:"); Serial.println(gu8InformBuf[0]);
Serial.print("Max Range:");Serial.println(gu8InformBuf[1]); Serial.print("Resolution:");Serial.println(gu8InformBuf[2]);
Serial.print("Max_Rate:");Serial.println(gu8InformBuf[3]);
}
status = bhi160.getConfiguration(BHY_VS_ORIENTATION, true, &configurations);
if (bhi160.status == BHY_OK)
{
gu8ConfigBuf[0] = (uint16_t)configurations.sampleRate;
gu8ConfigBuf[1] = (uint16_t)configurations.maxReportLatency;
gu8ConfigBuf[2] = (uint16_t)configurations.changeSensitivity;
gu8ConfigBuf[3] = (uint16_t)configurations.dynamicRange;
Serial.println("Sensor Configuration:"); Serial.println(gu8ConfigBuf[0], HEX);
Serial.println(gu8ConfigBuf[1], HEX); Serial.println(gu8ConfigBuf[2], HEX); Serial.println(gu8ConfigBuf[3], HEX);
Serial.println("Sensor Configuration:"); Serial.print("Sample Rate:"); Serial.println(gu8ConfigBuf[0]);
Serial.print("Max Report Latency:");Serial.println(gu8ConfigBuf[1]); Serial.print("Sensitivity:");Serial.println(gu8ConfigBuf[2]);
Serial.print("Dynamic Range:"); Serial.println(gu8ConfigBuf[3]);
}
}
void loop()
{
if (intrToggled)
{
intrToggled = false;
bhi160.run();
checkSensorStatus();
if (newOrientationData)
{
/* Can also be viewed using the plotter */
Serial.println(String(roll) + "," + String(pitch) + "," + String(heading));// + "," + String(status)
newOrientationData = false;
}
}
}
void orientationHandler(bhyVector data, bhyVirtualSensor type) //<--
{
roll = data.z;
pitch = data.y;
heading = data.x;
status = data.status;
newOrientationData = true;
} Thank you
... View more