A custom-built pedometer can offer advantages over commercial fitness trackers: complete privacy over your data, customizable features, and the satisfaction of building your own wearable technology. This comprehensive guide will walk you through creating a portable, accurate step counter using components like Arduino Nano and BMI160 to display the step count on the OLED display.
Table of Contents
What Makes This Pedometer Special
This DIY pedometer leverages the BMI160’s built-in step-counting algorithm—a powerful feature often overlooked in hobbyist projects. Unlike basic accelerometer implementations that require complex custom algorithms, the BMI160 handles the step detection internally, providing reliable counts even during varied walking patterns. Our design focuses on:
- Accuracy: The BMI160’s dedicated step-counting feature outperforms basic DIY solutions
- Portability: Compact enough to carry in your pocket or attach to clothing
- Battery efficiency: Designed for all-day use with a rechargeable lithium-ion battery
- Clear feedback: Real-time step count displayed on a bright OLED screen
- Simplicity: Easy-to-use interface with minimal controls
Components You’ll Need
- Arduino Nano (or compatible board)
- BMI160 6-axis Accelerometer/Gyroscope module
- 0.96″ I2C OLED display (128×64 resolution)
- 3.7V Lithium-ion battery (600-1000mAh recommended)
- TP4056 Li-ion charging module
- MT3608 boost converter module (to step up 3.7V to 5V)
- Slide switch (SPDT)
- Momentary push button
- Wires and headers
BMI160 Overview: Compact 3-Axis Accelerometer & Gyroscope Sensor
The BMI160 is a compact and power-efficient 16-bit Inertial Measurement Unit (IMU) that combines both a 3-axis accelerometer and a 3-axis gyroscope into a single, tiny package. Despite its small size, it delivers high-performance motion sensing, making it ideal for modern applications where space, power, and precision matter.

Key Features and Applications
This sensor is engineered to provide accurate motion tracking and orientation data, which is essential in areas like:
- Augmented and Virtual Reality (AR/VR)
- Indoor navigation systems
- Fitness trackers and wearables
- Smart gaming controllers and mobile devices
One of its standout features is its support for gesture recognition, motion detection, and step counting, all of which are handled onboard, reducing processing load on your microcontroller.
Communication Interfaces
The BMI160 is compatible with both I²C and SPI communication protocols, allowing it to integrate smoothly with most microcontrollers or embedded systems. For complete technical specifications, you can refer to the official Bosch BMI160 datasheet.
Step Counting with BMI160 – Built-In and Efficient
One of the BMI160’s biggest advantages over older sensors like the MPU6050 is its dedicated step counting capability. Here’s how it works and why it’s a game-changer:
1. Built-in Step Counter Algorithm
Unlike legacy sensors that only provide raw accelerometer and gyro data (leaving the rest to your code), the BMI160 has a built-in digital signal processor (DSP) that takes care of step counting for you. It actively filters and processes the motion data to detect step-like patterns.
2. Smart Detection Logic
The internal step counting engine uses threshold-based detection and debounce logic:
- It identifies the rhythmic motion of walking by analyzing the acceleration waveforms.
- Adjustable thresholds help fine-tune sensitivity.
- Debounce logic ensures only distinct steps are counted—avoiding false triggers caused by noise or random movement.
3. Easy-to-Access Registers
Every time the sensor detects a step, it increments a built-in step counter register, typically found at memory addresses 0x78 and 0x79. You can read this data directly using either I²C or SPI, depending on your setup.
4. Simplified Development
Thanks to the BMI160’s internal step detection engine, you don’t need to write complex algorithms to track steps. Just read the step count register—and you’ve got yourself a fully functional pedometer in minutes!
Circuit diagram to build DIY Pedometer with Arduino and BMI160
Connect all the components according to the below circuit diagram.

