Modern fitness systems are rapidly shifting toward smart, automated, and interactive workout solutions. Accurate repetition counting, real-time feedback, and user engagement are essential for professional gyms, home workout devices, and commercial fitness products.
In this project, we developed a Smart Gym Exercise Repetition Counter using ESP32, designed to automatically count exercises such as pushups, squats, and similar repetitive movements. The system integrates an ultrasonic distance sensor for motion detection, a Nextion touchscreen display for user interaction, a DFPlayer Mini module for audio feedback, and a WS2812B NeoPixel LED strip for visual status indication.
This project is a strong example of Product Design and Development Services, combining embedded firmware, HMI design, sensor-based motion analysis, audio-visual feedback, and smart logic into a commercially viable fitness system.

Project Objective || Smart Gym Exercise Counter
The key objectives of this smart fitness project are:
- Automatically detect and count exercise repetitions
- Provide accurate feedback for correct and incorrect movements
- Offer a professional touchscreen-based user interface
- Enhance user motivation using sound and NeoPixel lighting
- Demonstrate a scalable custom electronics product design
Smart Gym Exercise Counter System Overview
The ESP32 acts as the central processing unit, coordinating all system components:
- Ultrasonic sensor measures body movement distance
- ESP32 processes distance data and detects valid repetitions
- Nextion display shows live distance, repetition counts, sets, and results
- DFPlayer Mini provides voice or sound feedback
- NeoPixel LEDs indicate success, failure, and system states
Components Used in ESP32 Based Smart Gym Exercise Counter
- ESP32 Development Board
- Nextion Touch Display
- Ultrasonic Distance Sensor
- DFPlayer Mini MP3 Module
- WS2812B NeoPixel LED Strip
- Push Button
- Power Supply and Level Conversion Circuit
Check Out: Our ESP32 Based Custom Projects
Circuit Diagram of ESP32 with Nextion Touch LCD, Ultrasonic Sensor, DFPlayer Mini, and NeoPixel LED Strip

