Projects / Ramp slope checker

Ramp slope checker

Beginner45 minGuided buildReviewed

Build it step by step

0 of 6 done
  1. NANO

    Wire the sensor and display

    Connect both on the I2C bus.

  2. NANO

    Level it

    Place the board on a surface you know is level and let it set its zero.

  3. NANO

    Check a known slope

    Prop one end of a board by 1 cm per 12 cm and see about 8 %.

  4. NANO

    Mark the X axis

    Stick an arrow on the case showing the direction it measures.

  5. NANO

    Test a real ramp

    Place it along the ramp's length with the arrow up the slope.

  6. NANO

    Log checks

    Write the reading and place in a notebook for each site.

In short

How do you build a ramp slope checker?

An IMU measures the slope of a ramp and says if it meets the common 1 in 12 accessibility guidance. You need Arduino Nano, MPU6050 IMU and SSD1306 OLED Display. It takes 6 steps and about 45 minutes.

Level
Beginner
Time
About 45 min
Parts
3

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
MPU6050 VCC, GNDNano 5V, GNDPower (module has a regulator)
MPU6050 SDA, SCLNano A4, A5I2C
OLED SDA, SCLNano A4, A5I2C, same bus
OLED VCC, GNDNano 5V, GNDPower

Code

Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). U8g2 is the only library needed. Mount the MPU6050 so its X axis points up the slope. A slope of 1 in 12 is 8.33 % or about 4.8 degrees and is common accessibility guidance, but check the figures in your own building code. Treat the reading as a quick check, not a certified survey.

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Wire.h>
#include <U8x8lib.h>

U8X8_SSD1306_128X64_NONAME_HW_I2C oled(U8X8_PIN_NONE);
const byte MPU = 0x68;
float offsetDeg = 0;
const float LIMIT_PERCENT = 8.33;           // 1 in 12; check the guidance that applies to you

void readAccel(float &ax, float &ay, float &az) {
  Wire.beginTransmission(MPU); Wire.write(0x3B); Wire.endTransmission(false);
  Wire.requestFrom(MPU, (byte)6);
  int16_t x = Wire.read() << 8 | Wire.read();
  int16_t y = Wire.read() << 8 | Wire.read();
  int16_t z = Wire.read() << 8 | Wire.read();
  ax = x / 16384.0; ay = y / 16384.0; az = z / 16384.0;    // in g at the default range
}

float angleDeg() {                           // slope along the sensor's X axis
  float sum = 0;
  for (byte i = 0; i < 50; i++) {
    float ax, ay, az; readAccel(ax, ay, az);
    sum += atan2(ax, sqrt(ay * ay + az * az)) * 180.0 / PI;
    delay(5);
  }
  return sum / 50.0;
}

void setup() {
  Wire.begin();
  Wire.beginTransmission(MPU); Wire.write(0x6B); Wire.write(0); Wire.endTransmission(true);   // wake up
  oled.begin();
  oled.setFont(u8x8_font_chroma48medium8_r);
  oled.drawString(0, 2, "Place flat...");
  delay(3000);
  offsetDeg = angleDeg();                    // flat reference
}

void loop() {
  float deg = angleDeg() - offsetDeg;
  float pct = tan(deg * PI / 180.0) * 100.0;
  char b[17], v[8];
  dtostrf(deg, 5, 1, v);  snprintf(b, sizeof b, "Angle %s   ", v); oled.drawString(0, 1, b);
  dtostrf(pct, 5, 1, v);  snprintf(b, sizeof b, "Slope %s %% ", v); oled.drawString(0, 3, b);
  oled.drawString(0, 5, fabs(pct) <= LIMIT_PERCENT ? "Within 1:12   " : "Too steep     ");
  delay(300);
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Flat surfaceAbout 0 degrees
Prop 1 cm per 12 cmAbout 8 percent
Steeper rampToo steep appears
Rotate across the slopeReading drops towards zero

If it does not work

Reads nothing

Check the address 0x68 and the I2C wiring.

Does not zero

Keep it still for the first 3 seconds.

Angle seems backwards

Turn the sensor round so X points up the slope.

Noisy

Keep it still while reading and avoid vibrations.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the ramp slope checker?

Arduino Nano, MPU6050 IMU and SSD1306 OLED Display.

How long does the ramp slope checker take to build?

About 45 minutes for a beginner maker, in 6 steps.

How do I know the ramp slope checker works?

Flat surface: About 0 degrees. Prop 1 cm per 12 cm: About 8 percent. Steeper ramp: Too steep appears.

Reads nothing: what should I check?

Check the address 0x68 and the I2C wiring.

Does not zero: what should I check?

Keep it still for the first 3 seconds.

Angle seems backwards: what should I check?

Turn the sensor round so X points up the slope.

Noisy: what should I check?

Keep it still while reading and avoid vibrations.