The wiring is straightforward, with the BMI160 and OLED both communicating over I2C:
- Power System:
- Connect battery to TP4056 module input
- TP4056 output connects to MT3608 input through the slide switch
- MT3608 output connects to Arduino Nano VIN pin
- BMI160 Connections:
- VCC → Arduino 3.3V
- GND,SAO → Arduino GND
- SCL → Arduino A5
- SDA → Arduino A4
- INT1 → Arduino D2 (for interrupt-based step counting)
- OLED Display:
- VCC → Arduino 5V
- GND → Arduino GND
- SCL → Arduino A5
- SDA → Arduino A4
- Reset Button:
- Connect between Arduino D7 and GND (no need of 10k resistor as we are using internal pull up)
Coding and Uploading
After connecting all the components, its time to upload the code to the Arduino using Arduino IDE. Connect Arduino to PC where Arduino IDE is installed and then install the required libraries listed below in the Arduino IDE library manager or download from the link given and extract them in Arduino libraries folder. If you are new check out How to Install Arduino IDE on Your PC
- BMI160 library (Download from here: link)
- Adafruit SSD1306 library
- Adafruit GFX library
#include <Wire.h>
#include <BMI160Gen.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// OLED display definitions for a 0.96" (128x64) display
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1 // No dedicated reset pin
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// Sensor parameters:
const int BMI160_I2C_ADDRESS = 0x68; // BMI160 I2C Address
const int INTERRUPT_PIN = 2; // Digital pin used for sensor interrupt (D2 on Nano)
// Reset button pin:
const int RESET_BUTTON_PIN = 7; // Reset button connected to D7 on Arduino Nano
// Optional: Interrupt callback (for future embellishments)
void stepInterrupt() {
// This callback is triggered on an interrupt (e.g., double-tap).
// The built-in step counter works independently.
}
void setup() {
Serial.begin(9600); // Standard baud rate for Arduino Nano
// Set the reset button pin with internal pullup (Nano doesn't have pulldown)
pinMode(RESET_BUTTON_PIN, INPUT_PULLUP);
// Initialize the OLED display
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Typical OLED I2C address is 0x3C
Serial.println(F("SSD1306 allocation failed"));
while (1);
}
display.clearDisplay();
display.display();
// Initialize BMI160 sensor in I2C mode
if (!BMI160.begin(BMI160GenClass::I2C_MODE, BMI160_I2C_ADDRESS, INTERRUPT_PIN)) {
Serial.println("BMI160 initialization failed!");
while (1);
}
BMI160.attachInterrupt(stepInterrupt);
// --- Auto-Calibration for Improved Accuracy ---
// (Ensure the sensor is stationary during calibration)
BMI160.autoCalibrateGyroOffset();
BMI160.autoCalibrateXAccelOffset(0); // X-axis to 0g
BMI160.autoCalibrateYAccelOffset(0); // Y-axis to 0g
BMI160.autoCalibrateZAccelOffset(1); // Z-axis to +1g (gravity)
// Set accelerometer range to 2g (for higher sensitivity in step detection)
BMI160.setFullScaleAccelRange(BMI160_ACCEL_RANGE_2G);
// --- Configure the Built-In Step Counter ---
// Options: BMI160_STEP_MODE_NORMAL, SENSITIVE, or ROBUST
BMI160.setStepDetectionMode(BMI160_STEP_MODE_NORMAL);
BMI160.setStepCountEnabled(true);
BMI160.resetStepCount();
// Initial OLED decoration
display.clearDisplay();
// Draw border
display.drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SSD1306_WHITE);
// Header text in small font
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
String header = "BMI160 STEP COUNTER";
int headerWidth = header.length() * 6; // Approximate width at size 1
int headerX = (SCREEN_WIDTH - headerWidth) / 2;
display.setCursor(headerX, 3);
display.println(header);
// Draw a horizontal separator
display.drawLine(0, 15, SCREEN_WIDTH, 15, SSD1306_WHITE);
display.display();
delay(1000);
}
void loop() {
// Check the reset button. When pressed, reset the step counter.
// Note the logic is inverted from ESP32 version (LOW when pressed with pullup)
if(digitalRead(RESET_BUTTON_PIN) == LOW) {
BMI160.resetStepCount();
Serial.println("Counter reset!");
// Visual feedback on display
display.clearDisplay();
display.drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SSD1306_WHITE);
display.setTextSize(1);
display.setCursor(25, 30);
display.println("Step Count Reset!");
display.display();
delay(500); // simple debounce delay
// Wait for button release
while(digitalRead(RESET_BUTTON_PIN) == LOW);
delay(50); // Additional debounce
}
// Read the step count from the BMI160 sensor
uint16_t currentSteps = BMI160.getStepCount();
// Print the step count to Serial Monitor
Serial.print("Steps: ");
Serial.println(currentSteps);
// Clear the display before redrawing
display.clearDisplay();
// Draw a border around the screen
display.drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SSD1306_WHITE);
// --- Header Section ---
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
String header = "BMI160 STEP COUNTER";
int headerWidth = header.length() * 6;
int headerX = (SCREEN_WIDTH - headerWidth) / 2;
display.setCursor(headerX, 3);
display.println(header);
display.drawLine(0, 15, SCREEN_WIDTH, 15, SSD1306_WHITE);
// --- Step Count Section ---
String stepText = String(currentSteps);
display.setTextSize(3);
int stepWidth = stepText.length() * 18; // Approximate width at size 3
int stepX = (SCREEN_WIDTH - stepWidth) / 2;
display.setCursor(stepX, 25);
display.println(stepText);
// --- Footer Section ---
display.setTextSize(1);
String footer = "Steps";
int footerWidth = footer.length() * 6;
int footerX = (SCREEN_WIDTH - footerWidth) / 2;
display.setCursor(footerX, 55);
display.println(footer);
display.display();
delay(200); // Refresh display every 200 ms
}
// DIY PEDOMETER USING ARDUINO AND BMI160 BY CIRCUITSCHOOLS.COM
Test the functionality
- Step detection works
- Display updates properly
- Reset button functions correctly
Calibration and Tuning
The BMI160 has three sensitivity modes for step counting:
- Normal mode: Balanced sensitivity for typical walking
- Sensitive mode: Better for slow walking or light steps
- Robust mode: Reduces false positives during activities like driving
To adjust the sensitivity, modify this line in the code:
bmi.setStepDetectionMode(BMI160_STEP_MODE_NORMAL);
Replace BMI160_STEP_MODE_NORMAL with either BMI160_STEP_MODE_SENSITIVE or BMI160_STEP_MODE_ROBUST based on your preference.
Final Assembly
- Prepare the enclosure:
- Cut openings for the display, buttons, and USB charging port.
- Consider adding ventilation holes if needed.
- Mount the components:
- Secure the circuit board inside the enclosure.
- Ensure the OLED display aligns with its opening.
- Position the battery securely.
- Final testing:
- Verify all functions work with the enclosure closed.
- Test battery life under normal usage conditions.
Build Your Professional-Grade Pedometer with PCBWay’s Precision PCBs!
Turn your DIY step counter concept into a sleek, reliable wearable with PCBWay – your trusted partner for high-quality PCB fabrication and assembly!
Our Arduino Nano + BMI160 pedometer project combines medical-grade accuracy with consumer-friendly design, but none of it would be possible without a robust PCB. Here’s why PCBWay is the secret ingredient:
- Optimized Layouts: Their 4-layer FR4 boards ensure noise-free communication between the BMI160’s 16-bit IMU and Arduino Nano, eliminating false step counts.
- Ultra-Compact Design: PCBWay’s 0.8mm substrate and 3oz copper traces let you shrink the entire circuit into a smaller footprint!
- Battery-Ready: Choose their gold-plated pads for stable Li-ion charging connections, even after 10,000+ flex cycles.
Why Engineers Trust PCBWay for Wearables:
- 24-Hour Turnaround: Prototype your pedometer PCB in a day!
- Advanced Options: Matte black solder mask (for stealthy looks) and ENIG finish (for corrosion resistance).
- Full Assembly: Let PCBWay populate SMD components like the BMI160’s 2.5mm² chip—no microscope required!
Special Offer: Sign up now to get 5$ coupon for free.
Start Your Journey: Upload your Gerber files to PCBWay.com and transform this open-source pedometer into a market-ready product. From hobbyists to startups, PCBWay fuels innovation—one step at a time.
Extending the Project
This basic pedometer can be enhanced with additional features:
- Real-time clock: Add a DS3231 module to track time and date alongside steps.
- Data logging: Incorporate an SD card module to save step history.
- Wi-Fi and Bluetooth connectivity: Update Arduino with ESP32 module to sync data with your smartphone over WIFI and Bluetooth.
- Battery management: Monitor battery voltage and convert into percentage and display in OLED.
- Step goal tracking: Add visual indicators when you reach daily step targets.
Troubleshooting Common Issues
- Inaccurate step counting:
- Try different sensitivity modes
- Ensure the BMI160 is mounted securely without vibration
- Place the device in a consistent position when walking
- Poor battery life:
- Implement deeper sleep modes when inactive
- Reduce display brightness or update frequency
- Check for shorts or unnecessary power consumption
- Display not working:
- Verify I2C address (some displays use 0x3C, others use 0x3D)
- Check connections and voltage levels
- Try a different display to rule out hardware failure
- BMI160 communication errors:
- Keep I2C wires short and away from noise sources
- Add pull-up resistors (4.7kΩ) to SDA and SCL if not already present
- Verify your module’s pinout matches the connections
Conclusion
This DIY pedometer project demonstrates how to leverage specialized sensor features to create a practical fitness tracking device. The BMI160’s built-in step counting algorithm simplifies the development process while providing reliable results. With a few basic components and moderate soldering skills, you can build a functional pedometer that rivals commercial options in accuracy.
The completed device is not only useful for tracking your daily activity but also serves as an excellent platform for learning about embedded systems, sensor integration, and power management for portable electronics. As you become more comfortable with the basic implementation, consider adding the suggested enhancements to create a truly personalized fitness tracking solution.
