The BLE people-counter agent runs as a Python process on a Raspberry Pi. TheDocumentation 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.
install.sh script handles everything from system package installation to creating a systemd service that starts the agent automatically on boot.
Hardware and OS requirements
Raspberry Pi
Any Raspberry Pi model with an onboard Bluetooth adapter (Pi 3, Pi 4, Pi 5) or a USB Bluetooth 4.0+ dongle. Raspberry Pi OS (Bookworm or Bullseye) recommended.
Software prerequisites
Python 3.10 or later,
bluez Bluetooth stack, git. All installed automatically by install.sh.The installer grants the Python binary raw network capabilities via
setcap so BLE scanning works without running the entire process as root.Installation
Clone the repository to your Raspberry Pi, then run the install script from inside theraspberry-pi/ directory.
Run the installer
The script must be executed from the Internally,
raspberry-pi/ directory because it resolves paths relative to $(pwd).install.sh performs these operations in order:Create your .env configuration file
If no Open the file and set at minimum
.env file exists the installer copies .env.example automatically:DEVICE_ID and your MQTT credentials. See the configuration reference for all available variables.Test the agent manually
Verify that scanning and MQTT publishing work before enabling the service:The You should see output similar to:
run.sh wrapper activates the virtual environment and launches src/main.py:The systemd service unit
The installer writes the following unit file to/etc/systemd/system/ble-scanner.service:
BindsTo=bluetooth.target— the service stops automatically if the Bluetooth adapter disappears.ExecStartPre=/bin/sleep 5— a 5-second delay lets the BT stack settle after boot.Restart=alwayswithRestartSec=15— the agent restarts within 15 seconds after any crash.StartLimitBurst=10/StartLimitInterval=200— systemd stops retrying after 10 failures in 200 seconds to prevent a restart storm.
Managing the service
Check service status
Check service status
View live logs
View live logs
Stop or restart the service
Stop or restart the service
Disable autostart
Disable autostart