[last update: 2021-02-21]
go to: Inclinometer: Problem/Concept page
go to: Accelerometers
go to: OLED page
-----
- This project will use the Adafruit MPU-6050 6-d-of-f accelerometer + gyro (link to: Adafruit PIN: 3886)
At first, I started following (link to:) the Adafruit tutorial for the MPU6050, however that does not calculate/extract the actual (static) level, but only displays the various accelerations, both translation and angular.
- So I instead followed the droneBotWorkshop tutorial that uses direct-reading of the MPU6050 registers.
This tutorial worked for both an Uno and a Nano.
- The project will interface to a 128x32 OLED (Adafruit 4440)
--------------------------------------
- Hardware Connections:
- 6050:
- If you're using a 5v Arduino:
connect MPU6050-Vin to Arduino-5v
- If you're using a 3.3v Arduino:
connect MPU6050-Vin to Arduino-3.3v
- Connect Arduino-gnd to MPU6050-gnd
- Connect Arduino-A5 to MPU6050-SCL (for Uno & Nano)
- Connect Arduino-A4 to MPU6050-SDA (for Uno & Nano)
- The board uses i2c address 0x68
- OLED:
- Arduino 3.3v and gnd to OLED
- ArduinoA5 to OLED-SCL
- ArduinoA4 to OLED-SDA
- Software:
- Setup: Install libraries into IDE:
Adafruit_MPU6050 - installed manually from github download
Adafruit BusIO - installed manually from github download
& Adafruit Unified Sensor - could not find what looked like a valid one on github, so installed with Sketch > Include Library > Library Manager
- Load Test program:
- File > Examples > Adafruit MPU6050 > basic_readings
compiled successfully
- Tools > Serial Monitor and set at 115200 baud
- Successful
- Connect and re-program for OLED:
- General procedure from OLED project page.
- Add OLED code from Adafruit SSD1306 Examples: ssd1306_128x32_i2c.ino
- Final Program Configuration:
In the end I started with the program in dronebot (link below) and customized for this project.
Finished program:
eLevel06.ino.txt
--------------------------------------
- Issues:
- Sometimes OLED will blank out and I need to power-down and back up to restore it. Loose breadboard connection?
- There is some hysteresis/asymmetry in numeric level reading, in that readings don't track when rotating the sensor 180deg.
That is, if I have a 0.0deg reading, I should be able to rotate the sensor 180deg and still have a 0.0deg reading.
But instead there is 1 - 2 deg error.
- The readings take several seconds to stabilize after moving the sensor.
--------------------------------------
- Reference links:
- Here's another project site:
(link to:) dronebotworkshop - demo sketch
This site has two versions of the project. One uses i2CDev and MPU6050 libraries.
These are different libraries than Adafruit uses.
The second version on this site only uses the wire library to "directly manipulate the registers in the 6050."
This is the version I customized for this project.
- Another project site that also appears to do direct register manipulation:
This one bundles an ultrasonic range measurement module as well.
(link to:) howtomechatronics
--------------------------------------
eof