Build a Pocket Spirit Level: Measure Angles, Slopes, and Tilt with Gravity

Quick Overview & Specifications

AttributeDetails
PublicationVinjo Engineering & Technology
CategoryHardware & IoT
AuthorVinay
Article TypeTechnical Tutorial & Case Study
Published2026-12-04
Last Updated2026-12-04
License / AccessOpen Educational Resource
Core Engineering Highlights:
  1. Verified hardware architecture, schematics, and pinout diagrams.
  2. Comprehensive firmware routines, protocol benchmarks, and build steps.
  3. Production design rules, tolerances, and thermal considerations.
Related Topic Taxonomy:
  • #ESP32
  • #MPU6050
  • #DIY
  • #Spirit Level
  • #Angle Measurement
  • #3D Printing
  • #Hardware
  • #IoT
  • #Arduino

Build a Pocket Spirit Level That Measures Angles, Slopes and Tilt Using Gravity

Summary: This article provides a comprehensive guide to building a compact, portable digital spirit level. Utilizing an ESP32-C3 Super Mini and an MPU6050 sensor, the device accurately measures angles, slopes, and tilt, displaying real-time data on an OLED screen. Encased in a custom 3D-printed frame and powered by a rechargeable battery, it offers multiple measurement modes and on-the-go utility.

Key Takeaways

  • DIY Digital Level: Construct a sophisticated pocket spirit level using an ESP32-C3 microcontroller and an MPU6050 accelerometer/gyroscope for precise angle, slope, and tilt measurements.
  • Multi-Mode Functionality: The device features an OLED display and a rotary encoder, allowing users to switch between Level, Angle, and Tilt Guide modes, as well as toggle between degrees and percentage measurements.
  • Compact & Portable Design: The project leverages 3D printing for a custom, ergonomic enclosure, making the tool highly portable and suitable for various applications, powered by a long-lasting rechargeable battery.
  • Simplified Circuitry: Learn how to transition from a breadboard prototype to a compact, soldered circuit, optimizing space and reducing wire clutter for a professional finish.

Detailed Overview

This Instructable outlines the process of creating a compact Pocket Spirit Level, an innovative tool that goes beyond traditional bubble levels by providing digital measurements of angles, slopes, and tilt. Powered by an ESP32-C3 Super Mini and an MPU6050 sensor, this DIY project offers real-time data on an OLED display, complete with a rotary encoder for mode selection and calibration. The entire device is housed within a custom 3D-printed frame, making it a handy, portable tool for various measurement tasks.

Essential Supplies

To embark on this project, gather the following components:

  • MPU 6050 Sensor
  • ESP32-C3 Super Mini
  • Rotary Encoder
  • Jumper Cables
  • Spirit Level (for the analog reference)
  • OLED Module
  • Breadboard (for prototyping)
  • TP4056 Charging Board
  • 3.7 V Rechargeable Battery
  • 3D Printer
  • PLA Filament
  • Slicing Software (e.g., Ultimaker Cura)
  • Arduino IDE
  • Hot Glue, Double-sided Tape, Super Glue

All Supplies MPU 6050 ESP32C3 Super Mini Rotary Encoder Jumper Cables Spirit Level OLED Module Breadboard TP4056 Charging Board 3.7V Rechargeable Battery

Circuit and Arduino Program

The initial circuit is assembled on a breadboard for testing. The MPU6050 and OLED module share I2C pins (SDA to ESP32 pin 1, SCL to ESP32 pin 0). All modules' GND and VCC pins connect to the ESP32-C3's ground and 3 V pins, respectively. The rotary encoder's SW pin connects to D6, DT to pin 5, and CLK to pin 4 on the ESP32 board.

After wiring, upload the provided Arduino program to the ESP32-C3. Ensure the correct COM port and board type are selected in the Arduino IDE. Once uploaded, test the circuit by rotating the encoder to switch modes and tilting the sensor to observe display changes.

