Week 12

Networking and Communication

This week I started working on my final project. My goal is to use an imu to track motion and then create drawings based on the motion. Essentially a pen based on imu motion.

My plan is to use bluetooth to communicate between the pen and the interface which will be a web page. So I focused this week on bluetooth in javascript. I started with Neil's example code for the browser side of the bluetooth communication. I prefer using arduino c++ to micropython, so I wrote my own code for the esp side. I used the ESP32 BLE Arduino library to do this. I started with a notify example and modified it for my purpose. Since the goal is to send location information, I wrote a function to send three comma separated floats. I started testing it using randomly generated floats and then will send the imu data when I have it

I spent the rest of the week working on my imu position detection. I used the absolute orientation to rotate the acceleration into a consistent frame. Since I wanted to use the quaternion representation of the orientation for faster rotation calculations, I couldn't use serial to communication with the imu so I had to switch to I2C. Position tracking itself requires double integrating the acceleration which is known to be very error prone.

To improve consistency in integration, I didn't want the bluetooth program to interrupt the imu reading process, so I used the two cores of the esp32 s3. I created 2 tasks with one on core 0 running the bluetooth communication and the other on core 1 running the imu reading and integration. This helped but not enough.

I'm continuing to iterate on the position problem. I'm filtering out really tiny acceleration because that is probably just noise which has helped. I'm also damping the velocity over time so it doesn't grow too big. I might try adding some averaging or try capping the velocity and position to get better values. Depending on how this goes I might need to pivot a bit for my final project. But for now, this seems to have reasonably accomplished the weekly assignment