Skip to content

Thomas-More-Digital-Innovation/2425-EnergieFiets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

EnergieFiets Project (2024-2025)

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.

📋 Project Overview

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

🏗️ Architecture

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

🚀 Getting Started

Prerequisites

  • Python 3.x
  • Node.js and npm
  • Docker and Docker Compose
  • ANT+ USB stick
  • ANT+ compatible sensors (speed/cadence sensor and power meter)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd 2425-EnergieFiets
  2. 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
  3. Install Python dependencies

    cd code/WebApp
    pip install -r requirements.txt
  4. Install Frontend dependencies

    cd code/WebApp/react/scoreboard
    npm install

Running the Application

  1. Start the ANT+ sensor reader

    cd code
    python antReadCadence.py
  2. Start the Flask backend

    cd code/WebApp
    python app.py
  3. Start the React frontend

    cd code/WebApp/react/scoreboard
    npm run dev
  4. Access Grafana (optional)

    • Navigate to http://localhost:3000
    • Configure InfluxDB as a data source
    • Create dashboards to visualize performance metrics

📁 Project Structure

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

🔧 Configuration

ANT+ Sensor Configuration

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

Database Configuration

  • InfluxDB database name: trainerdata
  • SQLite database: trainer.db (auto-created)

📊 API Endpoints

  • POST /api/naam - Save user information (name and email)
  • GET /api/results - Retrieve performance results
  • Additional endpoints available in app.py

🐳 Docker Deployment

The application can be fully containerized using the provided Dockerfiles and docker-compose configuration:

docker-compose up -d

This will start:

  • InfluxDB (port 8086)
  • Grafana (port 3000)

📝 Data Model

SQLite Tables

  • temp_naam: Temporary user information storage
  • resultaten: Performance results with averaged metrics

InfluxDB Measurements

  • Speed (km/h)
  • Cadence (RPM)
  • Power (Watts)

About

Project 2024-2025 : EnergieFiets

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors