A demo showing the pose of the bmi160 6DoF IMU sensor in 3D using esp-idf.
You can use the Kalman filter or the Madgwick filter to estimate the Euler angle.
Euler angles are roll, pitch and yaw.
It's very intuitive and easy to understand.
However, since BMI160 is a 6DoF IMU, YAW estimation is not possible.
I used this library.
ESP-IDF V4.4/V5.x.
ESP-IDF V5.0 is required when using ESP32-C2.
ESP-IDF V5.1 is required when using ESP32-C6.
BMI160 Accelerometer Gyroscope module 6 Dof inertial Measurement Sensors.
BMI160 | ESP32 | ESP32-S2/S3 | ESP32-C2/C3/C6 | ||
---|---|---|---|---|---|
VIN | -- | N/C | N/C | N/C | |
3V3 | -- | 3.3V | 3.3V | 3.3V | |
GND | -- | GND | GND | GND | |
SCL | -- | GPIO22 | GPIO12 | GPIO5 | (*1) |
SDA | -- | GPIO21 | GPIO11 | GPIO4 | (*1) |
CS | -- | 3.3V | 3.3V | 3.3V | Use i2c |
SAO | -- | GND/3.3V | GND/3.3V | GND/3.3V | (*2) |
(*1)You can change it to any pin using menuconfig.
(*2)Choosing an i2c address.
GND:i2c address is 0x68.
3.3V:i2c address is 0x69.
I used this.
git clone https://github.com/nopnop2002/esp-idf-bmi160
cd esp-idf-bmi160/Kalman
idf.py set-target {esp32/esp32s2/esp32s3/esp32c2/esp32c3/esp32c6}
idf.py menuconfig
idf.py flash
I used this.
git clone https://github.com/nopnop2002/esp-idf-bmi160
cd esp-idf-bmi160/Madgwick
idf.py set-target {esp32/esp32s2/esp32s3/esp32c2/esp32c3/esp32c6}
idf.py menuconfig
idf.py flash
ESP32 acts as a web server.
I used this component.
This component can communicate directly with the browser.
It's a great job.
Enter the following in the address bar of your web browser.
http::https://{IP of ESP32}/
or
https://esp32.local/
WEB pages are stored in the html folder.
I used this for gauge display.
I used this for 3D display.
You can change the design and color according to your preference.
You can view Euler angles using this tool.
It works as a UDP display server.
This is a great application.
+-------------+ +-------------+ +-------------+
| IMU | i2c | ESP32 | UDP | pyteapot.py |
| |---->| |---->| |
| | | | | |
+-------------+ +-------------+ +-------------+
$ sudo apt install python3-pip python3-setuptools
$ python3 -m pip install -U pip
$ python3 -m pip install pygame
$ python3 -m pip install PyOpenGL PyOpenGL_accelerate
$ git clone https://github.com/thecountoftuscany/PyTeapot-Quaternion-Euler-cube-rotation
$ cd PyTeapot-Quaternion-Euler-cube-rotation
$ python3 pyteapot.py