A real-time cycling performance tracking system that reads data from ANT+ sensors (speed, cadence, and power), stores it in InfluxDB, and displays results on an interactive scoreboard.
The EnergieFiets project allows users to:
- Record cycling performance data using ANT+ sensors
- Track speed, cadence, and power output in real-time
- Store user information and results in a database
- View live performance metrics on a scoreboard
- Visualize historical data with Grafana dashboards
The system consists of:
- ANT+ Sensor Reader: Python script that captures bike speed, cadence, and power data
- Backend API: Flask REST API for managing users and results
- Frontend: React-based scoreboard with real-time updates
- Time-Series Database: InfluxDB for storing sensor data
- Visualization: Grafana for creating performance dashboards
- Data Storage: SQLite for user data and results
- Python 3.x
- Node.js and npm
- Docker and Docker Compose
- ANT+ USB stick
- ANT+ compatible sensors (speed/cadence sensor and power meter)
-
Clone the repository
git clone <repository-url> cd 2425-EnergieFiets
-
Start InfluxDB and Grafana
cd code docker-compose up -d- InfluxDB will be available at
http://localhost:8086 - Grafana will be available at
http://localhost:3000
- InfluxDB will be available at
-
Install Python dependencies
cd code/WebApp pip install -r requirements.txt -
Install Frontend dependencies
cd code/WebApp/react/scoreboard npm install
-
Start the ANT+ sensor reader
cd code python antReadCadence.py -
Start the Flask backend
cd code/WebApp python app.py -
Start the React frontend
cd code/WebApp/react/scoreboard npm run dev -
Access Grafana (optional)
- Navigate to
http://localhost:3000 - Configure InfluxDB as a data source
- Create dashboards to visualize performance metrics
- Navigate to
code/
├── antReadCadence.py # Main ANT+ sensor reader
├── antTest.py # ANT+ testing script
├── docker-compose.yml # InfluxDB and Grafana services
└── WebApp/
├── app.py # Flask REST API
├── readData.py # Data reading utilities
├── saveToDB.py # Database operations
├── testAverage.py # Data processing/testing
├── requirements.txt # Python dependencies
├── Dockerfile # Backend container
└── react/
└── scoreboard/
├── src/
│ ├── App.jsx # Main React component
│ ├── components/
│ │ └── Scoreboard.jsx # Scoreboard component
│ └── api/
│ ├── api_client.js # API client
│ └── results_service.js # Results service
├── package.json # Node dependencies
└── Dockerfile # Frontend container
Edit antReadCadence.py to adjust:
WHEEL_CIRCUMFERENCE_M: Wheel circumference in meters (default: 2.1m)RECORDING_DURATION: Recording duration in seconds (default: 10s)MIN_POWER_THRESHOLD: Minimum power threshold in watts
- InfluxDB database name:
trainerdata - SQLite database:
trainer.db(auto-created)
POST /api/naam- Save user information (name and email)GET /api/results- Retrieve performance results- Additional endpoints available in
app.py
The application can be fully containerized using the provided Dockerfiles and docker-compose configuration:
docker-compose up -dThis will start:
- InfluxDB (port 8086)
- Grafana (port 3000)
temp_naam: Temporary user information storageresultaten: Performance results with averaged metrics
- Speed (km/h)
- Cadence (RPM)
- Power (Watts)