Ultrasonic Sensor Interface
The ultrasonic sensor is connected to the ESP32 using dedicated trigger and echo pins. It continuously measures the distance between the user and the sensor, which changes as the user moves during exercises.
This distance variation is the core input for repetition detection.
Nextion Display Interface
The Nextion display communicates with the ESP32 via serial communication. It is used for:
- Selecting exercise modes
- Displaying real-time distance
- Showing repetition counts
- Displaying failed reps and total reps
- Navigating between countdown, counter, rest, and result screens
Using a Nextion display offloads graphical processing from the ESP32, which is a best practice in product-grade embedded systems.
Related internal resource:
Nextion Display with Arduino and ESP32
DFPlayer Mini Audio System
The DFPlayer Mini module provides audio feedback for:
- Device ON and OFF events
- Countdown start
- Successful repetition confirmation
- Failed repetition alerts
- Rest and result page notifications
Audio feedback significantly improves user engagement and is commonly used in commercial fitness electronics.
Related internal resource:
DFPlayer Mini Arduino Audio Projects
NeoPixel LED Feedback
A WS2812B NeoPixel LED strip is used for visual feedback:
- Green color indicates successful repetitions
- Red color indicates failed repetitions
- LEDs can be expanded for animations or status indicators
This feature enhances usability and makes the system visually intuitive.
ESP32 Code for Smart Fitness Counter
int Device_ON_Sound = 5;//0005
int Device_OFF_Sound = 1;
int SUCCESS_Rep_Sound = 1;
int FAILURE_Rep_Sound = 2;
int Rest_Page_Sound = 2;
int Countdown_Page_Sound = 2;
int Counter_Page_Sound = 2;
int Result_Page_Sound = 2;
int O1_Upper_distance = 30, O1_Lower_distance = 5;//cm
int O2_Upper_distance = 35, O2_Lower_distance = 5;
int O3_Upper_distance = 40, O3_Lower_distance = 5;
int O4_Upper_distance = 45, O4_Lower_distance = 5;
int O5_Upper_distance = 50, O5_Lower_distance = 5;
Functionality of Custom Fitness Electronics System
✷System Initialization Logic
During startup, the ESP32:
- Initializes serial communication with the Nextion display
- Initializes Serial2 for DFPlayer Mini communication
- Sets ultrasonic sensor and button pin modes
- Initializes NeoPixel LED strip
- Sets default sound tracks and distance thresholds
This structured startup routine reflects professional firmware design standards.
✷Exercise Mode Selection Logic
Using the Nextion display, users can select predefined exercise modes. Each mode sets specific:
- Upper distance limit
- Lower distance limit
These limits define valid motion ranges for different exercises or body heights.
✷Distance Measurement and Filtering
The ESP32 continuously triggers the ultrasonic sensor and calculates distance using pulse timing. Only valid distance ranges are processed to prevent false detections.
Distance is also mapped for graphical representation on the Nextion display.
✷Smart Repetition Detection Algorithm
The repetition logic uses multiple state flags:
- Upper position detection
- Lower position detection
- Mid-range validation
- Direction tracking
A repetition is counted only when the user completes a full and valid movement cycle, ensuring accuracy and eliminating false counts.
✷Success and Failure Detection
If a full movement cycle is completed correctly:
- Repetition count is incremented
- Success sound is played via DFPlayer Mini
- NeoPixel LED turns green
- Success image is displayed on the Nextion screen
If movement does not meet criteria:
- Failed repetition is counted
- Failure sound is played
- NeoPixel LED turns red
- Failure image is displayed
This logic simulates trainer-style feedback in a smart gym system.
✷Set and Rest Management
The system supports multiple workout sets:
- Set 1
- Set 2
- Set 3
After each set:
- Results are displayed
- A rest page is shown
- Audio cues notify the user
This makes the system suitable for structured workout routines.
Button Control Logic
A single physical button is used for:
- Short press to start or confirm actions
- Long press to stop or reset the device
This reduces hardware complexity while maintaining usability.
Key Features of the Smart Gym System
- ESP32-based high-performance processing
- Accurate ultrasonic-based repetition detection
- Professional Nextion touchscreen interface
- Audio feedback using DFPlayer Mini
- NeoPixel LED visual status indication
- Multi-set workout tracking
- Designed as a commercial-ready smart system
Applications of Custom Fitness Tracker System
- Smart gym equipment
- Home fitness monitoring devices
- Commercial workout machines
- Rehabilitation and physiotherapy systems
- Fitness product prototyping
This project aligns perfectly with Custom Electronics Project Services and Product Design and Development Services.
At Arduino Expert, we specialize in transforming such concepts into market-ready smart products using our Arduino Project Services and Custom Electronics Project Services.
Future Enhancements
- Wireless data sync using ESP32 Wi-Fi or Bluetooth
- Mobile application integration
- Cloud-based workout analytics
- User profile management
- AI-based exercise posture validation
Conclusion
The Smart Gym Exercise Repetition Counter Using ESP32, Nextion Display, Ultrasonic Sensor, DFPlayer Mini, and NeoPixel LED is a complete smart fitness solution designed using professional Product Design and Development methodologies. By combining accurate sensing, intelligent logic, audio-visual feedback, and a modern touchscreen interface, this project demonstrates how embedded systems can power next-generation fitness technology.
This system is ideal for startups, gyms, and fitness equipment manufacturers seeking custom electronics and smart product development services.
Need Embedded Smart Gym Fitness Tracker Device?
If you need this Smart Gym Fitness Tracker Device with or without Modifications or Customization then you can contact us through WhatsApp. We can deliver you this Project in the Following Ways.
Project Code:
we can provide you Project Code along with Zoom Assistant, through Zoom meeting for Setup of this Project.
Fully Functional Project with Hardware/Components Shipment:
if you can not make this project yourself then you can use this option. We will assemble the Project and will ship it to your Doorstep with Safe Packaging.
Learn More about the services we offer.