Goal: Visualize IMU data on an OLED screen attached to microcontroller Software:Mods (computes machine routes), Arduino IDE Hardware: Microcontroller (SEEED XIAO ESP32-S3), IMU (Adafruit BNO-08x Breakout), OLED (Weewooday 12864) Prior Experience: None with onboard displays--connected to IMU last week New Methods:
Dual I2C connections,
scrolling IMU data on OLED screen
Details:
For details connecting the microcontroller to the IMU with the custom-milled PCB, see last week
This document focuses on connecting the microcontroller to the OLED screen in tandem with the IMU
This OLED module also communicates via I2C, just like the IMU
Multiple devices can use the same I2C line simultaneously--the microcontoller distinguishes between them by their unique address
And conveniently, OLED's I2C pins are in the same order as the IMU's pins
So, if we take the existing custom PCB and split its I2C header into 2x identical I2C headers...
We should be able to connect to and communicate with both!
To do this, I designed and milled this custom I2C splitter
Similar to last week, I just edited the existing board's .png file to produce this new board
In general, I would not recommend doing this, but it served as a quick-and-dirty solution for this week
For more details on PCB design and milling, see previous weeks
Note that this PCB requires through-holes for pins that will plug in to the main PCB's female I2C headers
Instead of using the milling machine to make these holes, I just used a hand drill with a small bit
Once pins and headers are soldered to the freshly-milled splitter, it's time to assemble!
A promising start! The ESP32-S3 was pre-loaded with the "ssd1306_128x64_i2c" example from Adafruit's "SSD1306" library for OLED's
For more information on how to use the Arduino IDE to do this, see introductory tutorials online--ChatGPT is your friend
Now that all modules are connected, time to see if the microcontroller can simultaneously...
Read IMU data
Display IMU data on OLED screen
Let's start by seeing if we can control the position of a dot on the screen
Success! Using an internal algorithm, the IMU is able to calculate its orientation relative to gravity
In this example, we are use that information to update the position of a dot on the OLED screen
When the device is flat, the dot is centered--as the device tilts, the dot moves in the direction of the tilt
We can improve this visual effect, by storing a recent history of tilt values, and drawing circles of decreasing diameter
Success! The dot now leaves a trail of decreasing circles as the device tilts
We can use the same strategy of storing recent values to create a scrolling display that plots acceleration values over time