Skip to content

A step counter written in Rust with an accelerometer and ESP32

Notifications You must be signed in to change notification settings

maurogull/pedometer-rust-esp32

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pedometer-rust-esp32

Some time ago, I started running and my partner gave me a smart watch that allows me to measure my workouts. From the very beginning, I was intrigued by the algorithm for counting steps (pedometer). So, I bought an accelerometer and tried to replicate it, using an ESP32 and an OLED display that I already had.

In an attempt to replicate the behavior of the watch, this implementation connects to WiFi, updates the time via NTP, and then counts steps by analyzing the accelerometer signal. Then it displays the current time and the steps, cycling between them.

Hardware:

  • SoC is Espressif ESP-WROOM-32 (dev board also called NodeMCU-32s)
  • OLED display is SSD1306
  • Accelerometer is MPU6050
  • Flash used: 1 of 4 MB

ESP32 pedometer project ESP32 pedometer protoboard view

Counting the steps

I only used the information from the X-axis because it's enough. Basically, samples are taken every 100 milliseconds, and it tries to detect when the data changes its upward or downward trend, attempting to find the inflection points. From one peak to another, we assume a step has been taken. Therefore, we can deduce the steps by counting the number of "peaks".

Sine signal pedometer

Demo video

Youtube demo preview

Here you can find a live demonstration: Realtime demo - YouTube video

Installing dev environment

The reference is https://docs.esp-rs.org/book/installation/index.html

For initiating a new project you do:

Remember that you should enable the board flashing by pressing a button on your dev board. I can't provide further details because it depends on your board. There are a lot of versions in the wild.

The flash utility creates an output like this when you do cargo run: Flashing ESP32 screenshot

About

A step counter written in Rust with an accelerometer and ESP32

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages