Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Arduino-based electronic leveling device

By Nikhil Agnihotri September 8, 2021

Have you ever struggled to fix nails on a wall perfectly parallel to the floor or ceiling? In this project, we have modeled an electronic-level device useful in placing anything perfectly parallel. This device is prototyped on the popular microcontroller board – the Arduino. It uses very few components to build, only an accelerometer sensor and a LED light. Let us quickly build this device on our favorite Arduino UNO and get everything perfectly aligned.

Components required

  1. Arduino UNO x1
  2. ADXL345 Accelerometer Sensor x1
  3. LED x1
  4. Resistor 330Ω x1
  5. Breadboard or a prototyping board
  6. Connecting wires or jumper wires
  7. L-shape measurement scale

Circuit connections

This device is built by interfacing Arduino with an ADXL345 accelerometer sensor and a LED. The ADXL345 is a digital sensor that talks with Arduino using an I2C interface. For interfacing ADXL345 with Arduino, connect the SDA and SCL pins of the sensor with the SDA and SCL pins of one of the I2C ports on Arduino. The following image shows available I2C ports on Arduino UNO.

The VCC and GND pins of ADXL345 are connected to 5V out and one of the Ground pins of Arduino UNO. A LED is also interfaced with the Arduino at pin 2. The LED’s anode is connected to 5V out of the Arduino UNO, while its cathode is connected to the Arduino’s pin 2. There is a current limiting resistor of 330Ω in series with the LED.

It is recommended to assemble the circuit on a prototyping board and attach an L-measurement scale to the board. The L-measurement scale must be perfectly aligned with the edges of the prototyping board or the device’s overall casing.

Arduino based Levelling Device

Circuit diagram

Arduino Sketch


How it works

ADXL345 is a 3-axis MEMS accelerometer sensor. It is a digital inertial sensor that uses a capacitive accelerometer design. It has a user-selectable range up to +/-16g, a maximum output resolution of 13 bits, a 3.9 mg/LSB sensitivity, and a maximum output data rate of 3200 Hz. ADXL345 measures static acceleration due to gravity as well as dynamic acceleration resulting from motion or shock. It can sense linear acceleration in 3 axes and detect the tilt and free fall of an object. The acceleration value obtained in gravity units can range from +2 g to -2g, or +4g to -4g, or +8g to -8g or +16g to -16g, depending upon the selected measurement range. The value of acceleration includes both static accelerations due to gravity and dynamic acceleration due to motion or shock. The following image shows acceleration values in gravity units due to gravity –

The sensor’s tilt can be detected by the acceleration’s sign and value in the x-, y- and z-axes. When only static acceleration is working on the ADXL345 sensor, the acceleration value along a given axis will be approximately +1g or -1g.

By examining the sign and value of acceleration in all axes, the exact orientation of the ADXL345 sensor in a 3-axis frame can be determined. This project uses the same principle of examining the orientation of the ADXL345 sensor. Whenever the sensor is perfectly aligned to one of the planes, the value of acceleration in one of the axes will be 1, while in the other two axes, it will be 0.

The Arduino is programmed to detect when the ADXL345 is perfectly inclined in one of the three planes. Remember that our circuit is also perfectly inclined with an L-measurement scale.  So, when perfectly inclined in one of the three planes, Arduino lights up the indicator LED. This will indicate that the device and the L-measurement scale are perfectly parallel to either a horizontal or vertical plane. Using the L-measurement scale, points parallel to the horizontal or vertical plane can be marked. This can be used for fixing nails perfectly parallel to the floor or ceiling or to place objects perfectly parallel overground. It can also be used to detect if a wall or floor is inclined or flat.

In the Arduino code, we have considered some tolerance of 5% to 10% in acceleration values, as we only need to determine situations when one of the acceleration values approaches 1 or -1. In contrast, the other two acceleration values approach a value of zero. Whenever these conditions are matched, the LED lights up for 5 seconds, then switched off. This constant lookup for the matching conditions helps in avoiding human error in marking parallel points.

The code

The Arduino sketch configures the ADXL345 sensor to a +/- 2g measurement range and uses a 10-bit resolution. The script reads acceleration data of all axes and converts it to gravity units. The values of acceleration in the x-, y-, and z-axes are 10-bit and right-justified. Accordingly, the values are derived from 16-bit registers. At 10-bit resolution, the value of acceleration in the gravity unit is obtained by multiplying by 4 mg, i.e., multiplying by 0.004. After obtaining the acceleration values for all axes, the matching conditions are looked up, i.e., if one of the acceleration values approaches 1 or -1. In contrast, the other two acceleration values approach the value of zero. If any matching condition is found true, the device and the L-measurement scale are perfectly inclined to the horizontal or vertical plane in space, and parallel points can be marked using the L-scale.

The matching of conditions is indicated by lighting a LED. The LED is connected with Arduino such that it sinks current from the Arduino pin. The LED is lighted for 5 seconds by setting the Arduino pin to LOW. Then, the LED is again turned off by setting the respective Arduino pin HIGH. The accelerometer sensor is configured in the setup() function. The acceleration values in the X, Y, and Z-axis are determined in the loop() function. The matching conditions are also looked up in the loop() function, so Arduino keeps repeating it.

Result

You may also like:


  • Arduino-based token display board controller

  • How to design an Arduino-based RLC metal detector using an…

  • What are the top tools for developing embedded software?

  • Designing an Arduino-based EMG monitor

  • Arduino-based RGB LED strip controller

  • How to design an Arduino-based container shipment tracking system

Filed Under: Arduino Projects, Electronic Projects, Sensors, Tutorials, Video

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • mosfet driver problem in regeneration mode
  • What is the purpose of this relay?
  • Industrial Relay Board Design for Motorcycle Use
  • ADEM III ECM — No CAN Signal & Power Supply Issue
  • Snooping Around is All

RSS Electro-Tech-Online.com Discussions

  • Pic18f25q10 osccon1 settings swordfish basic
  • Sump pit water alarm - Kicad 9
  • Anyone jumped from Easyeda std to Easyeda pro?
  • turbo jet fan - feedback appreciated.
  • More fun with ws2812 this time XC8 and CLC

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • How IoT network topologies work
  • The top five AI startups to watch in 2025
  • STMicroelectronics unveils SoC based on secure MCU
  • Nexperia’s 48 V ESD diodes support higher data rates with ultra-low capacitance design
  • Taoglas releases Patriot antenna with 18 integrated elements covering 600 to 6000 MHz

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe