Introduction: DIGITAL MULTI-FUNCTION MEASURING TOOL

About: student at SRM university , Btech mechatronics Loves finding out how things work and trying it myself . Loves anything that's a combination of electronics and mechanical .

Hi everyone. I had always wanted a device that would help me in leveling my 3D printer bed and some other device that would help me get an approximate length of a curved surface so that I could easily cut out the right length of sticker to apply on that surface and thus preventing wastage. So I thought why not combine both ideas and make a single gadget that can do both. At last, I ended up building a device that can not only measure curved lines and surface levelness but can also measure straight line distances and angle of a line. So basically this gadget works as an all in one digital level+ruler+protractor+roll-measure. The device is tiny enough to fit inside a pocket and its batteries can be easily recharged using a phone charger.

This device uses an accelerometer and gyroscope sensor to accurately measure surface levelness and angle, a sharp IR sensor to measure the linear length in a non-contact way and an encoder with a wheel which can be rolled over a curved surface or a curved line to get its length.

Navigation through the device modes and features is done using 3 touch buttons marked as M (mode), U (unit) and 0 (zero)

M - To choose between different types of measurements

U - To choose between the units mm, cm, inches, and meter

0 - To reset the measured values to 0 after measuring a distance or angle.

The reason for using touch buttons is to gently navigate through the modes and units without disturbing the position of the device while measuring.

The device has a neodymium magnet embedded into its base so that it won't slip or slide off the metal surface being measured.

The casing is designed to make the device as compact as possible and also to be 3D printed easily.

Step 1: COMPONENTS AND MODULES REQUIRED

The components were chosen keeping in mind that this device is built to fit inside a pocket. So the smallest of the display, battery, and sensors which I could find were used.

1. 3d printed case

2. Sharp GP2Y0A41SK0F IR distance sensor X 1 (Aliexpress)

3. MPU6050 accelerometer/gyroscope module X 1 (Aliexpress)

4. Boost+charging module X 1 (Aliexpress)

5. Grove Mouse encoder X 1 (Aliexpress)

6. 128 X 32 OLED display X 1 (Aliexpress)

7. Arduino pro mini ATMEGA328 5V / 16MHz X 1 (Aliexpress)

8. 12 mm buzzer X 1 (Aliexpress)

9. 3.7v, 1000mah lipo battery X 1 (Aliexpress)

10. TTP223 touch button module X 3 (Aliexpress)

11. 20x10x2mm neodymium magnet X 1 (Aliexpress)

12. CP2102 USB to UART TTL module X 1 (Aliexpress)

13. Enamelled copper wire (Aliexpress)

14. 10K resistors X 2

15. 19(length)X2(dia) mm steel axle X 1

16. 3mm led X 1

17. Any vinyl sticker roll (Aliexpress)

18. Micro USB cable

MPU6050

MPU6050 is a mems device which consists of a 3 axis accelerometer and a 3 axis gyroscope in it. This helps us to measure acceleration, velocity, orientation, and displacement. This is an I2C based device that runs on 3.3 to 5v.In this project, MPU6050 is used to measure if a surface is level or not and also to measure the angle of a line.

GROVE MOUSE ENCODER

This is a mechanical incremental rotary encoder with feedback data of rotary direction and rotary speed. I used this encoder because its the smallest encoder I could find and the programming part of it was also easy. This encoder has 24 steps per rotation. Using this we can calculate the distance moved by the wheel on the encoder if the wheel diameter is known. Calculations on how to do this are discussed in the later steps of this instructable. This project uses the encoder to measure curved lines distances.

SHARP GP2Y0A41SK0F IR DISTANCE MODULE

This is an analog sensor which gives a variable voltage as output based on the distance of the object from the sensor. Unlike other IR modules, the color of the object being detected will not affect the output of the sensor. There are many versions of sharp sensors but the one we are using has a range of 4 - 30 cm. The sensor operates a voltage between 4.5 to 5.5 volts and draws just 12 mA of current. The red(+) and black(-) wires are the power wires and the 3rd wire (either white or yellow) is the analog output wire. The sensor is used in this project to measure linear distances without contact.

Step 2: TOOLS REQUIRED

1. A pair of scissors

2. Box cutters or any other super sharp blades

3. tweezers

4. Hot glue gun

5. Instant glue (like super glue)

6. Rubber based adhesive (like a fevi bond)

7. Soldering iron and lead

8. laser cutter

9. 3D printer

10. A rotary tool with disc cutting bit

11. Wire cutters

12. Sandpaper

Step 3: STL Files to 3D Print

The case for this device was designed in Autodesk Fusion 360 software. There are 3 pieces . The STL files for these pieces are given below.

The "LID" and "wheel" files can be printed without supports whereas the "BODY" file needs support. I printed these at 0.2 mm layer height at 100% infill using green PLA. The printer used is a TEVO tarantula.