Circuit Diagram Breadboard Setup

Deep Dive & Technical Insights

The core of this project lies in the ESP32-C3's ability to process data from the MPU6050. The MPU6050 is a 6-axis motion tracking device that combines a 3-axis gyroscope and a 3-axis accelerometer. By reading the accelerometer data, the ESP32 can calculate the device's orientation relative to gravity, thus determining angles, slopes, and tilt. The rotary encoder provides user input for mode selection and calibration, while the OLED display presents the measurements in a clear, digital format.

The Arduino program (level.ino) handles the sensor readings, calculations, display updates, and user interface logic. It's designed for automatic calibration upon startup, ensuring accurate measurements when placed on a flat surface.

3D Designing and Printing

The enclosure for this pocket spirit level is designed using Tinkercad. The primary goal was to create a compact, rectangular frame that securely houses all the electronic components, including the ESP32, MPU6050, OLED, rotary encoder, and a rechargeable battery. A smaller 1200 mAh battery was chosen over an 18650 to optimize space and maintain a compact form factor without sacrificing performance.

The design includes specific slots and mounts for each component, ensuring a snug fit and easy assembly. The main frame, lid, and a holder for the analog spirit level are printed using PLA filament. Standard slicing software like Ultimaker Cura can be used with typical PLA settings.

Tinkercad Design 3D Printed Parts Main Frame Design Lid Design Component Placement Battery Slot OLED Slot Encoder Slot Spirit Level Holder

Simplifying the Circuit

After verifying the breadboard circuit, the next step is to simplify the wiring for a compact fit within the 3D-printed enclosure. This involves reducing redundant wires by branching ground and positive connections. For instance, instead of connecting three separate ground wires to the ESP32, they are consolidated into a single connection.

The rechargeable battery, initially with pre-soldered wires and a connector, is modified by directly soldering its wires to the TP4056 charging board. The charging board's output pins (ground and positive) are then connected to the ESP32, with a switch integrated into the positive line for power control. This streamlined approach eliminates the need for a breadboard and minimizes cable clutter.

Simplified Wiring Diagram Battery Wiring TP4056 Connections Switch Integration Consolidated Ground Wires Compact Wiring Final Simplified Circuit

Casing the Electronics

With the circuit simplified and 3D parts printed, it's time for assembly. Start by gluing the TP4056 charging board to the base of the 3D-printed frame. Next, secure the rechargeable battery to a corner of the frame using double-sided adhesive or hot glue. The ESP32 is then glued into an appropriate spot on the base.

For optimal performance, the MPU6050 sensor is affixed to the side of the 3D-printed frame using double-sided adhesive. Finally, the OLED display and rotary encoder are mounted onto the lid, along with the analog spirit level tube, which fits into a dedicated slot. Once all components are in place and wired, the lid is secured to the base using super glue, completing the device.

Gluing TP4056 Battery Placement ESP32 Secured MPU6050 Mounted

How to Use With Working Video

Using the pocket spirit level is straightforward. Simply turn on the power button. The device will automatically calibrate itself; ensure it's placed on a flat surface during startup for accurate calibration.

Once calibrated, the OLED display will show the spirit level meter. You can use this to check the flatness of any surface. Rotate the rotary encoder to switch between different modes:

  • Level Mode: Displays the levelness of a surface.
  • Angle Measurement Mode: Shows the precise angle of the surface.
  • Tilt Guide Mode: Provides tilt information, also showing angles.

The device is designed for portability, allowing you to carry it in your pocket and take measurements anywhere on the go.

Device in Level Mode Device in Angle Mode Device in Tilt Mode


Conclusion & Resources

This DIY pocket spirit level offers a practical and educational project for makers interested in electronics, 3D printing, and microcontrollers. Its ability to provide precise digital measurements of angles, slopes, and tilt makes it a versatile tool for various applications, from home improvement to engineering tasks. The compact, rechargeable design ensures it's always ready for use.