You are currently viewing Digital Spirit Level

Digital Spirit Level

Makers

Syed Hasan Askari Rizvi

Shreya Gupta

Electronic Enthusiast

Vedika Mishra

Techno-savy

AbstractDetecting inclination of the surface or measuring flatness has always been a problem during installation process of any equipment. There are various spirit level devices available in the market for measurement but their accuracy is compromised. In this work, a Digital Spirit Level has been proposed that is more accurate and have many features. Firstly, the user should not have to be necessarily close to the level to read it. The device tells the user not only whether a surface is flat, but also how many degrees it is out of level or inclined. This has been achieved using a gyroscopic sensor MPU6050. Secondly, the gyroscopic sensor is also equipped with inbuilt temperature sensor. This temperature sensor can be used to measure the temperature of the surrounding and that can be visualized in the mobile app as an additional benefit. Henceforth, this device can precisely measure angle of elevation/depression along with temperature of the surrounding. The result will be displayed on the app as well so that the user can take remote readings.
Circuit Diagram

Introduction

As it is widely known, the pace of technological change in electronics and computer-related communications has been extremely rapid in past decades. Previous technically-driven sociological transformations were coupled to prominent developments, such as the printing press, internal combustion engine, or television. The current great metamorphosis has the underlying driving theme of “digital”.

There is a time when you need to mount a piece of furniture or something similar in your home and for a straight mounting everybody usually use a old school spirit level with bubble to tell the gyroscopic angle. We have made this project with just one difference from the usual i.e. its digital. This project also becomes in handy for people  who are building RC Models, since this might be mandatory to acquire angles in different directions to process them further for using in different calculations like stabilizing and leveling, etc. We can operate the device with just a single button .

A Spirit level is a tool used to indicate how parallel (level) or perpendicular (plumb) a surface is relative to the earth . A spirit level gets its name from the mineral spirit solution inside the levels. If you try to figure out what determines the levelness of a surface, you will soon come to realize that it is the 2D orientation that determines the level , i.e. height is irrelevant , since a crooked surface will remain crooked even if you raise it up by 1 or 100m.

In this project we have used MPU6050 as Gyroscopic sensor getting gyroscopic angles with surfaces. For displaying the angles we have used LCD .The microcontroller used is Arduino Nano, in order to keep everything compact on PCB.

 

  1. Circuit Explanation

The circuit diagram (Fig 1.) is very simple and is based on Arduino UNO. The circuit can be divided into two versions one being simple Arduino implementation and other being based on the ATMega 328p Microcontroller IC.

 

2.1 The first version of circuit is as follows.

SDA and SCL of MPU6050 is connected to SDA and SCL pins of Arduino [9] respectively, i.e. SDA is connected to A4 and SCL is connected to A5. The GND and VCC of MPU6050 are connected to power pins respectively.

The SDA and SCL of OLED Display [1], [2] and [6] or I2C based 16X2 LCD [8] is connected to same pins i.e. SDA is connected to A4 and SCL is connected to A5 respectively and power pins to their respective power pins i.e. GND to GND of Arduino and VCC to +5V of Arduino.

The Rx and Tx of Bluetooth are connected to Tx and Rx respectively for proper USART/UART communication. This will enable communication between mobile phone and project.

 

2.2 The second version  ATMega 328p Based circuit

The 16Mhz crystal in parallel with 22 pF Capacitors are connected to XTAL pins of ATMega328p Microcontroller IC and Reset pin is pulled up using 10K resistor connected to +5 V.

The USB to TTL converter IC is connected to Arduino and RX and TX of the same IC is connected to TX and RX respectively for uploading code. There is also one fuse placed between Micro/Mini USB to protect from surge current.

SDA and SCL of MPU6050 is connected to SDA and SCL pins of Arduino respectively, i.e. SDA is connected to A4 and SCL is connected to A5. The GND and VCC of MPU6050 are connected to power pins respectively.

The SDA and SCL of OLED Display or I2C based 16X2 LCD is connected to same pins i.e. SDA is connected to A4 and SCL is connected to A5 respectively and power pins to their respective power pins i.e. GND to GND of Arduino and VCC to +5V of Arduino.

The Rx and Tx of Bluetooth are connected to Tx and Rx respectively for proper USART/UART communication. This will enable communication between mobile phone and project.

In the Block Diagram above (Fig 2.), we can see that  the power is being distributed to both microcontroller/MPU and LCD. The data from the MPU is the raw data which need to be preprocessed in order to use it for project purpose. The data receive is filtered using Kalman’s filter and complimentary filter and then preprocessed. Now the data received is displayed on the Liquid Crystal Display (LCD Display).

  1. Literature Review

 

