The micro:bit accelerometer is a small chip that senses forces due to gravity and acceleration. It is the NXP/Freescale MMA8652, and it’s located on the bottom of the module, near the lower left corner.
Before talking about how the accelerometer works, remember the capacitor from the cyber:bot visible light sensing activities? Picture the inside of a capacitor as two metal plates separated by an insulator. For example, two plates separated by an insulator have a capacitance—the ability to store charge. If that insulator gets compressed, it brings the two plates closer to each other, and the capacitance increases.
Inside the accelerometer, imagine a tiny object (with mass) held in the middle of a small box. Each wall of the box has capacitors with plates held in place by material that compresses with force. (In the picture, it’s shown as tiny springs.)
When the accelerometer accelerates, the box’s walls have to push on the mass to make it accelerate along with it. As it does so, the tiny springs stretch and compress, changing the distance between the metal plates in each capacitor.
The electronics inside the accelerometer convert that capacitor measurement to a number that reports to the micro:bit when your script executes a statement like x = acceleromter.get_x().
Think about how you speed up when you jump down off of something and land on the ground. That’s the acceleration due to gravity, g. In physics calculations, commonly used values are 32 ft/s² or 9.8 m/s².
The micro:bit won’t typically experience more than 1 g of force from acceleration, unless it’s taking a ride in a high performance model airplane or attached to a wheel that’s spinning really fast. But it does typically experience force equivalent to 1 g of acceleration from gravity’s pull.
These are just concept drawings. The micromachined construction of a proof mass and capacitors inside an actual accelerometer is more elaborate than a simple box with a block inside. It involves a small sliding plate anchored to a flexible material. The plate has capacitive fingers that overlap more or less with metal fingers below it, depending on how much force the plate stretches or compresses the flexible material.
The most common unit accelerometers use is 1 g, which is one unit of gravity. The micro:bit reports gravity/acceleration in steps of 8, from -2048 to + 2048 to report -2 g to 2 g.
If you orient the micro:bit so that the x-axis is pointing down and the y-axis is pointing sideways, the x-axis reports 1024 because it is fully aligned with gravity. The y-axis reports zero because it is not aligned at all.
If you rotate the micro:bit 45° counterclockwise, the measurement of 736 corresponds with the component of the x sensing axis that’s adjacent to gravity.
1024 is the ideal value representing 1 g, but your micro:bit might report more or less than that. Also, since it reports accelerometer measurements in steps of 8, if it reports a value like 1040 for 1 g, don’t worry, that’s really only two increments of 8 off from 1024.