API reference
Jump to navigation
Jump to search
API Reference
The bcMeter exposes a REST API on port 80. All endpoints are accessible without authentication when connected to the device network.
The software is open source: github.com/dahljo/bcmeter
Status & Diagnostics
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/status |
Current measurement state, last sensor readings, error codes, sample count, WiFi mode, firmware version |
| GET | /api/system |
Hardware info: MAC address, memory, time, last calibration, GPS position, barometric altitude |
| GET | /api/logs |
Structured health report with sections: hardware, measurement, system, network |
Measurement Control
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/control?action=start |
Begin measurement session (requires time sync + calibration). Add &force=1 to override preflight checks.
|
| GET | /api/control?action=stop |
Stop measurement and save session file |
| GET | /api/control?action=calibrate |
Start calibration routine (async — poll /api/calibration for progress)
|
| GET | /api/calibration |
Calibration status: running, elapsed time, log output, success/failure |
| GET | /api/control?action=clear_error |
Reset error state |
Configuration
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/config |
All settings as JSON. Each parameter includes type, value, label, tab, and description. |
| POST | /api/config |
Update settings. JSON body with key-value pairs. Only changed values need to be sent. |
| POST | /api/device/rename |
Set device name. Body: {"name": "bcmeter01"}
|
| GET | /api/control?action=synctime&ts=EPOCH&tz=IANA |
Sync device clock. ts = Unix timestamp, tz = IANA timezone string.
|
WiFi Management
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/wifi/scan |
List nearby networks. Add ?refresh=1 to trigger a new scan.
|
| GET | /api/wifi/status |
Current connection: mode (sta/ap), SSID, IP address |
| POST | /api/wifi/connect |
Connect to network. Body: {"ssid": "...", "pass": "...", "hidden": false}
|
| GET | /api/wifi/connect/status |
Connection progress: state, hostname, log messages |
| POST | /api/wifi/delete |
Clear saved WiFi credentials, switch to AP mode |
| GET | /api/ap-security |
Hotspot security settings: secured (bool), password |
| POST | /api/ap-security |
Update hotspot password. Body: {"secured": true, "password": "..."}
|
Data Management
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/csv |
Current session CSV data. Add ?file=FILENAME for archived files.
|
| GET | /api/files |
List stored CSV logs as JSON: [{"name": "...", "size": 1234}, ...]
|
| GET | /api/control?action=cleardata |
Delete all stored log files |
| GET | /api/control?action=cleanempty |
Remove empty (0 byte) log files |
| GET | /api/control?action=export |
Export all logs to SD card |
Firmware Updates
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/ota/status |
Check if update available: version, release notes, apply state/progress |
| POST | /api/ota/check |
Force check for new firmware |
| POST | /api/ota/skip |
Skip current available update |
| POST | /api/ota/apply |
Download and flash firmware update |
| POST | /api/update |
Direct firmware upload (multipart form-data, .tar.gz) |
System Operations
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/control?action=reboot |
Reboot the device |
| GET | /api/control?action=shutdown |
Safely shut down |
| GET | /api/control?action=factory_reset |
Erase all data and settings, reboot to factory state |
| POST | /api/email/validate |
Validate email API key. Body: {"api_key": "..."}
|
Captive Portal
These endpoints handle captive portal detection on mobile devices:
| Endpoint | Purpose |
|---|---|
/generate_204 |
Android captive portal check |
/hotspot-detect.html |
Apple captive portal check |
/success.txt |
Generic connectivity probe |
Example: Start a Measurement
# Sync time first curl "http://bcmeter-XXXX.local/api/control?action=synctime&ts=$(date +%s)&tz=Europe/Berlin" # Start measurement curl "http://bcmeter-XXXX.local/api/control?action=start" # Poll status curl "http://bcmeter-XXXX.local/api/status" # Download current data curl "http://bcmeter-XXXX.local/api/csv" -o measurement.csv