DigiLevel - a Digital Level With Two Axes

5,674

84

23

The inspiration for this instructable is the DIY Digital Spirit Level found here by GreatScottLab. I liked this design, but wanted a bigger display with a more graphical interface. I also wanted better mounting options for the electronics in the case. Ultimately, I used this project to improve on my 3D design skills (using Fusion 360) and to explore new electronic componentry.

DigiLevel will provide feedback on whether a surface is level - both along the x-axis (horizontal) and y-axis (vertical). Degrees from level are shown, as well as a graphical representation on a 2 axes chart. In addition, the battery level is shown, and the current temperature in Fahrenheit or Celsius is shown (as reported by the accelerometer chip). This is minimal audible feedback - an initial tone to verify power, and then a double tone any time the level is moved from a non-level position to a level position.

I've provided detailed instructions on how you can make this digital level, but feel free to extend and modify on my design, much as I did on the DIY Digital Spirit Level.

Step 1: Materials

Following are the materials used in putting together this Digital Level. Most of the buying links are for multiple pieces, which are typically cheaper than buying the individual components. As an example, the TP4056 chip comes with 10 pieces for $9 (less than $1/TP4056), or it can be bought individually for $5.

With the exception of the screws, the links provided will take you to Amazon. Nearly all of these items, however, can be purchased on eBay or direct from China at a significant discount. Just keep in mind that ordering from China can result in long lead times (3-4 weeks is not unusual).

Note also that there are alternatives for many of these components. For instance, you could substitute a different accelerometer for the LSM9DS1 (such as the MPU-9205). You could replace the Arduino Nano by using any Arduino-compatible processor with the proper GPIO pins.

