Build a digital spirit level using a SCA610 accelerometer

A bubble or spirit level meter is a handy tool to find whether a surface is horizontal or vertical. It is often carried by civil engineers, mechanical engineers, surveyors, carpenters, and many other professionals whose work involve precise alignments of horizontal and vertical planes. Original spirit levels had two banana-shaped curved glass vials at each viewing point and were much more complicated to use. Mechanical spirit level meters are still available both in 1D and 2D formats. However at present time their electronic counterparts have also emerged and are even available in modern Android equipped cell phones. It’s from there I got my inspiration to make a very simple digital spirit level. Here’s a demo of such an electronic spirit level made by using a Microchip PIC16F684 micro, a SCA610 accelerometer and a handful of other discrete components.

Build a digital spirit level using a SCA610 accelerometer
Digital spirit level meter

Theory

The heart of this project is the SCA610 accelerometer IC that senses the inclination of a surface. Bases on VTI 3D MEMS technology, SCA610 is a very reliable, accurate and stable one-axis analog accelerometer. It requires a single power supply and provides an analog output voltage proportional to the inclination. According to its datasheet, if the device is powered with a precise +5.0V, the analog output voltages for +1g (vertical), 0g (horizontal), and -1g (vertical in opposite direction) inclinations would be 3.75V, 2.50V, and 1.25V, respectively. Voltages between 1.25V and 3.75V are linearly interpolated and mapped to the inclination angles varying from +90° to -90°. The analog signal can be processed by a microcontroller through an ADC channel to retrieve the inclination information.

Circuit diagram

The microcontroller used in this project is PIC16F684 which has just enough I/O pins and a built-in 10-bit A/D converter required for this project. The microcontroller runs at 8.0 MHz using the internal oscillator. The SCA610 sensor output goes to AN0 ADC channel of PIC16F684. The microcontroller takes quick multiple ADC samples which are averaged for a better estimation of inclination angle. There are five LEDs connected to RC0 through RC4 port pins and they are arranged in a row. Based on the direction of inclination the LEDs run in either forward or in reverse direction. There is a buzzer connected to RC5 pin which beeps continuously until the entire board settles at 0g or horizontal position. The buzzer used in the circuit is a ON/OFF type. What that means is it turns on when the RC5 pin goes high. If the device is aligned perfectly horizontal then only a central blue LED flashes and the buzzer mutes.

Schematic Build a digital spirit level using a SCA610 accelerometer
Circuit diagram of a simple LED spirit level meter (Click image to enlarge)

Software

The firmware for this project has been written in C using mikroElektronika’s mikroC Pro for PIC compiler. Note that the buzzer used in this project is a high impedance ON/OFF type and the software just turns the RC5 pin high in order to make the buzzer on. So this firmware won’t drive a buzzer that requires an ac signal. You can download the source code and compiled HEX output of the firmware from the following link.

For more detail: Build a digital spirit level using a SCA610 accelerometer

About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation, and engineering. I have a clear and simple writing style and am skilled in using infographics and diagrams. I am a great researcher and is able to present information in a well-organized and logical manner.