In Ref[10] , the property of conductivity of liquid has been used for the detection of inclination whereas our device uses simple gyroscopic detection using MPU6050. In Ref[14], Kalman’s Filter Algorithm is used which increases the complexity of the device whereas in our proposed design we used simple Euler’s rule to calculate the inclination. Our device also reflects the measured inclination in the app so that it can be remotely accessed and one doesn’t need to go near to it for the readings. It is cost effective, simple and has more accuracy.

Our design also has temperature sensor inbuilt in the gyroscope which tells the inclination with temperature.

  1. Working
  1. When the device is powered, the device take 3 sec time to calibrate in order to give accurate readings.
  2. After the calibration is done, the device will get the gyroscopic values from the MPU6050 sensor and calculate the inclination in X as well as Y levels.
  3. Once the value in degree is obtained, the same is displayed on display device, i.e. either LCD or OLED.
  4. Not only this, the device also has Bluetooth connectivity and hence it is connected to mobile app.
  5. The X angle is sent to mobile phone continuously and hence the value on mobile app changes continuously.
  6. User can select on app weather he wants Y angles as well and once selected the device will send Y Angle value will be sent.
 
  1. Technology Used : Gyroscopic Sensor

Gyroscope sensor is used for the measurement of angular velocity and the orientation of any object. It is also installed in our mobile phones because of which we are able to track the rotation, tilting and twisting of phones.

For this project we are using MPU 6050 [3], [5], [14] and [15] micro electromechanical system that has a 3-axis gyroscope,3-axis accelerometer, digital motion processor and a temperature sensor. It is a very powerful but complex sensor. It uses I2C communication protocol. The module has 8-pins i.e., VCC,GND,SCL,SDA, XDA,XCL,AD0,INT. VCC provides power to the module(3-5 V).GND is connected to ground of the system. SCL(Serial Clock Line) and SDA( Serial Data Line) are used as a part of I2C serial bus to which SCL provides clock pulse and SDA is used for data transferring. XDA(Auxiliary Data)and XCL( Auxiliary Clock) are optional pins used for connecting the module to external sensors or modules.AD0 is used for varying the address. If low then I2C address is OX68,if high then I2C address is Interrupt pin is used to provide interrupts to microcontroller to read the data.

10.Technical Calculations

MPU6050 6 freedom of axis Gyroscopic sensor is used  which will give Angle in X and Y (Roll and Pitch) but in order to get the user friendly angle  data in degrees, some highly sophisticated calculations before the angle data is been presented on OLED screen or mobile app.

MPU6050 is a SPI based sensor so we can use specific register and in order to receive data we need to setup MPU 6050 in specific mode and extract data and pre-process it. For the initialization of MPU6050 we have to set all bits of register 0x6B and 0x1B to 0 i.e. LOW [12] and [13]. To achieve this we will be using Wire.h library to set all bits of register to LOW.

 Once it is done the MPU6050 is now ready to be used to get the accelerometer as well as gyroscopic values and for the same we have to use register from  0x3B to 0x40 [12] and [13] to get Acceleration data in X,Y and Z axis. First 2 registers (0x3B and 0x3C) will provide Acceleration in X axis, the two registers will give two 8 bit data (0x3B being MSB and 0x3C being LSB) which we have to combine to get a 16 bit signed data. The same is for other axes i.e. middle two registers (0x3D and 0x3E) will give data for acceleration in Y axis and last two registers (0x3F and 0x40) will give acceleration in Z axis. We will again use the same Wire.h library in order to get the register data.

Now for gyroscopic values, we will use register from 0x43 to 0x48 [12] and [13]. The same way first two registers (0x43 and 0x44) will give Gyroscopic value in X axis. Middle two registers (0x45 and 0x46) will give Gyroscopic value in Y axis. Last two registers (0x47 and 0x48) will give Gyroscopic value in Z axis.

Once we have these values, we use the below formula to filter out and stabilize the oscillation and frequently alternating readings so that a better reading is obtained on the OLED Display as well as Mobile phone.

TotalAngleX = 0.98 * (TotalAngleX + GyroDataY – TimeElapsed) + 0.02 * atan (y / (x2+z2)1/2)

TotalAngleY = 0.98 * (TotalAngleY + GyroDataX – TimeElapsed) + 0.02 * atan (x / (y2+z2)1/2)

Leave a Reply