In particular, the LSM9DS1 is one I bought on sale at Sparkfun for less than $10, but it is normally higher priced; the MPU-9025 (http://a.co/d/g1yu2r1) provides similar functionality at a lower price.

If you make a substitution, you will likely need to modify the case (or at least how you mount the component in the case) and you will likely need to modify the software to connect to the alternative component. I do not have those modifications - you will need to research and update as appropriate.

Step 2: Wiring Diagram

The wiring schematic details how the various electronic components are wired to each other. Red lines represent positive voltage while black lines represent ground. Yellow and green lines are used for data signals from the accelerometer and to the OLED LCD display. You'll see how these components are wired together in the following steps.

Step 3: Make the Case

If you have a 3D printer, the case can be printed fairly easily. The STL files included in this Instructable. If you don't have a 3D printer, you can upload the STL files to a 3D printer bureau (such as this one) and have them printed for you.

I printed mine with no brim or raft (and no supports) and 20% infill, but you can print yours however you're used to printing. Each piece should be printed separately, laying flat. You may need to rotate it 45 degrees to get it to fit the printer bed. Mine was printed using a Monoprice Maker Select Plus with a bed size of 200 mm x 200 mm - each piece took about 12 hours to print. If you have a smaller bed, it may not fit. Scaling is not recommended as the mounts for the electronic components will then not be scaled appropriately.

Step 4: Wire the Components to a Breadboard to Verify Connectivity (optional)

I strongly recommend wiring the primary components to a breadboard to verify connectivity before proceeding with the mounting of the components inside the case. You can download the software to the Arduino Nano (see the next step), and to verify that the OLED LCD display is correctly wired and is operational, and that the accelerometer has been correctly wired and that it is reporting its data to the Arduino Nano. Also, this can be used to verify the operation of the optional piezo speaker.

I did not connect the battery and charger to the breadboard at this stage - connecting the switch to control the battery is done after you mount the switch to the case. The last picture shows how this looks prior to wiring.

Step 5: Download the Software to the Arduino Nano

The software is loaded to the Arduino Nano using the Arduino IDE. This can be done at any time during the process of building the DigiLevel, but is best done when the components have been wired using a breadboard (see the previous step) to verify correct wiring and operation of the electrical components.

The software requires that 2 libraries be installed. The first is the U8g2 library (by oliver) - you can install this by clicking on 'Sketch -> Include Library -> Manage Libraries...' in the Arduino IDE. Search for U8g2 and then click on Install. The second library is the Sparkfun LSM9DS1 library. You can get instructions on how to install that library here.

After the library specifications, the software has a setup section and a main processing loop. The setup section initializes the accelerometer and the OLED LCD display, and then displays a startup screen prior to showing the main display. If a speaker is connected, it will play one beep on the speaker to signify the power on status.

The main processing loop is responsible for reading the accelerometer, obtaining the x and y angles and then displaying the values as a set of absolute numbers and also pictorially on a graph. The temperature reading from the accelerometer is also displayed (in either Fahrenheit or Celsius). If the level was previously non-level, when it returns to level it will generate two beeps on the speaker (if connected).

Finally, the voltage from the battery is obtained to determine and display the current battery level. I don't know how accurate this code is, but it is accurate enough to show a full battery and the gradual draw down of the battery level during use.

Step 6: Mount and Wire the OLED Display and Piezo Speaker

The 1.3" OLED display (128x64) mounts to the top half of the case using 4 M2x4 pan head self-tapping screws. I suggest you connect your wires to the the display prior to mounting. This ensures that you can see how the pins are labeled as you are connecting the wires. Once the display is mounted, you won't be able to see the labels for the pins. You'll notice that I added a label to the back side of the display so that I could remember the pin values (since I didn't do this the first time and I wired it incorrectly...).

The speaker is used to emit a brief tone when the Digital Level is turned on to verify that the battery is good and that it's operational. It also emits a double tone whenever the level is moved from a non-level position to a level position. This is to provide an audible feedback as you're positioning the level or whatever the level is on. It is mounted to the top half of the case using 2 M2x4 pan head self-tapping screws. You do not need a speaker - the DigiLevel will operate just fine without it, however you will be missing any audible feedback.

Step 7: Mount and Wire the Battery, Battery Charger, and Switch

The switch needs to be mounted to the case prior to connecting it to the battery. This is because if you wire it first, you won't be able to mount the switch without disconnecting it. So mount the switch first, then mount the pre-wired TP4056 and Li-Po battery, then complete the wiring to the switch.

The TP4056 has 4 wiring pads: B+, B-, Out+, Out-. You will want to wire the battery to the B+ (positive voltage) and B- (ground) connections. The Out- connection is used for the ground that will go to the Arduino Nano, and the Out+ is connected to one pin of the switch. The second pin of the switch is then wired to the VIN of the Arduino Nano.

My soldering job is not the best - I like to use heat-shrink tubing to cover and insulate the soldered joint. You'll notice that on one of the soldered connections here, the heat-shrink tubing was impacted by the heat of the soldering and it shrunk before I was able to move it.

Step 8: Mount and Wire the Accelerometer

The accelerometer (LSM9DS1) is mounted in the middle of the bottom half of the case. There are 4 pins to be wired: VCC goes to the V5 pin on the Arduino Nano; GND goes to ground; SDA goes to the A5 pin on the Arduino Nano; and SCL goes to the A4 pin on the Arduino Nano.

I've used jumper wires with Dupont connectors for wiring, however you can solder the wire directly to the pins if you prefer. If you solder the wires directly to the pins, you will probably want to do this before mounting the accelerometer chip to make it easier.

Step 9: Complete the Electronics by Wiring the Arduino Nano

Final wiring is done by connecting all of the electrical components to the Arduino Nano. This is best done prior to mounting the Arduino Nano so that the USB port is accessible for calibration and any other last minute software changes.

Start by connecting the switch to the Nano. The positive lead (red) goes from the switch to the VIN pin of the Nano. The negative lead (black) from the battery will go the GND pin on the Nano. There are two GND pins on the Nano and all four electrical components have a ground wire. I chose to combine the two grounds on the bottom of the case into one lead wired to one of the GND pins. The two grounds from the top of the case I combined into one lead wired to the other GND pins.

The accelerometer (LSM9DS1) can be connected to the Nano by connecting the VDD pin on the accelerometer to the 3V3 pin on the Nano. Do NOT connect this to the 5V pin or you will damage the accelerometer chip. Connect SDA to the A4 pin on the Nano, and SCL to the A5 pin on the Nano. The GND pin goes to the GND pin on the Nano (combined with the negative lead from the battery).

The OLED LCD display can next be connected to the Nano by connecting the VCC pin on the display to the 5V pin on the Nano. Connect SDA to the D2 pin on the Nano, and SCL to the D5 pin on the Nano.

Finally, the speaker can be connected by connect the red wire (positive) to the D7 pin on the Nano. The black wire goes to GND along with the GND of the OLED LCD display.

Step 10: Calibration

Once the software is downloaded, and prior to mounting the Arduino Nano, you may need to calibrate your level. Ensure that the accelerometer board has been mounted. Mounting it with the screws should result in a level board, however if it is slightly off for any reason, calibration will ensure a correct display.

Put the bottom case on a surface that is known to be level (using a bubble level or some other means). Read the displayed values for X and Y. If either is non-zero, you will need to update the software with the calibration amount. This is done by setting either the xCalibration variable or the yCalibration variable to the appropriate amount (what's displayed).

//
// Set these variables with initial values as appropriate
//
bool displayF = true; // true for Fahrenheit, false for Celsius
int xCalibration = 0; // calibration amount for leveling out the x-axis
int yCalibration = 0; // calibration amount for leveling out the y-axis
long irvCalibration = 1457; // calibration amount for internal reference voltage

At this time, you should also set the value of displayF to the appropriate setting depending on whether you want the temperature displayed in Fahrenheit or Celsius.

Reloading the software onto the Nano should now result in a 0/0 reading on a known-level surface.

Step 11: Mount the Arduino Nano and Assemble the Case

Once calibration is completed, you can mount the Arduino Nano in the case by applying hot glue to the rails and placing the Arduino Nano on these rails, with the pins facing up and the USB port facing the interior of the case.

The case containing all of the electronics can now be assembled by putting the two halves together and using 4 M2x8 pan head self-tapping screws.

Step 12: Verify the Operation of Your New Digital Level

Make sure the Li-Po battery is charged. If the case is assembled, you won't be able to see the charging LED indicators directly. If you want to verify the charging operation by viewing the charging lights directly you will need to open the case, however you should be able to see the red glow indicating that charging is occurring with the case closed.

Once charged and assembled, turn on the Digital Level and verify its operation. If it is not working, the two likely trouble points are the wiring for the OLED LCD display and the wiring for the accelerometer. If the display is not showing anything, then start with the OLED LCD wiring. If the display is working, but the H and V labels both show 0 and the temperature is 0 (C) or 32 (F), then the accelerometer is probably not wired correctly.

Step 13: Final Thoughts...

I put together this digital level (and the Instructable) primarily as a learning experience. It was less important to me to make a functioning level as it was to explore the various components and their capabilities, and then put them together in a way that adds value.

What improvements would I make? There are several I'm considering for a future update:

  • Expose the USB port of the Arduino Nano through the case by modifying the way it's mounted. This would allow for easier updates to the software (which in any case should be rare).
  • 3D print the case using a wood filament. I've been experimenting with Hatchbox Wood filament and I'm very pleased with the results I've gotten. I think this would provide a better overall look to the DigiLevel.
  • Update the design to use the MPU-9250 accelerometer to lower the cost while not impacting the function.

This is my first instructable and I welcome feedback. While I have tried to avoid it, I'm sure that this still has a more US-centric perspective - so apologies for those outside of the US.

If you found it interesting, please vote for me in the First Time Author Contest. Thanks for reading through to the end!

First Time Author

Runner Up in the
First Time Author

Share

Recommendations

  • Arduino Contest 2019

    Arduino Contest 2019
  • Trash to Treasure

    Trash to Treasure
  • Tape Contest

    Tape Contest

23 Discussions

0
None
pjessing

Question 4 months ago on Step 9

I already have all the parts and plan on building this sometime in the next week. I install kitchen appliances daily and use a level to level the ranges. I think this will work great for the ranges. I did buy a bigger battery for longer life. It takes up pretty much all of the extra room. My question is before I build it, is there anything you wish you added or did different?
After building it, I plan on sanding the bottom perfectly flat on a belt sander, then calibrate it. I might even make the bottom out of metal.

7 answers
0
None
KCRobertspjessing

Answer 4 months ago

There are a few things I mentioned in my Instructable - like exposing the USB port of the Arduino Nano. This would allow later updating of the software (shouldn't really need to, but you never know...).

The one thing I found with this build is that the USB port for charging is hard to reach with a standard USB cord. I think enlarging the hole would make it easier to fit a USB cable due to the insulation around the end of the cable.

Good luck and let me know if you have any questions.

0
None
pjessingKCRoberts

Reply 3 months ago

I am super excited to get this all working. I have printed and installed the components and am trying to upload the sketch. It has been a while since I have played with Arduino and have not used any other board with them. Though I have fixed some errors I am still getting some.
Though I am not completely new to Arduino, if someone new to this were to build it, is there anymore information you could give them?
Do I have things in the wrong folders?
Here is the entire error messages....

Arduino: 1.8.8 (Windows 10), Board: "Arduino Nano, ATmega328P"
C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Phillip\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Phillip\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Phillip\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10808 -build-path C:\Users\Phillip\AppData\Local\Temp\arduino_build_894124 -warnings=none -build-cache C:\Users\Phillip\AppData\Local\Temp\arduino_cache_809311 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-5.4.0-atmel3.6.1-arduino2.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino14.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.2.1.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Phillip\Documents\Arduino\Digital_Level_V3\Digital_Level_V3.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Phillip\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Phillip\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Phillip\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10808 -build-path C:\Users\Phillip\AppData\Local\Temp\arduino_build_894124 -warnings=none -build-cache C:\Users\Phillip\AppData\Local\Temp\arduino_cache_809311 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-5.4.0-atmel3.6.1-arduino2.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino14.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.2.1.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Phillip\Documents\Arduino\Digital_Level_V3\Digital_Level_V3.ino
Using board 'nano' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "C:\\Users\\Phillip\\AppData\\Local\\Temp\\arduino_build_894124\\sketch\\Digital_Level_V3.ino.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "C:\\Users\\Phillip\\AppData\\Local\\Temp\\arduino_build_894124\\sketch\\Digital_Level_V3.ino.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "C:\\Users\\Phillip\\AppData\\Local\\Temp\\arduino_build_894124\\sketch\\Digital_Level_V3.ino.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src\\Wire.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src\\utility\\twi.c" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src\\SPI.cpp" -o nul
Generating function prototypes...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "C:\\Users\\Phillip\\AppData\\Local\\Temp\\arduino_build_894124\\sketch\\Digital_Level_V3.ino.cpp" -o "C:\\Users\\Phillip\\AppData\\Local\\Temp\\arduino_build_894124\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\Phillip\\AppData\\Local\\Temp\\arduino_build_894124\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "C:\\Users\\Phillip\\AppData\\Local\\Temp\\arduino_build_894124\\sketch\\Digital_Level_V3.ino.cpp" -o "C:\\Users\\Phillip\\AppData\\Local\\Temp\\arduino_build_894124\\sketch\\Digital_Level_V3.ino.cpp.o"
Digital_Level_V3:60:1: error: 'U8G2_SSH1106_128X64_NONAME_1_SW_I2C' does not name a type
U8G2_SSH1106_128X64_NONAME_1_SW_I2C u8g2(U8G2_R2, 5, 2);
^
C:\Users\Phillip\Documents\Arduino\Digital_Level_V3\Digital_Level_V3.ino: In function 'void setup()':
Digital_Level_V3:66:3: error: 'imu' was not declared in this scope
imu.settings.device.commInterface = IMU_MODE_I2C;
^
Digital_Level_V3:66:39: error: 'IMU_MODE_I2C' was not declared in this scope
imu.settings.device.commInterface = IMU_MODE_I2C;
^
Digital_Level_V3:73:3: error: 'u8g2' was not declared in this scope
u8g2.begin();
^
C:\Users\Phillip\Documents\Arduino\Digital_Level_V3\Digital_Level_V3.ino: In function 'void loop()':
Digital_Level_V3:92:7: error: 'imu' was not declared in this scope
if (imu.accelAvailable()) {
^
Digital_Level_V3:117:5: error: 'u8g2' was not declared in this scope
u8g2.firstPage();
^
Digital_Level_V3:120:20: error: 'u8g2_font_t0_11_tf' was not declared in this scope
u8g2.setFont(u8g2_font_t0_11_tf);
^
Digital_Level_V3:126:20: error: 'u8g2_font_helvB12_tf' was not declared in this scope
u8g2.setFont(u8g2_font_helvB12_tf);
^
C:\Users\Phillip\Documents\Arduino\Digital_Level_V3\Digital_Level_V3.ino: In function 'void showCredits()':
Digital_Level_V3:142:5: error: 'u8g2' was not declared in this scope
u8g2.setFont(u8g2_font_t0_11_tf);
^
Digital_Level_V3:142:18: error: 'u8g2_font_t0_11_tf' was not declared in this scope
u8g2.setFont(u8g2_font_t0_11_tf);
^
C:\Users\Phillip\Documents\Arduino\Digital_Level_V3\Digital_Level_V3.ino: In function 'void drawLegend()':
Digital_Level_V3:152:3: error: 'u8g2' was not declared in this scope
u8g2.drawLine(offset, 31, offset + 90, 31);
^
C:\Users\Phillip\Documents\Arduino\Digital_Level_V3\Digital_Level_V3.ino: In function 'void drawPoint(int, int)':
Digital_Level_V3:170:3: error: 'u8g2' was not declared in this scope
u8g2.drawCircle(xOffset, yOffset, 3, U8G2_DRAW_ALL);
^
Digital_Level_V3:170:40: error: 'U8G2_DRAW_ALL' was not declared in this scope
u8g2.drawCircle(xOffset, yOffset, 3, U8G2_DRAW_ALL);
^
C:\Users\Phillip\Documents\Arduino\Digital_Level_V3\Digital_Level_V3.ino: In function 'int setBatteryLevel(int)':
Digital_Level_V3:201:3: error: 'u8g2' was not declared in this scope
u8g2.drawFrame(116, 0, 11, 5);
^
Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI
exit status 1
'U8G2_SSH1106_128X64_NONAME_1_SW_I2C' does not name a type
no protocol: U8g2_Arduino/examples/full_buffer/GraphicsTest/GraphicsTest.ino

0
None
KCRobertspjessing

Reply 3 months ago

I'm not an Arduino expert, but I can offer a couple of suggestions.

First, make sure the necessary libraries are installed (I did not mention this in the software step, but I'll update it to call it out). It looks like you might be missing the u8g2 library. You can install it by selecting 'Sketch -> Include Library -> Manage Libraries...". In the dialog box that appears, search for 'U8g2'. You should see a library there by 'oliver' - click on the Install button to install this library.

The second library to install is the Sparkfun LSM9DS1 library (assuming that's the accelerometer chip you're using). You can get instructions on how to do this by going to: https://learn.sparkfun.com/tutorials/lsm9ds1-break...

Next, try compiling the sketch without uploading. This will make sure it's a software issue, not a connectivity issue or hardware issue.

Let me know if this solves your issues.

0
None
pjessingKCRoberts

Reply 3 months ago

Thank you for your reply, it helped tremendously! Thank you for taking the time and not only writing this instructable, but helping us who need a little push.
I was able to load the sketch and have a working level....mostly I think. I don't feel I have the correct "Sparkfun LSM9DS1". Here is the list of "contributed libraries" that I have. I know just enough about electrics and soldering to do a pretty decent job, but when it comes to the software I am lost.

When I try to calibrate it(I have it on a perfectly flat board) by changing the value in the sketch to the number it shows on the screen(pictured)...which is 2 degrees, when I reload the sketch it shows 177 degrees and not 0. So then I changed it to -2 and it showed 182 degrees. I have tried different numbers but still can't get it to 0. Any thoughts? Am I changing the wrong value?

Level.jpeg2018-12-29 11.23.30 (Large).jpgLevel1.jpeg
0
None
KCRobertspjessing

Reply 3 months ago

Looks like your library is working, but I must have an error in my code. I'm going to have to take a deeper look at it with mine to try and figure it out. Nice job on the 3d print and the assembly!

0
None
KCRobertspjessing

Reply 3 months ago

I've taken a look at the code and didn't see anything obvious. Unfortunately, I don't have access to my debugging tools just yet as I've been traveling. I'll dig into this more next week. Apologies for the delays.

0
None
Phil_S

4 months ago

Nice project. I've fitted a number of kitchens now, working alone.
This can mean that you are trying to fit a cabinet to level it and trying to watch a spirit level at the same time.
I invested in an electronic level that emits a continuous tone once you have the surface level in one axis. This of course is just one axis so you have to repeat for another axis or even a third. Before someone suggests it, I do use a crosshair laser level as well for initial setting up.
You could add some features like longer bars to span greater distances or get better accuracy or add a laser to get a visual line to work with.
The only time I have had to set up something using a bullseye level (circular bubble) was an expensive vinyl record turntable. Plenty of applications though.

1 reply
0
None
KCRobertsPhil_S

Reply 4 months ago

Great observations - thanks! Interesting thought to add a laser.

0
None
dlf.myyta

Question 4 months ago on Introduction

Nice project. One question though, I thought the Arduino Nano's Vin required 7-12v. Doesn't the tp4056 charger module only output ~4.2v max? How did you make this work without using a dc-dc boost converter?
Thanks!

2 answers
0
None
KCRobertsdlf.myyta

Answer 4 months ago

I'll defer to ozjon's research, here. You're correct that the TP4056 charger with a 3.7V Li-Po battery outputs around 4V. However, this appears to be enough to operate the components I've put together in this tutorial.

0
None
ozjondlf.myyta

Answer 4 months ago

Google the Nano 3 Schematic and the 328 processor data sheet and all will be revealed!

With the Nano's 16Mhx xtal the 328 should work OK down to about 3V on the Vcc pin

0
None
ozjon

4 months ago

It looks good and quite handy for many applications,
But I suspect that it's accuracy and repeatability would be a bit questionable.

The bottom of the case needs to be absolutely flat and remain that way - A hot-printed case probably needs to be stress releived by heating then slowly cooling after printing? Adding 3 well spaced "pimple" (mini feet) would improve it's repeatability.

Then there is the precision and repeatability of the magnetometer to consider - some of that you can calibrate out. but not all of it.

Nevertheless a neat interesting product!
Congratulations!

1 reply
0
None
KCRobertsozjon

Reply 4 months ago

Thanks for the feedback - I suspect you're right. As I stated in the tutorial, I did this primarily as a learning experience and this has not had any rigorous testing to validate its accuracy. In my limited testing, it has been both accurate and repeatable - but I agree that may not hold up over the long run.

The 3d printing introduces the most variability - the quality of the printer, the quality of the filament, etc. If the print warps on the bed during printing, it is affected - and over time it will not hold up as well as a metal case.

I would expect the accelerometer to be accurate, but I've not used it enough to verify that. Mounting it level is critical, although as you noted calibration can be used to offset some of that.

0
None
warhawk8080

4 months ago

Awesome!!! Is the case large enough to fit an 18650 battery in it?
Such a cool project...any idea on it's accuracy?

1 reply
0
None
KCRobertswarhawk8080

Reply 4 months ago

Thanks! Should be enough room for an 18650 battery - the space in the case for the battery is about 80mm x 40mm, so it should fit. As to accuracy - should be very accurate - I'm using the Sparkfun library for the accelerometer to obtain the angles (although I do round them to be integers). I just can't speak to the accuracy other than anecdotal since I have run any controlled measurements.

0
None
Penolopy Bulnick

4 months ago

Nice job on this! I like the way it looks in the nice little 3D print box :) Did you design that in Fusion 360?