Mounted next to the controller, in line with the centre of the board is an MPU6050 6-axis sensor on a GY-521 breakout board. It is connected to the microcontroller via I2C, powered with 5v and can data connect to board with either 3.3v or 5v
- A4 I2C - SDA
- A5 I2C - SCL
- D2 4 I2C - SDA
- D1 5 I2C - SCL
Wemos D1 Mini (ESP-8266):
- D1 5 GPIO5 IO I2C - SCL
- D2 4 GPIO4 IO I2C - SDA
- MPU6050: X=Right/Left, Y=Forward/Backward, Z=Up/Down
- orientation (byte): 0=flat, 1=upside-down, 2=up, 3=down, 4=left-side, 5=right-side
- direction (byte): -1=stationary, 0=forward, 1=back, 2=up, 3=down, 4=left, 5=right
The software has several calibration routines to help work out where it is in space and time.
- A full calibration is run when the board can be placed on a level, solid surface for quite some time, preferably leaving the room please, haha funny, your jumping is not helping.
- Short calibrations are run at startup when the board is placed on the ground. Current and saved data is compared to make slight adjustments to centre the orientation.
- Short calibrations can also be run by request, at intervals, or whenever needed by the program to self-correct.
Orientation sensor data is used to switch light modes, change the speed of the animation, activate an emergency beacon, indicate when the board leans round a corner and mix with the wheel sensors to produce LED effects.
TODO: Fix upside-down register. Seems to have a blind spot/gimbal lockout point?
TODO: Proper calibration system with menu.
Software uses a custom library for ease of access.
- BoardOrientation - attempt to move all board mpu6050 sensor related items to a single library
- 20 milliseconds read interval
- 100 milliseconds main orientation read interval