TroubleshootingArduino

bmx160+bmp388

userHead Giacomo.Eandi 2024-06-06 17:12:41 75 Views1 Replies

Hi everyone,

 

I'm new to DFRobot products and I'm trying to learn something about IMU sensors.

I've bought a BMX160+BMP388 sensor ( this one https://wiki.dfrobot.com/Gravity%3A%20BMX160%2BBMP388%2010%20DOF%20Sensor%20SKU%3A%20SEN0252) and I'm dealing with the communication between the sensor and an Arduino Due board.

When I try to compile the example code as reported in the guide within the link above I always get this message:

 

Compilation error: 'bmx160SensorData' was not declared in this scope

 

 

I know I'm missing something very trivial but I can't figure out what it is.

Can anyone help me?

 

Thanks in advance

2024-06-06 23:58:38

Here is an example code:

#include <Wire.h>
#include <DFRobot_BMX160.h>
#include <DFRobot_BMP388.h>

DFRobot_BMX160 bmx160;
DFRobot_BMP388 bmp388;

DFRobot_BMX160::sBmx160SensorData_t bmx160SensorData;

void setup() {
 Serial.begin(115200);
 while (!Serial);

 if (bmx160.begin() != 0) {
   Serial.println("Failed to initialize BMX160!");
   while (1);
 }

 if (bmp388.begin() != 0) {
   Serial.println("Failed to initialize BMP388!");
   while (1);
 }

 Serial.println("Sensors initialized successfully.");
}

void loop() {
 bmx160.getAllData(&bmx160SensorData);
 Serial.print("Accel X: "); Serial.println(bmx160SensorData.accel.x);
 Serial.print("Accel Y: "); Serial.println(bmx160SensorData.accel.y);
 Serial.print("Accel Z: "); Serial.println(bmx160SensorData.accel.z);

 // Add more code to read and print data from bmp388

 delay(1000);
}
 

userHeadPic lia.ifat