This guide walks you from a fresh machine to a fully working BLE people-counting setup. By the end you will have the cloud backend running in Docker, the Raspberry Pi agent scanning and sending anonymized detections, and the web dashboard showing live zone counts. The whole process takes roughly 15 minutes on a Pi that already has Python 3 and a Bluetooth adapter.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AngelAmoSanchez/TFG-RaspberryPi-BLE/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites before you begin:
- A Raspberry Pi (any model with a built-in or USB Bluetooth adapter) running Raspberry Pi OS (Bullseye or later)
- Python 3 and
pipavailable on the Pi - A machine (or the Pi itself) that can run Docker and Docker Compose for the backend
- A PostgreSQL instance — Docker Compose in step 3 provides one automatically
Clone the repository
Clone the project on both the machine that will run the backend and on the Raspberry Pi (they can be the same device).
Start the cloud backend with Docker Compose
The This brings up the following services:Once the containers start, verify the backend is healthy:You should see a JSON response with
docker-compose.yml in backend-cloud/ starts a PostgreSQL 14 database and the FastAPI backend together. The database connection string is wired up automatically between the two services."status": "healthy".Configure the Pi agent
On the Raspberry Pi, navigate to the The If you are using HTTP mode for a local setup, change
raspberry-pi/ directory and copy the example environment file:.env file controls every aspect of the agent. The minimum required fields are shown below. Fill them in before running the installer.COMMUNICATION_MODE to http and set HTTP_BASE_URL to the LAN IP of your backend machine:Run the installer on the Pi
The The installer performs these steps automatically:
install.sh script updates the system, installs Bluetooth and Python dependencies, creates a virtual environment, grants the necessary BLE capabilities to the Python binary, and generates a run.sh launch script. It also configures a systemd service so the agent can start on boot.The installer creates a
run.sh wrapper and a systemd unit file (ble-scanner.service) but does not enable the service automatically. Enable auto-start manually after verifying the agent works correctly (see the next step).Start scanning
Run the agent manually first to confirm everything is configured correctly:You should see log output similar to:Once you have confirmed it works, enable the systemd service to start the agent automatically on boot:To watch live logs from the service:
Open the web dashboard
With the backend running and the Pi agent sending detections, open the web dashboard in your browser. If you started the backend on your local machine, navigate to:The dashboard connects to the backend’s WebSocket endpoint (
ws://localhost:8000/ws) on load and begins rendering real-time zone charts. New detection batches appear automatically as the Pi completes each 30-second scan cycle.The dashboard source lives in the
frontend/ directory of the repository. See the frontend setup guide for instructions on building and deploying it.What to do next
Calibrate zone thresholds
Adjust
NEAR_THRESHOLD and MEDIUM_THRESHOLD to match your physical space.Privacy and anonymization
Understand exactly how SHA-256 anonymization works and what data is stored.
Deploy to production
Move from a local Docker setup to a hosted backend on Fly.io or similar.
API reference
Explore the REST endpoints for detections, statistics, devices, and CSV export.