I’m more than happy with how an “analogue” spirit level works. A cylinder with a slight upward curve in the middle (or a larger diameter in the middle) is incompletely filled with a spirit. This leaves a bubble which travels to the centre of the cylinder when on a flat surface. When on a slight level the bubble travels to not be in the centre. Additional lines can be drawn on the tube to represent inclinations of 45 degrees etc.

Analogue spirit level
So how can a digital spirit level possibly know whether it’s on an inclination or not!? Answer: witchcraft*.
No one at work could give me a satisfactory answer but fortunately my friend the internet gave a guide on how to build my own electronic spirit level ( http://embedded-lab.com/blog/build-a-digital-spirit-level-using-a-sca610-accelerometer/). For this build you will need: an accelerometer, a microcontroller (like a microprocesser but with RAM, ROM etc) and some other electronic things and also some knowledge of programming and electronics.
But the most important component is the accelerometer!
*or science. Sometimes the same thing in all honesty.
Accelerometers
There are lots of ways to make an accelerometer. In essence you need an accelerative force to create a change in your device that you can measure. One way of doing this is using the piezoelectric effect to create a voltage within a crystal that can then be measured. Another is to have a micro capacitor with a fixed plate and one that can move. As the accelerative force moves the moveable one, the capacitance between them changes which can be measured and converted to voltage.
A digital spirit level uses an accelerometer that can sense accelerations of -g to g. At -g, the spirit level reads -90 degrees and at g, reads 90 degrees. Between these two values the angles are interpolated from the voltage et voila, a digital spirit level!
A/N: Learning about how all this worked is my favourite kind of science. Simple concepts that when put together create something that was beyond your comprehension before you started reading about it! P.S. This is related to medical physics due to how we use spirit levels in testing radiotherapy treatment units and the recommendations of IPEM 81.
Great post π
LikeLiked by 1 person