Step 4: COVERING THE CASING WITH VINYL

1. Use fine sandpaper to smoothen out all the outer surfaces of the 3D printed pieces so that the vinyl sticker sticks easily.

2. Use a wet cloth to get rid of all the fine particles which might remain on the surfaces after sanding.

3. After the surface dries, apply the vinyl sticker on the surface. Make sure there are no trapped air bubbles.

4. Use scissors to trim off the excess sticker around the edges.

5. Now apply sticker around the sides of the casing and trim the excess.

6. Use a boxcutter or any other razors to cut out the holes for the OLED display, charging port, the encoder wheel, and the sharp IR sensor.

WARNING: BE VERY CAREFUL WITH SHARP BLADES AND TOOLS

Step 5: CIRCUIT DIAGRAMS

PROGRAMMING A PRO MINI

Unlike Arduino nano, pro mini cannot be programmed directly by plugging in a USB cable as it doesn't have a built-in USB to serial TTL converter. Therefore first we should connect an external USB to serial converter to the pro mini in order to program it. The first image shows how these connections are to be made.

Vcc - 5V

GND - GND

RXI - TXD

TXD - RXI

DTR - DTR



COMPLETE CIRCUIT DIAGRAM

The 2nd image shows the complete circuit diagram of this project.

D2 - INT MPU6050

D3 - I/O (MODE)

D5 - I/O (UNIT)

D6 - I/O (ZERO)

D7 - +(1) ENCODER

D8 - +(2) ENCODER

A0 - I/O SHARP IR

A1 - + Buzzer

A4 - SDA (OLED AND MPU6050)

A5 - SCL (OLED AND MPU6050)

GND - GND OF ALL MODULES AND SENSORS AND BOOST MODULE

VCC - + OF BOOST MODULE USB PORT

B+ - BATTERY +

B- - BATTERY -


The 3rd picture was taken while I was creating the code. This is a temporary setup which was made for testing the code, modules, and the circuit. It's optional for you guys to try.

Step 6: INSERTING THE MAGNET

1. Apply instant glue in the cavity for the magnet provided beneath the charging port hole.

2. Place the magnet in the cavity and hold it down until the glue dries using something non-magnetic.

The magnet helps in preventing the device from sliding off or moving when used on a metal surface.

Step 7: SHAPING THE SENSORS

In order to make the device as small as possible, the mounting brackets of the sharp IR sensor and the encoder were cut off using a rotary tool with cutting disc bit attachment.

Step 8: PLACING THE OLED DISPLAY

1. Mark the pin names on the back side of the OLED display so that connections can be made correctly later.

2. Place the OLED display in the correct position as shown in the second picture. The opening for the display is designed such that the display will slightly go into the walls. This ensures that the display is in the correct position and orientation and doesn't move easily.

3. Hot glue is applied carefully around the display. Hot glue is preferred because it kind of act like a shock absorber for the display and won't put stress on the display when applied.

Step 9: ATTACHING THE TOUCH BUTTONS AND MPU6050

1. A rubber based adhesive is used.

2. The adhesive is applied to both surfaces.

3. Making sure all the soldering points are facing the open side of the case, place the modules in their assigned places as shown in the pictures.

4. Keep the module and casing gently pressed together for at least 2 min after adhering them together.

Step 10: BOOST+CHARGING MODULE

This is a module which I took out of a cheap single cell power bank. This module has both battery protection circuitry as well as a 5v, 1 amp boost converter. It also has an ON/OFF push button that can be used as the power switch for the entire project. The female USB port on the module was removed using a soldering iron and two wires were soldered to the +5v and ground terminals as shown in the 4th picture.

Solder 2 male header pins to B+ and B- as shown in the first two pictures and then check if the module works with the batteries.

Apply instant glue on the platform provided for the module and place the module gently making sure the charging port and the opening provide for it is aligned perfectly.

Step 11: PLACING THE BATTERY AND SHARP IR SENSOR

1. The coating of the Enamelled copper wire is removed by heating the wire's tip using the soldering iron or a lighter until the insulation melts off. The wires are then carefully soldered to the OLED display. This is done now because it might be difficult to do the same after the batteries are placed.

2. The battery is slid under the boost module's platform such a way that its wire connectors are facing the direction of the OLED display as seen in the 3rd picture.

3. The sharp IR sensor is inserted into the slot provided for it.

Step 12: ATTACHING THE ARDUINO AND BUZZER

1. The USB to serial converter is soldered to the Arduino according to the provided circuit diagram.

2. Hot glue is used to stick the Arduino to the middle of the casing over the batteries.

3. Wires are soldered to the buzzer terminals and then the buzzer is pushed into the circular cavity on the casing provided for it as seen in the 7th picture.

Step 13: ENCODER

1. The terminals of the encoder are cleaned using a blade.

2. The resistors are soldered to the encoder.

3. The copper wires are soldered according to the circuit diagram.

