Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Arduino-based walking steps and distance calculator

By Nikhil Agnihotri July 23, 2023

A very common feature in Android and iOS fitness apps is calculating the number of steps the user walks and the distance he covers. These apps calculate the number of steps walked by the user either using GPS location and manipulating the geospatial data or by monitoring the acceleration vector of the device using an accelerometer sensor.

In this project, we have designed a similar walking steps calculator on the Arduino platform. The method used in this project is monitoring the acceleration vector of the device. For this purpose, the ADXL345 accelerometer is interfaced with the Arduino. The number of steps walked by the user and the distance covered by him are displayed on an OLED screen. The logic used in this project can be easily replicated in a smartwatch application. You can easily port the code logic to any other language as it simply reads the data from the accelerometer sensor and manipulates that data to detect the user’s movement.

Components required

  1. Arduino UNO x1
  2. ADXL345 Accelerometer Sensor x1
  3. SSD1306 OLED display x1
  4. Connecting wires/Jumper wires

Circuit connections
For designing this project, the ADXL345 accelerometer sensor and SSD1306 OLED are interfaced with the Arduino. To do this, connect its GND and VCC pins to Arduino’s ground and 3.3V out pins. Then connect the SDA and SCL pins of the accelerometer sensor to the SDA and SCL pins on the I2C  port of the Arduino.

In this project, a 7-pin SSD1306 OLED module is interfaced to Arduino UNO. The module is connected to the Arduino as follows.

Circuit Diagram of Arduino based Pedometer

Circuit Diagram of Arduino-based Pedometer

Arduino sketch


How it works
When the device is powered on, the SSD1306 OLED display is initialized, and the logo of “EEWORLDONLINE” and the device name “Steps Counter” are flashed on the screen. The initial number of steps is displayed to be 0, and the distance covered is also displayed as 0. Now, all the user needs to do is keep the device on their person.

The device continuously monitors its acceleration vector with the help of the ADXL345 accelerometer sensor. When the user walks, there is a change in the acceleration vector. When the user steps a foot forward, the immediate change in acceleration vector goes negative. As the user steps the other foot balancing on the previous foot, the immediate change in acceleration vector goes positive.

Average acceleration values are calculated as the device is powered on and initial messages are flashed on the screen. The average values are also derived by taking the mean of 50 consecutive readings from the ADXL345 accelerometer. These average values for the acceleration of the device in the x-, y-, and z-axis serve as the reference point.

After the initial setup is complete, the device again calculates the acceleration in x-, y-, and z-axis 50 consecutive times and derives an average of those values. The acceleration vector of the device is calculated by taking the square root of the difference of current acceleration values compared to reference values.

After a delay of 250  milliseconds, the device again calculates the acceleration in x-, y-, and z-axis for 50 consecutive times and derives the average of those values. The acceleration vector of the device is calculated once again at an interval of 250 ms by taking the square root of the difference of current acceleration values compared to reference values. The difference between the acceleration vector now and the acceleration vector 250 ms before is calculated, and if the difference is more than 0.05, a step is incremented. The value of distance covered is calculated by multiplying the number of steps by one foot or 0.3048 meters, assuming that an average step is one foot long.

The number of steps and distance covered are updated on the OLED screen, with a delay of 400 ms. The process of calculating the difference between two consecutive acceleration vectors of the device at an interval of 250 ms is continued throughout to monitor the user’s movement.

It should be noted that the delay of 250 ms between the calculation of two consecutive averaged acceleration vectors and the difference of 0.05 is obtained after careful calibration of the device.

Check out this link to learn more about how the ADXL345 accelerometer communicates with Arduino over the I2C protocol.

To learn more about interfacing SSD1306 OLED with Arduino, check out this link.

You should note that Arduino’s reset button acts as a reset button for the device and reset the number of steps and distance covered to zero.

The code
The code begins by importing wire.h for I2C communication with the ADXL345 accelerometer sensor and SPI.h for communication SSD1306 OLED display. The Adafruit libraries for working with OLED display are imported and the constants required for OLED interfacing and defined parameters. An object display is initialized for the SSD1306 class. The bitmap for the logo of EEWORLDONLINE is stored in Arduino’s PROGMEM and is converted to an array object. The variables to store average, current, and immediately next acceleration values are declared. A variable to store the number of steps is declared.

In the setup() function, three different functions are called. The ssd1306_init() is called to initialize the SSD1306 OLED display and flash initial messages onto it. The adxl345_init() is called to initialize the acceleration sensor. The read_av_acc() function is called to calculate reference acceleration values when the device is at rest.

In the loop() function, the acceleration vector is calculated twice at a gap of 250 ms, and if the difference between two values of greater than 0.05, one step is incremented. The number of steps and distance covered are updated to OLED display.

Result

Arduino based Pedometer using ADXL345 and SSD1306

Arduino based Pedometer using ADXL345 and SSD1306

Demonstration Video

 

You may also like:

  • battery types
    What are the different battery types for specific applications?

  • Arduino-based token display board controller
  • pollution monitoring
    Arduino-based portable pollution monitor with OLED display

  • Arduino-based electronic leveling device

  • Insight into Arduino: Beginner’s Guide

  • Designing an Arduino-based EMG monitor

Filed Under: Arduino Projects, Electronic Projects, Sensors, Tutorials, Video
Tagged With: Arduino, Arduino ADXL345, Arduino pedometer, Arduino pedometer adxl345, Arduino projects, Arduino walking distance calculator, Arduino Walking Steps Calculator
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Safe Current and Power Density Limits in PCB Copper(in A/m² and W/m³) simulation
  • The Analog Gods Hate Me
  • Help with hall effect sensors for a milwuakee impact driver
  • How to find the resonance frequency and impedance of a planar spiral coil in HFSS?
  • Diode recovery test Irrm timing.

RSS Electro-Tech-Online.com Discussions

  • Raise your hand if your car had one of these:
  • Simple LED Analog Clock Idea
  • Kawai KDP 80 Electronic Piano Dead
  • Tektronix 2235 channel 1 trace unstable
  • How to make string LEDs?

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • Tria modules integrate edge AI processing with multi-core processors
  • pSemi introduces RF switch with 52 dBm PMAX,PEAK and 90-dBm IIP3 linearity
  • XP Power launches 1.3 kW power supply with 58.9 W/cm³ density
  • How to enable Wi-Fi provisioning in ESP32-based IoT products
  • Amphenol RF introduces FAKRA to SMA adapters with 4 GHz operating frequency

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe