Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

Arduino-based walking steps and distance calculator

By Nikhil Agnihotri

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:


  • Arduino-based electronic leveling device
  • pollution monitoring
    Arduino-based portable pollution monitor with OLED display

  • Insight into Arduino: Beginner’s Guide

  • Designing an Arduino-based EMG monitor

  • Arduino-based token display board controller

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

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.

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!


Featured Tutorials

  • Designing Gate Driver Circuit and Switching Mechanism for Modified Sine Wave Inverter – (Part 9/17)
  • Completing Modified Sine Wave Inverter Design with Full Bridge Circuit and Step Up Transformer – (Part 10/17)
  • Designing an Offline UPS – Part (12 /17)
  • How to reduce Switching Time of a Relay – (Part 15/17)
  • Testing MOSFET – (Part 16/17)
  • Driving High Side MOSFET using Bootstrap Circuitry – (Part 17/17)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • Renesas to demonstrate first working silicon based on the Arm Cortex-M85 processor
  • STMicroelectronics releases first automotive IMU with embedded machine learning
  • Infineon offers DC-DC controller for full LED headlamps without a microcontroller
  • Vishay launches new high-precision, thin-film wraparound chip resistor
  • STMicroelectronics’ common-mode filters ensure signal integrity in serial interfaces

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd ldr led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Capacitive Switches
  • CSI-2 FIFO or Line buffer?
  • Temperature sensor readout
  • What is the function of the long stub?
  • Circuit Performance Exploration

RSS Electro-Tech-Online.com Discussions

  • Opamp ciruit
  • Audio equalizer
  • Background of Members Here
  • software PWM
  • SPI Questions
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 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 | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering