Introduction: Digital Multi-Tool
Hi everyone. If you're like me you, probably have a bunch of spare sensors lying around either from incomplete projects, or that you bought on a whim for some reason or another. I was inspired by Patrick Panikulam's DIGITAL MULTI-FUNCTION MEASURING TOOL to take some of my spare sensors and combine them into a digital multi-tool. It's like a Swiss Army Knife, but for sensing. I mainly focused on incorporating sensors that I thought were useful in a workshop setting (length, angle, temperature, etc), although I did include an extra I2C port, and a few spare digital pins if you want to add a sensor of your own.
Here are a list of the multi-tool's features / modes:
- Bubble style digital level with exact angle output
- Bullseye style digital level with exact angle output
- Digital protractor (like a drawing compass) with exact angle output
- Laser range-finder with max range of 3.5 meters
- Detachable measure marker for the Laser range-finder
- Rolling wheel style ruler
- Contact tachometer
- Non-Contact IR tachometer
- Non-Contact IR thermometer (Wide angle, not great for point sources)
- Laser Pointer
- Powered by rechargeable LiPo battery
- Solar panel for passive recharging
- Magnets for mounting / securing the multi-tool
All combined into a 3D-printed, pocket-sized case, 4.4 "x 1.6" x 1.8" (11.2mm x 40.3mm x 46.8mm).
I wanted to make the tool as easy to assemble as possible, so I focused on using sensors and components that were widely available (with any luck you might already have some of them :) ) and also created a custom PCB to connect everything. Almost all of the electronic parts are through-hole mounted, making soldering easy. The only exception to this are resistors, where I had to use SMD 0805 packages. These can still be soldered pretty easily by hand, but I would not recommend this project to someone who has never soldered before.
Also the multi-tool modular, meaning that if you don't need a feature or sensor, you can simply leave it off the PCB and change a single line of code to remove it.
I've tried to make this Instructable as beginner friendly as possible. If you've ever uploaded code to an Arduino you should be good to go, and if not, I hope my instructions will be clear enough. If you have any questions, please leave a comment and I will try my best to answer.
Please note that due to some of the sensors sensitivity to infrared light, and the display's lack of back-light, the multi-tool is intended to be used in a shaded environment, not in direct sunlight.
Attachments
Supplies
Below I list the electronics, supplies, and tools needed to make the multi-tool. For the electronics, I provide a link to where you can purchase each part, however, many of the components are fairly common and can probably be found for less at places like Ebay, Aliexpress, etc (I try to provide Amazon / Digikey links so that you can buy as much in one place as possible). The only exception to this is the VL53L1X Time-of-Flight (TOF) distance sensor, which you must buy from Pololu; other versions of the board have the SCL and SDA lines reversed and the sensor IC in a different location.
You can find the code, PCB, and 3D print files at my Github: here
Electronics:
- Wemos D1 Mini V3.1.0 Link (must be V3.1.0, earlier versions have onboard LED in wrong place)
- 0.93" SSD1306 I2C OLED Display Link (there are a few versions of this with different hole placement, all of them should work. Yellow/blue color split not required)
- A micro USB cable that supports data transfer (for programming)
- 5mm Mouse Encoder Link
- VL53L1X Time-of-Flight Distance Sensor Link
- 5mW Laser Diode Link
- 2N2222 Transistors x2 Link
- MLX90614 Temperature Sensor Breakout Link
- MPU-6050 IMU Breakout Link
- 1000mah 1S LiPo Battery Link (must be at least 1000mah, 50 x 34 x 5.2mm are the maximum dimensions)
- TP4056 LiPo charger board Link (there are a few versions of this out there, make sure the LED placement matches the one linked)
- 53x30mm 5V solar panel Link
- 220, 1k x 2, 10k x 4, 47k x 2, and 100k 0805 SMD resistors Link (set at link contains 20 of each type)
- 940nm LED and IR Photodiode Link (Make sure it you use a photodiode, not a phototransistor)
- 2Position 3P SPDT Panel Mount Slide Switch, 5-6mm knob length Link
- 6x6x9.5mm tactile switch x 3 LinkLink (second link is the value pack I used, first is a direct purchase. If you buy elsewhere be sure to get the through-hole version, not SMD)
- 2.54 Male Header Pins Link
- Heat shrink tubing Link or electrical tape (optional)
- 26Ga stranded wire Link
- Female 2.54 mm Crimp Terminals and 2-pin 2.54mm Connector Link (optional, linked kit includes crimping tool, male / female headers, and some wire)
- MCP23008 Link
- LM358P Link
- 10K Pot Link
Custom PCB:
To connect all the electronics together, and make assembly easier, I designed a custom PCB (the attached Gerber zip file) Unless you can make PCB's locally, you'll have to order some from a prototype PCB manufacturer. If you've never purchased a custom PCB before, it's very straight forward; most companies have an automated quoting system that accepts zipped Gerber files. I can recommend JLC PCB, Seeedstudio, AllPCB, or OSH Park, although I'm sure most others will work as well. All the default board specs from these manufactures will work fine, but make sure to set the board thickness to 1.6mm (should be the default). The board's dimensions are 107.5 x 31mm. Board color is your preference.
Other Parts:
- M2 x 4mm Screws x9
- M2 x 8mm Screws x4
- 6x3mm Magnets x 12 Link
- Adhesive Backed Velcro Strips Link
- 1/16" Diam. Metal Rod Link (need ~8mm)
- 3mm Diam. Clear Acrylic Rod Link (need ~20mm)
- 25mm x 1.5mm Square Clear Acrylic Tiles Link (need 3)
Tools and Adhesives:
- FDM 3D printer, 1.75mm filament, 0.4mm nozzle
- Wire Clippers
- Wire Strippers
- Soldering Iron with a fine tip
- Tweezers (optional)
- Small Needle-Nosed Pliers
- PH#0 Screwdriver
- Hot Glue Gun + Hot Glue Sticks
- Superglue
- Plastic Glue Link
- Hacksaw or Large Diagonal Cutters (for cutting 1/16" metal rod)
Step 1: Overview of Sensors and Electronics
In this section I'll go over each of the sensors in the multi-tool, briefly explain how they work, and their performance. I will also go over the other major electronic parts, their purpose, and why I choose them. Reading this section is optional, as it is mainly educational and rather long.
Sensors:
- MPU6050 IMU:
- An IMU (Inertial Measurement Unit) measures the orientation of the sensor in space. In other words, it measures the rotation of the sensor about the x-y-z axes. Most IMU's consist of two sensors, a three axis accelerometer and a three gyroscope. As you might have guessed, the accelerometer measures accelerations along the x-y-z axes while the gyroscope measures the sensor's rotation about each axis.
- Although both the accelerometer and gyroscope can calculate orientation alone, their combined reading produces a more accurate result. Accelerometers are noisy, but their readings don't drift, while gyroscope readings tend to drift over time, but are very accurate. By combing each sensor's readings with some math (typically a complimentary or Kalman filter) we can produce an accurate end result.
- It should be noted, that with just an accelerometer and gyroscope, the rotation of the axis parallel to gravity (normal to the ground) can only be measured by the gyroscope, and so will drift (this is relevant to the protractor mode of the multi-tool) . You can fix this by incorporating a magnetometer into the IMU (turning it from a 6-axis IMU into a 9-axis)
- I chose the MPU6050 IMU to use in the multi-tool. This is a low cost, common, 6-axis I2C IMU . Most importantly it can perform DMP (Digital Motion Processing), meaning that it will calculate angles directly from the raw accelerometer and gyroscope readings. This saves me from having to implement a complimentary or Kalman filter (the latter of which is very accurate, but requires a lot of number crunching by the micro-controller) The only downside is that the sensor uses an interrupt to signal a new DMP reading, requiring an extra pin on the micro-controller. Thanks to Jeff Rowberg, for reverse engineering the DMP.
- In my experience, the MPU6050 seems to produce accurate and stable angle readings.
- Mouse Encoder:
- I got the idea of using a mouse encoder from Patrick Panikulam's Multi-tool. Encoders are a common way of measuring rotary motion. They generally consist of a disk featuring some kind of marker, be it an indent, slit, magnet, etc. The disk is attached to a rotating shaft, and as it rotates, the disk's marker passes by some kind of sensor, registering the rotation.
- The mouse encoder uses a series of indents to flex a pair of metal plates, which complete a circuit, sending a pulse to the micro-controller. It's like a pair of buttons being pressed as the encoder turns.
- Most encoders are quadrature encoders; which can distinguish between forwards and reverse rotation. They do this be offsetting the two sets of markers such that one is "off" while the other is "on". So whatever marker turns "on" first determines the direction of motion. In the multi-tool, the encoder's outputs are tied to interrupts on the micro-controller, so it should be fairly accurate. However, the encoder is only intended for use in a mouse, so I wouldn't try to rotate it too fast (above 500 rpm maybe).
- VL53L1X TOF Distance Sensor:
- The VL53L1X uses an infrared laser to measure distance. TOF stands for Time-of-flight, so the sensor records the time taken for the laser to be reflected by an object and converts this to a distance measurement. It's maximum range is 4m under ideal conditions (low ambient IR and a light gray surface) In my testing it seemed to read about 3.5m max reliably with a accuracy of about +-6mm. Curved or angled surfaces seem to throw-off the reading quite badly. The VLX53L1X has an FOV of 27°, so at a distance of 1cm, the measured spot is about 0.5cm wide, at 30cm, it's 15cm wide, etc. Out of all the sensors this one is the most unusual. I thought about using the more common sonar or Sharp IR sensors, but decided they were either too bulky, too expensive, or had too little range. The VL53L1X board from Pololu has decent range, is cheap (esp considering it's basically a Lidar), and is fairly small.
- IR LED/IR Photodiode Tachometer:
- The principles of the IR LED and Photodiode combo are discussed here. This also includes the circuit I used in the multi-tool (see the schematic at the bottom of the linked page). To summarize, the IR LED emits infrared light, while the photodiode's resistance decreases with increasing IR light. Meanwhile, the photodiode outputs an analog signal, but we need a digital one (I'm using the Wemos D1 Mini's single analog pin to monitor the battery). Using an LM358 dual op-amp and a potentiometer we build a comparator, producing a high digital signal only if the photodiode's voltage output is greater than the potentiometer's. So if the photodiode receives a burst of infrared light, it's resistance decreases, dropping the voltage, producing a low signal. Additionally, I added a 2N2222 to the ground of the circuit, so the IR LED and photodiode can be turned off when not in use. This saves power and avoids IR interference with other sensors.
- By attaching a square of IR reflective tape to a spinning body, we can record the frequency of rotation by adjusting the potentiometer to only trigger the LM358 as the IR tape goes by. The LM358 output is wired to pin D4 on the Wemos D1 Mini, which is also connected to the onboard LED, serving as an strigger indicator for the tachometer.
- This method seems to be a standard contact-less tachometer setup. In-fact a number commercial tachometers seem to work in a similar way, also requiring IR tape. Avoid using it in direct sunlight or other high IR environments. In testing the system seemed quite accurate, matching the readings from the encoder based tachometer. Operating range is 4-6cm. I'm not certain of the max RPM, but similar setups, such as Link suggest about 20K.
- MLX90614 IR Temperature Sensor:
- TheMLX90614 is a commonly available infrared, non-contact, temperature sensor. The base sensor is already a through-hole part, but I choose to use a commonly available breakout board version of the sensor because it fitwell on the PCB. The sensor communicates over SMBus (I2C), so it doesn't need any extra pins on the multi-tool IR temperature sensors work by measuring black-body radiation, which is emitted by all objects. The molecules in an object are constantly vibrating, and emitting infrared radiation. The vibrating increases with temperature, increasing the amount of radiation. The MLX90614 absorbs the radiation, generating an electrical signal. Because of this, the sensor is sensitive to incident radiation, so the best performance is had indoors, reading from objects with high IR emissivity (dull, not shiny surfaces)
- The MLX90614 has a 90° FOV, so for every 1cm away from the object, the sensing spot grows by 2cm. So you probably want to hold the multi-tool within 5cm for most objects. The MLX90614 also reports the ambient temperature (the temperature of the sensor body). The sensing ranges are -70 to 382.2 °C (-94 to 719.96 °F) for objects and -40 to 125 °C for ambient. Versions of the MLX90614 with tighter FOV's are available but are much more expensive and bulky.
- I would describe the MLX90614's performance as ok. It seems to be accurate at room temperatures, but becomes less accurate at lower and higher temperatures for point sources. This is most likely due to the high FOV capturing ambient readings. Meanwhile temperature gradients in the sensor can cause miss-readings, so holding it extremely close to an object can cause problems as well. Overall it's probably best to use this to detect average temperatures over an area rather than the exact temperature of a point source.
Other Electronic Parts:
- Wemos D1 Mini: The D1 Mini is the brain of the multi-tool; it collects data from the sensors and translates it to a readable form, and displays it on the LCD. The D1 Mini has just enough digital and analog pins to run all the sensors, and operates at 3.3v, making it LiPo friendly. The individual pin connections are listed on the PCB itself. Notably, the single analog pin is used to monitor the battery voltage. More experienced readers might be wondering why I choose a D1 Mini, an esp8266 breakout, as the controller despite the project not requiring internet connectivity. There are certainly other controllers I could have used, my reasons for the D1 are outlined below.
- The libraries I wanted to use require too much flash memory to fit on an Arduino Nano, Pro-Mini, or Micro (this is mainly due to the package required to run the DMP on the MPU6050), so needed a beefier controller.
- I wanted everything to be easily solder-able, so a through-hole breakout board was preferred over a raw chip.
- I wanted it to be easily programmable using the Arduino IDE
- I wanted it to be as small as possible, while still having enough pins for all the sensors.
- The D1 Mini comes with a LDR voltage regulator, allowing it to run directly from the LiPo (down to 3.5 volts, where the LiPo is mostly discharged). The D1 Mini also has a voltage split connected to the analog pin, requiring only one external resistor to read the battery voltage.
- The D1 Mini is available from a variety of sellers at a low cost.
- I already had few D1 Mini's lying around and wanted more experience with them :)
- MCP23008I2C IO Extender: The MCP23008 is used to expand the number of IO pins available to the controller, adding 8 additional digital pins. It communicates over I2C, so it fits well into the multi-tool as most of the sensors already use I2C. Each IO pin can be configured as an interrupt; if pin states change, the MCP23008 will flag an interrupt pin on the controller, prompting the IO states to be checked. For the multi-tool I use the MCP23008 to read the Mode, Extra, and Zero button's states, as well as control the 2N2222's connected to the laser diode and the IR tachometer system. These all change at a low frequency, so any delay from the MCP23008 doesn't matter. Likewise, using the MCP23008 leaves more D1 Mini pins available for high frequency inputs, like the encoder and the IR tachometer reading.
- TP4056 LiPo Charge Controller: The multi-tool needed to be battery powered. A 1S LiPo was an obvious choice: rechargeable, small, lightweight, and being at a suitable voltage to power all the sensors. However, a LiPo needs to be charged carefully, requiring a controller. The TP4056 board is perfect for this because it is small, cheap, widely available, easily soldered, has indicator LEDs and a USB port, and allows pass through current (can drive the multi-tool directly from USB). The only downside to the board is that the charge current is prefixed at 1A (the charge current used by the TP4056 chip is adjusted using a resistor value). As a rule-of-thumb LiPo's can be safely charged at 1C (1 times their capacity), so a 1000mah is the smallest capacity LiPo I could use. Luckily, my PCB's size matches common 1000mah LiPo's quite well, and this gives the multi-tool many hours of run time.
- SSD1306 0.93" OLED: The multi-tool needed a display of some-kind. Most common LCD's are too big for the multi-tool. However, the 0.93" SSD1306 is commonly available, cheap, and has a low power consumption, while still having a good enough pixel density and size to be readable. You can draw lines and shapes directly on the display, which is useful in a number of the multi-tool's modes. It also communicates over I2C, minimizing pin usage. A downside is its lack of a back-light, making the display hard to read in bright environments.
- Solar Panel: The solar panel was one of the final features added to the multi-tool. I though it would be a useful addition at the cost of a few extra components. The multi-tool's case was already mostly designed, so I choose the largest panel that would fit, requiring that it output 5V (to match the TP4056 input and avoid any voltage converting components). It only outputs 30ma max, so in direct sunlight it will take over a day to charge the 1000mah LiPo, but it's a nice-to-have feature.
- Laser Diode: The lasers main purpose is to show where the distance sensor is pointing. The type of laser I used is both common and inexpensive. I doesn't have the tightest focus, but at 4.2V it's bright enough to be clearly visible on most surfaces at 10+ feet. The laser is controlled by a 2N2222 transistor connected to the MCP23008.
Step 2: PCB and Case Design
I'm going to keep this part brief, as I'm sure the exact details of how I designed the PCB and case will be just as tedious for you to read, as they are for me to write about. Instead this section is intended to highlight some of the important parts of the PCB and case. This may help if you need to trouble-shoot, or add a new sensor, but is not required reading. If you have any specific questions, don't hesitate to ask me.
The PCB:
- I decided to design a custom PCB for this project to make it easier for people to assemble, and to minimize the multi-tool's size. I used EasyEDA to design the PCB, which is a great, online PCB design tool. The PCB is public and can be found here.
- I tried to keep most of the sensors in one area of the PCB. This means you don't have to change your grip to use each of the modes.
- Most of the sensors don't interact with each other, so the board is mostly modular. You can leave out a sensor if you don't need it, with one caveat. Most of the sensors I used communicate over I2C and are on their own breakout boards. This means they come with their own pull-up resistors for the I2C lines. In general, both I2C lines need to be pulled-up to VIN, but the acceptable resistor ranges depend on the voltage and bus capacitance. More details, can be found here. My PCB doesn't include pull-up resistors because the equivalent resistor value from all the sensor boards is about 1.6k (10K on the, VL53L1X, and SSD1306, 4.7k on the MPU6050 and MLX90614) You can still remove any sensor and be safe, but this is something to be aware of.
- I've included an extra I2C port on the board, in-case you want to add your own sensor. As noted above, you must be careful to consider the end pull-up resistor value of the I2C lines. The current 1.6K value is fairly close to the minimum, so you might need to consider removing the pull-ups on any new sensor.
- I've also broken out the WEMOS TX and RX pins if you need them for a new sensor.
- I only use first five of the MCP23008 IO pins, leaving three spare. I didn't break these out, but you can solder directly to them if needed.
- I've added text to the PCB detailing all of the pin connections. It gets covered up by the MPU6050 and the battery, but is still more or less legible.
The Case:
I designed thecase using Fusion 360. It's intended to be 3D printed; I made sure each part can be oriented to require minimal supports. In designing it, I basically took the PCB and extended a body around it, cutting holes for sensors, and adding space for the measure marker and solar panel. Originally I intended to use the screw holes in the PCB to secure the case halves together (a screw would pass through one case half, through the PCB and into the other half), but I did not leave enough space around the screw holes on the PCB. In the end it worked out, with the PCB being secured to the bottom of the case, and the case halves being secured using their own holes. I also wanted to 3D print the button labels directly into the case, but I could not find a font that would print cleanly without needing to be too big. The OLED display and the solar panel were both fragile enough that I wanted to protect them, but I didn't want to cut up pieces of acrylic, because it's difficult to get perfect squares. I did some googling and found the acrylic model bases as linked in the supplies section. The bases come in a number of sizes, but by luck, the 25mm squares fit both the screen and the solar panel well.
Step 3: Modes
This section will serve as the multi-tool's manual. I will go over each of the tool's modes, their function, each button's action, and any limitations to measurements. If you have any suggestions for new modes/actions please let me know in the comments, I'd love to add more functionality!
You switch between modes using the Mode button. It cycles through each mode in turn.
Modes:
Roll Level:
- This is like a typical bubble level. Hold the multi-tool so that the display is perpendicular to the ground. The display will show the rotation of the multi-tool in degrees. Uses the MPU6050 IMU.
- Zero Button: sets the current angle as the new zero.
- Extra Button: No action.
X-Y Level:
- Like a circular bullseye level. Hold the multi-tool so the display is parallel with the ground. The display will show the rotation of the multi-tool around the x and y axes in degrees. In other words it shows a two axes orientation of the tool. Note that the angles are constrained between -90, 90. This also applies if you are holding the tool upside down (display facing the ground). Uses the MPU6050 IMU.
- Zero Button: zeros both axes, making the current orientation the new zero.
- Extra Button: No action.
Protractor:
- Measures the horizontal angle of the multi-tool (like a protractor on a piece of paper). Hold the multi-tool so that the screen is parallel to the ground. The display will show the rotation of the multi-tool around the axis normal to the screen in degrees. Please note, that due to the IMU's limitations (see step 2) the angle will constantly drift. You should zero the reading and quickly rotate the multi-tool to get an accurate measurement. Uses the MPU6050 IMU.
- Zero Button: sets the current angle as the new zero.
- Extra Button: no action.
Laser Ruler:
- Measures distance using the VL53L1X infrared TOF sensor. The sensor is mounted on the left side of the multi-tool. When the mode is active, the laser diode will turn on. The laser is aligned with the VL53L1X, letting you know where you're measuring to. The VL53L1X has three measurement modes: long, medium, and short. The current mode is indicated on the display along with the maximum range (4m, 3m, and 1.3m respectively). Each mode won't necessarily give you better performance (the sensor's accuracy seems be +-6mm), but they are instead intended to help avoid ambient light interference. The long mode should work in most cases, but if you're outdoors, you might want to use another mode. The display shows you the status of the latest measurement, which should help in picking a mode (if you get a lot of invalid readings, you'll need to switch). Avoid pointing the sensor at angled, curved, or shiny objects as these will produce inaccurate measurements. To help, you can use the included measure marker, which is stored on the multi-tool, as a target for measuring to.
- The VLX53L1X has an FOV of 27°, so at a distance of 1cm, the measured spot is about 0.5cm wide, at 30cm, it's 15cm wide, etc.
- Zero Button: switches between measuring modes: Long, medium, short (might take a few seconds to take effect)
- Extra Button: switches between mm and inches
Wheel Ruler:
- Uses the wheel on the left side of the multi-tool to measure distance. Turning the wheel increments the measurement in steps, 1.6mm (0.06in) for each step. Direction is also tracked, so rolling the wheel in reverse will lower the measurement. Note that the measurement is never negative, if you pass through zero, it will increase, using the current rolling direction as positive (this is way more intuitive than it sounds :) ). Uses the encoder for sensing.
- Zero Button: zeros the measurement, setting a new starting point.
- Extra Button: switches between cm and inches.
Wheel Tachometer:
- Uses the wheel on the left side of the multi-tool to measure RPM. Because this uses the physical encoder, and requires the multi-tool to be in contact with the spinning object, only use this mode for lower RPMs, both for safety, and to avoid damaging the encoder. I'm not sure what the maximum safe RPM is, but I'd try to keep measurements below 500 RPM. If you need to measure high RPMs, use the IR tachometer mode. To begin reading hit the zero button and hold the wheel to your spinning object. By default, the multi-tool will count the number of rotations over a 10 sec period, and then calculate the RPM. Note that the timer only begins after the multi-tool detects rotation, so you can start a measurement, and then position the multi-tool. You can also end the measurement early by hitting the zero button again. Once the measurement period has ended, the multi-tool will report the RPM. Pressing the zero button will start a new measurement.
- The reported RPM is that of the multi-tool's wheel. To find the RPM of your object, you need to take this and multiply it by the ratio between the multi-tool's wheel diameter, and the diameter of your object. Ie RPM * (Multi-tool Wheel Diam / Object Diam) = RPM of object
- Zero Button: Begins and ends measurement periods.
- Extra Button: No action.
IR Tachometer:
- Uses the IR LED and Photodiode on the left side of the multi-tool to measure RPM without contacting the spinning object. I'm not sure of the maximum possible RPM is, but similar setups report 20K. To use this mode you'll need something that is IR reflective to attach to your spinning object (such as IR tape) Attach a small strip of IR reflective material to your object. Point the IR LED/Photodiode at the material, and adjust the IR Tac Adj knob until the IR Tac Ind LED just lights up. The LED is the counter, each time it pulses, a revolution is counted, so make sure that the LED only lights up when the multi-tool is pointed at the reflective strip. Once you're ready, the measurement method is the same as the Wheel Tachometer mode, hitting the zero button starts/stops measurements.
- Zero Button: Begins and ends measurement periods.
- Extra Button: No action.
IR Thermometer:
- Uses the MLX90614 non-contact IR thermometer on the back of the multi-tool to measure an objects temperature. The MLX90614 also reports the ambient temperature (the temperature of the sensor body). The sensing ranges are -70 to 382.2 °C (-94 to 719.96 °F) for objects and -40 to 125 °C for ambient. Note the MLX90614 has a 1 to 2 ratio between spot size and sensor distance from target (a 1cm range, means a 2cm detection area). It is much better at reading the average temperature of an area than of a point source. You probably want to hold the multi-tool within 5cm for most objects. It is also effected by the object's IR emissivity, so avoid very shiny metals. In my experience, the sensor is not accurate at lower temperatures (below 40°F), but is ok for higher ones.
- Zero Button: No action
- Extra Button: Switches between °F and °C.
Laser Pointer:
- Gives direct control over the laser diode on the left side of the multi-tool. Both the zero and extra buttons can turn the laser on/off.
- Zero Button: switches the laser on/off.
- Extra Button: switches the laser on/off.
Step 4: Pre-construction
Before you begin assembling the multi-tool you should:
- Gather all the components, supplies, and tools listed in the intro.
- 3D print all the stl files found in the "Digital Multi-tool 3D print parts" zip file attached to this step. Print three copies of "Button Cap.stl" and one copy of everything else. I recommend printing with 0.4mm nozzle, with 20% infill at 0.2mm layer height. If your slicer supports single width extrusion, please use it. Only the case top and bottom parts require supports.
- Print a copy of "Digital Multi-tool Labels.pdf".
- Download and install the Arduino IDE found here and the esp8266 core V2.5.0 for Arduino, see here for instructions. Important, make sure you use V2.5.0 of the esp8266 core and no later. Later versions change how interrupts work. At the time of writing, most libraries have not updated yet and will not compile for newer core versions.
- Download the libraries needed for the Multi-tool. You can install most of them using the Arduino IDE's library manager, just search for the library name. Direct links are provided below:
- MLX90614 (Adafruit)
- Vl53L1X (Pololu)
- Encoder (Paul Stoffregen)
- SSD1306 Display and Adafruit GFX (Adafruit)
- MCP23008 Library, find this file attached to this instructable. It's a modification of the original Adafruit library to add interrupt support. Install it by unzipping the folder and placing it in the libraries folder in the Arduino IDE install directory. See here for detailed instructions.
- MPU6050 and I2Cdev (Jeff Rowberg)
- Battery Sense (Roberto Lo Giacco)
- Verify that you can upload code to your Wemos D1 Mini by uploading blink (found in the Arduino IDE under file->examples->basics->blink). Make sure you select "LOLIN(Wemos) D1 R2 & Mini" under tools->board and the correct port. Use a micro USB cable (with data lines) to connect to the Wemos. If everything is correct, the D1 Mini's LED should blink once a second.
- I highly recommend that you test each sensor (excluding the IR LED/Photodiode and encoder) and the display before soldering them to the multi-tool's PCB. This will save you a lot of headache if you need to trouble-shoot later. All of the libraries include an example you can run for testing, including wiring instructions. Note that on the D1 Mini, the SDA line is tied to D2, and the SCL on D1. You will probably need a breadboard and some hook-up wire. Also, if you solder headers onto the sensors, please match the orientations shown in the construction steps of this instructable. Some notes for each of the parts are listed below for reference:
- MLX90614: Follow the hook-up (changing the I2C line for the Wemos), but use the example in the Adafruit Library linked above.
- VL53L1X: follow the instructions in the Pololu library linked above. If you solder on headers, be sure to use the right-angle type as shown in the construction pictures later in this instructable.
- SSD1306 Display: Follow the hook-up (changing the I2C line for the Wemos). Address should be 0x3C.
- MPU6050: Use the MPU6050_DMP example from the library. Hook-up the MPU6050's Int0 pin to D8 of the D1 Mini, and change the INTERRUPT_PIN from 2 to D8 in the example. Also change LED_PIN to D4.
Step 5: PCB Assembly Step 1:
Please follow these steps exactly, if you do not, some components may become inaccessible. If you don't want to include all the sensors initially, you should still solder headers for them onto the board. In general we will attach components to the PCB in order of height, starting with the lowest. If you have any questions about the assembly please let me know! Some components have pads that are close together, so I advise using a soldering iron with a narrow tip for the entire assembly. Start by soldering the 0805 SMD resistors. Each location on the PCB is labeled with the required resistor value and circled on the image above. You will use one 100k, one 220, two 1K, two 47K, and four 10k.
Step 6: PCB Assembly Step 2:
Next solder most of the through-hole components. Following the image above attach the: two 2N2222 transistors, LM358P, MCP23008, 1N4148 Diode (orient the white line on the PCB with the black line on the diode), and the MPU6505. Make sure you match each component's orientation to what is indicated on the PCB. Solder the MPU last, keeping it as parallel to the PCB as possible. I recommend soldering one pin first, keeping it molten while you align the MPU. Once it's aligned, solder the remaining pins. Trim back any excessively long pins as needed.
Step 7: PCB Assembly Step 3:
Attach the TP4056 battery charger board to the underside (opposite side to the SMD resistors) of the multi-tool PCB using single 2.54mm header pins. Do not solder headers to the B+ and B- pins. Note that there may be a slight discrepancy between the hole placement on the PCB and the TP4056. I advise soldering the headers to the TP4056 first such that the long side of the header will go into the multi-tool's PCB. This gives you some room to squeeze the pins in if the holes don't match. Trim back any excessively long pins as needed.
Step 8: PCB Assembly Step 4:
Solder the Wemos D1 Mini (using 2.54mm male headers), three push-buttons, and optionally 2 pin male 2.54mm headers for the solar panel and laser diode. Solder the Wemos and headers first. Trim back any excessively long pins as needed. If you don't want to use headers for the solar panel and laser you can solder their wires directly onto the board. To avoid having them flopping around in the rest of the assembly, you can solder them later in steps 6 and11 (I'll remind you). Using headers for the laser also allows you to detach the top half of the case from the PCB after assembly is complete.
Step 9: PCB Assembly Step 5:
For this step you'll need to 3d print the LED Mount stl file (found in the pre-construction step). Insert the IR LED and photodiode into the LED mount as pictured; photodiode in the top hole, IR LED in the bottom. Pay attention to the their orientation, their flat edges should be facing the same direction. Next bend the leads as pictured. Make sure that when inserted into the multi-tool's PCB, the longer leads are closest to the board edge. Before you insert them, you can optionally cover the leads in heat-shrink or tape. This helps prevent accidental shorts. Once inserted, do not solder them, we will do so in the next step.
Step 10: PCB Assembly Step 6:
Solder the mouse encoder, VL53L1X, and the IR LED/Photodiode pair. Do the mouse encoder first, you might need to bend the tab pins slightly to fit. You can do the VL53L1X and the LED's at the same time. Be careful with the VL53L1X's orientation. Try the match the picture; the sensor (the black rectangle with gold squares) should be facing the closest edge of the multi-tool's PCB, use right angle pins of the type pictured, inserted also as pictured, and lastly, make sure the sensor board is as perpendicular to the multi-tool's PCB as possible. Trim back any excessively long pins as needed.
If you did not attach headers for the laser diode in PCB assembly step 4 you should now solder the lasers leads to the +/- holes labeled "laser" on the PCB. Make sure the leads are at least 6.5cm long. The positive lead should be red, and the negative blue. + (PCB) -> positive wire (laser), - (PCB) -> negative wire (laser)
Step 11: PCB Assembly Step 7:
Attach the MLX90614 temperature sensor to the rear of the multi-tool's PCB using male headers, as pictured. Try to keep the MLX90614 board as parallel to the multi-tool's PCB as possible. Trim back any excessively long pins as needed.
Step 12: PCB Assembly Step 8:
Attach the potentiometer, SSD1306 OLED display, and the slide switch to the PCB. Do the potentiometer first. Its larger tabs require quite a lot of heat to take solder, so, if possible, increase the temperature of your soldering iron a bit. For both the switch and the display, use 8cm lengths of 22Ga or smaller wire. Solder one wire to the center pin of the switch and one to an outer pin. Then solder the wires to the PCB holes as shown in the image (ignore the unused hole in the picture, it's not present on your PCB version), their exact order doesn't matter. For the display attach the wires between the its pins and the corresponding holes on the PCB, matching the labels on both the display's pins and the multi-tool's PCB holes. IE, SCL (display) -> SCL (PCB), GND (display) -> GND (PCB), etc. Optionally you can use a section of heat-shrink or tape to keep the wires orderly.
Step 13: PCB Assembly Step 9:
Following the picture, add Velcro strips to the battery and the PCB. Not only does this help secure the battery, but it prevents the battery from being possibly damaged by the PCB's exposed pins.
Step 14: PCB Assembly Step 10:
Solder the battery wires to the TP4056 B+ and B- holes as pictured. To prevent any accidental shorts, I suggest cutting, stripping, and soldering the wires one at a time, starting with the negative one. The red wire on the battery should be positive, but you may want to confirm this using a multi-meter (I have seen some Amazon reviews claiming their wires were reversed). A multi-meter should show a positive voltage between the red and black wires of the battery.
Step 15: PCB Assembly Step 11:
Solder wires to the solar panel using the exposed copper pads on its back. You probably only need about 4cm of wire attached to each pad. If you added male headers to the PCB for the solar panel in PCB Assembly Step 4, you should add female headers to the solar panel wires. You can then plug the solar panel onto the PCB. Make sure you match the polarity: + (solar panel) -> + (PCB), - (solar panel) -> - (PCB).
If you did not add headers, solder the wires directly to the PCB using the holes marked "solar" (most easily seen on the back of the PCB). Solder the wires such that they stick out the top side of the PCB (the side with the Wemos). Make sure you match the polarity: + (solar panel) -> + (PCB), - (solar panel) -> - (PCB).
If everything is correct, holding the solar panel to direct sunlight should cause one of the LED's on the TP4056 to light up.
Step 16: PCB Assembly Step 12:
Cut about 1cm of the 1/16" Diam. metal shaft and 3D print the wheel stl file. Insert and glue the shaft into the hole in the wheel. Then insert and glue the shaft into the mouse encoder's hole, leaving about a 3mm separation between the wheel and the encoder. I recommend a fast drying glue for this, such as superglue. Be careful not to spread glue into the encoder mechanism and bind it up.
At this point you are done with the PCB assembly, and can move onto the case.
Step 17: Case Assembly Step 1:
When gluing the acrylic parts do not use superglue, it will fog them up. Use plastic glue.
- Take the 3mm Diam. acrylic rods and cut them into one section about 20mm long and two sections each about 6mm long as pictured.
- As pictured, insert and glue the long rod into the corresponding hole in the top half of the case (the larger half). This is a light pipe for the Wemos LED.
- Insert and glue the two short acrylic rods into the corresponding holes on the bottom of the case (the smaller half). I forgot to take a picture of this, but the correct holes are the only ones sized for the rods. These are light pipes for the TP4056 LEDs.
- Glue the clear acrylic squares into position on the top half of the case (the larger half). Using the pictures for guidance, glue one square into the inset area on the front of the case, and two squares into the inset area on the side of the case. Sorry if these directions are a bit vague, hopefully the pictures should be clear. We're using the squares to cover up the holes for the solar panel and the display.
Step 18: Case Assembly Step 2:
Insert and glue 3x6mm magnets into the holes in both the top and bottom halves of the case as pictured. You will need 10 magnets in total. The holes have a slight taper, so you should insert the magnets from the inside of the case.
Step 19: Case Assembly Step 3:
Return to the multi-tool PCB and add the IR adjust knob to the potentiometer, and the three button caps to the push-buttons as pictured. These should all be press fits, but depending on the tolerance of your printer you may have to add a dab of superglue.
Step 20: Case Assembly Step 4:
If you have not done so, print out the "Multi-tool Labels.pdf" attached to the pre-construction step. Cut the labels out and glue them into the indents in the multi-tool case as pictured. I suggest using plastic glue to give you some extra working time over super glue. There's not a lot of extra room around most of the labels, so you'll have to trim them close to the letters. For the Laser Ruler / IR Tac side, ignore the wheel and inner parts in the image, I forgot to take the picture until after the multi-tool was finished.
Step 21: Case Assembly Step 5:
Now it's time to combine the case and the PCB. Insert the PCB into the bottom half of the case as pictured. Secure it with three 4mm long M2 bolts. Note that in the picture two of the screws are hidden by the VL53L1X. You may need to trim the pins on the VL53L1X to allow the bolts past. Ignore the extra corner hole in the PCB.
Next secure the display and slide switch as pictured using 4mm long M2 bolts. You can remove the display screen protector if it has one. Make sure the switch is oriented in the right direction (so that the on position matches the case label).
To do this next bit, you'll have to be able to turn the laser on, so skip forward to the code uploading section, and then come back here.
Lastly, hot glue the laser diode into it's hole as pictured. Make sure you adjust the focus and the laser's angle before gluing, so that it produces a small dot, and a beam that is parallel to the case side (you want the beam pointing where the distance sensor is pointing). You can adjust the angle by looking along the case half, and nudging the laser dot position until it seems to be aligned with the case.
Step 22: Case Assembly Step 6:
Press the two case halves together, oriented so that the wheel cut-outs align. The tab in the outer wall of the lower case half should insert into the corresponding slot in the upper case half. As you press the halves together you might need to move some wires around and align the button caps with a pair of tweezers. The solar panel should fit into the slot next to it's position on the PCB. You might need to bend it's wires to get the case halves together. Once everything's together, insert four 8mm-12mm long M2 bolts into the holes as pictured. The pictured case is a prototype, yours will have a hole at each red circle, use a bolt in each of them. Tighten the bolts down until the case is snugly held together.
Step 23: Case Assembly Step 7:
Assemble the measure marker from "measure marker" stl parts 1, 2, and 3. Join the three parts together by inserting lengths of 1.75mm filament into each hinge. You shouldn't need glue. My pictures are not the best for this step, but hopefully you'll figure it out. Lastly, insert and glue two 3x6mm magnets into the marker's holes. Once it's assembled, you can fold up and store the measure marker in the slot next to the solar panel on the multi-tool.
Step 24: Programming:
Now it's time to upload the code to the multi-tool. You can find the Multi-tool's code attached to this step. If you haven't installed the required Arduino libraries for the code, please go to the pre-construction step to find them. There you can also find instructions for installing the boards package for the Wemos D1 Mini.
When uploading code to the Wemos, sometimes you get a memory read/write error. This is fine, just try uploading again, or disconnect the Wemos and try again.
Before you actually upload the code you might need to do a few things:
- If you have chosen to not include one or more of the sensors you'll need to go into the code and change the modes. The modes list can be found towards the top of the code under Modes. Each mode is numbered and labeled with the sensor it uses. For any modes you won't be able to use, set their number to 999. Then adjust the numbers of the remaining modes (so they go from 0 to however many modes are left) and change the NUM_MODES to match the number of active modes.
- If you are using the IMU, you should calibrate it (the multi-tool will work without doing this, but with reduced IMU accuracy). To calibrate, upload and run the IMU_Zero sketch found in the MPU6050 examples. Follow the instructions in the example. After getting the results, go to the Multi-tool's code and fill in the offset values. These can be found towards the top of the code under IMU OFFSETS.
Now you can upload the Multi-tool's code to the Multi-tool. If everything is correct it should start up right away. Cycle through the modes and test each one.
At this point you can return to Case Assembly Step 5 to align and glue the laser diode in place.
Attachments
Step 25: You're Done!
If you're here that means you should have a fully functioning multi-tool. I hope you find it useful!
If you want, you can add your own sensor using the spare I2C (watch the pull-up value, see the PCB and Case Design Step) or serial ports. There's also a few spare pins on the MCP23008 (but I did not add header spots for them). You'll have to modify the code, but it's fully commented, so hopefully that won't be too hard. I've also attached .step files for all the 3D Printed parts to this step, so you can change the case if needed.
Attachments
Step 26: Trouble Shooting:
Hopefully you won't need this step, but if you're here then something isn't working. I'll list some tips below to help diagnose your problem. Before following any tips, remove the PCB from the case.
- If a mode isn't working, it's probably a faulty sensor. Depending on the sensor, replacing it may be pretty difficult. You'll probably want to cut the sensor off the headers (at a point closest to the sensor), then solder a new sensor on using whatever of the headers is left. Make sure to test the new sensor first.
- If the display isn't showing anything:
- First try cycling the multi-tool modes, the laser pointer should turn on for the laser ruler mode. If the laser turns on, either the display is broken, or it's address is wrong.
- To find the address, go to where you purchased the display from, hopefully the address should be listed. If not, look on the back of the display, there might be a resistor selecting the address. If there is no resistor, google image search SSD1306 and try to find a match, hopefully with an address listed.
- If the address is correct, double check your wiring between the PCB and the display. (SCL -> SCL, SDA -> SDA, GND -> GND, VCC -> VCC). If it's correct, your display is broken, and you'll need a new one.
If the laser never turns on, plug the Wemos into your computer and open the serial port wiindow using the Arduino IDE. Press the reset button on the Wemos. If the serial output shows an error code, you'll need to google the exact cause. This will probably be a hardware reset, which means something on the PCB is wired wrong. Touch each sensor to check their temperatures.
If any are hot, they're probably either broken or wired wrong somehow. Cut the sensor off at the headers. Test the PCB again. Hopefully the display works, along with the modes (excluding the missing sensors). Confirm that the pins on the sensors match those on the multi-tool PCB (maybe you have a different sensor version and the pins are mis-matched). If they do, your sensor is probably broken, if not, the sensor may be ok, but you'll have to do some direct wiring to the correct pins.
- If none are hot, you'll need to confirm the pins are correct for each sensor. If they aren't see above. If they are, unfortunately I can't really help at anymore at this point, as trouble shooting each sensor's output requires an oscilloscope. You may just want to populate a whole new PCB (test each sensor first)
- First try cycling the multi-tool modes, the laser pointer should turn on for the laser ruler mode. If the laser turns on, either the display is broken, or it's address is wrong.
- If the multi-tool only works when connected to USB. Try connecting the USB to the charge port. If one of the LED's on the TP4056 turns on, the battery probably just needs charging. If one of the TP4056 LED's starts flashing, either the battery polarity is reversed, or the battery is dead.
- If the laser won't turn on. First test it directly by applying 5v and ground to its leads (you'll have to find a 5v source and some test wires). If it turns on, the laser's 2N2222 is probably reversed or faulty.
- If the IR tachometer doesn't work. First confirm that the photodiode is producing a signal. You can do this by turning the IR Adj knob counter-clock-wise as far as possible; the IR Tac Ind LED should turn on.
- If the LED doesn't turn on you may have a phototransistor instead of a photodiode. You can check this by measuring if the resistance changes with differing amounts of IR light. If you do have a photodiode, then either it, or the LM358 are faulty and should be replaced.
- If the LED does turn on, make sure the IR LED is working. You can do this looking directly at the LED with most Android phone cameras (IPhones filter IR). It should show up as a light pink color. If it's not on, either the LED is faulty, or the 2N2222 is reversed / faulty. If it is on, the most likely the LM358 is faulty.
If the buttons don't seem to be working. Probably a problem with the MCP23008.
Hopefully this helps with whatever issue you are having. If not, please post a comment and I'll try to help.