Here’s what we got for right now. The accelerometer is really basic. I would have loved to include a full IMU, but we didn’t have the cost room. The one we are using is the least expensive one on the market (50 cents), full IMUs start at like 4-5 dollars and up which would have added $10 to the final system cost.
Anyway, it’s really just for tilt sensing, which we will use in the future to allow you to rotate the video as the camera rotates.
# Untitled - By: kwagy - Tue Aug 8 2023
import machine, time
bus = machine.I2C(2)
print(bus.scan())
while(True):
d = bus.readfrom_mem(0x15, 0x03, 7)
x = ((d[0] << 8) | d[1]) >> 4
if x & 0x800: x = x - 4096
y = ((d[2] << 8) | d[3]) >> 4
if y & 0x800: y = y - 4096
z = ((d[4] << 8) | d[5]) >> 4
if z & 0x800: z = z - 4096
t = d[6]
x = x / 1024.0
y = y / 1024.0
z = z / 1024.0
t = (t * 0.586) + 25.0
t = (t * 9.0/5.0) + 32
print("%+0.2fx %+0.2fy %+0.2fz %+0.2ft" % (x, y, z, t))
time.sleep_ms(100)
Besides being an inexpensive IMU, it is the simplest thing imaginable.