4. The steel axle is inserted into the 3D printed wheel. If the wheel is too loose, secure it using instant glue.

5. Insert the axle-wheel setup into the encoder. Again if it's loose use instant glue. But this time, be very careful not to let any glue enter the encoder mechanisms.

6. Position the encoder inside the casing such that the wheels protrude out through the provided opening and also make sure it turns freely.

7. Use hot glue to secure the encoder in place.

Step 14: WIRING AND SOLDERING

1. The circuit wiring is done according to the circuit diagram given in the "CIRCUIT DIAGRAM" step previously.

2. The +ve and -ve wires of all the sensors and modules are connected parallelly to the power source.

3. Make sure none of the wires blocks the view of the IR module or entangles with the encoder wheel.

Step 15: CODING

1. Download code and libraries provided below.

2. Extract the library folders. Copy these folders into the "libraries" folder in the "Arduino" folder which is found inside "My Documents" of your computer(if you are a windows user).

3. Open the provided code ("filal_code") in Arduino IDE and upload it to the Arduino.

Step 16: CALIBRATION OF MPU6050

Since the MPU6050 accelerometer/gyroscope module was just glued to the casing, it might not be perfectly level. Therefore the following steps are followed to correct this zero error.

STEP 1: Plug in the device to your computer and place it on a surface which you already know is perfectly level (example: a tile floor)

STEP 2: Go to "LEVEL" mode on the device by touching the "M" button and note down the X and Y values.

STEP 3: Assign these values to the variables "calibx" and "caliby" in the code.

STEP 4: Upload the program again.

Step 17: CALCULATION OF DISTANCE MOVED PER STEP OF THE ENCODER

Number of steps per rotation of the encoder shaft, N = 24 steps

The diameter of the wheel, D = 12.7mm

Circumference of the wheel, C = 2*pi*(D/2) = 2*3.14*6.35 = 39.898 mm

Therefore, distance moved per step = C/N = 39.898/24 = 1.6625 mm

If you guys are using a different diameter wheel or encoder with a different step count, find the distance moved per mm by substituting your values in the above formula and once you find the resolution, enter this value in the formula within the code as shown in the picture.

Compile and upload the code to the Arduino again.

Once the calibration of the encoder is done and the modified program is uploaded, you can desolder and remove the USB to serial TTL converter module from the Arduino Pro Mini.

Step 18: TESTING EVERYTHING BEFORE CLOSING THE CASE

Things to test :

1. If the charger can be easily plugged into the port and if the batteries are charging properly.

2. The power ON/OFF button is working or not.

3. The OLED displays everything in the correct orientation and position with the right spacing.

4. The touch buttons are all properly working and correctly labeled.

5. If the encoder gives the distance values when turned.

6. The MPU6050 and SHARP IR modules are working and giving the correct readings.

7. The buzzer is sounding.

8. Make sure nothing inside is heating up when turned ON. If heating occurs, it means the wiring is wrong somewhere.

9. Make sure everything is secured in position and does not move around in the casing.

Step 19: PLACING THE PUSH BUTTON EXTENDER AND BONDING THE CASE

USING AN LED TO EXTEND THE PUSH BUTTON SHAFT

The shaft of the push button on the charging module is too short to come out through the opening on the casing. So a 3mm LED head is used as an extender.

1. The legs of the LEDs are cut off using a wire cutter.

2. The flat side of the LED is made smooth and level using sandpaper. If the LED is too small to handle by hand, use tweezers.

3. Place the LED head in the hole provided for it on the case lid as shown in the picture. Make sure the led is not tight as it is supposed to slide in and out when the pushbutton is pressed

BONDING THE CASE

1. Apply any rubber based adhesives (I used Fevi Bond) carefully along the rim on both the body and the cap.

2. Wait for 5 to 10 minutes for the glue to dry slightly and then press both the halves together. Make sure the free end of the steel axle of the encoder wheel goes into the hole provided for it on the cap.

3. Use a heavy load (I used a UPS battery) to keep both the pieces pressed while the glue dries.

A Rubber based adhesive was recommended here because in case the casing has to be opened in the future for battery replacement or reprogramming, It can be easily done by running a sharp blade or knife along the joint.

Step 20: LABELING THE TOUCH BUTTONS

The labeling is done in order to easily identify the touch button positions and functions.

The alphabets were cut out from a white sticker sheet using my homemade laser cutter.

The cut pieces were removed from the main sheet using tweezers and then applied on the device in the correct position and orientation.

Max Alphabet height : 8mm

Max Alphabet width : 10MM

WARNING: WEAR LASER BLOCKING SAFETY GLASSES WHEN WORKING WITH A LASER ENGRAVER OR CUTTER

Step 21: RESULTS

The device is finally done. If you guys have any doubts or suggestions regarding the project please do let me know through the comments.

THANKYOU

Pocket Sized Contest

First Prize in the
Pocket Sized Contest