API reference
Local HTTP API
The ESP32 bcMeter serves its local API over HTTP on port 80. GET /api/status reports the installed firmware in version, the platform in platform ("esp32" on the assembled instrument), and the build environment in env.
Raspberry Pi examples apply to the current DIY software.
Connecting
Replace the example hostname with the hostname or LAN IP shown by your device.
device='http://bcmeter-XXXX.local' curl --fail --show-error -H 'X-bcMeter-Client: bcmctl' "$device/api/status"
For local status, CSV and routine controls, send X-bcMeter-Client: bcmctl. These requests do not require the device password. Browser clients must use the device's own origin. Owner operations, including Wi-Fi credential changes, require a separate device-password proof for each request.
Use the device password to sign each owner request.
- Fetch
GET /api/auth/challengewith the client header. The returnednonceis single-use, bound to the requesting client and valid for 30 seconds. - Compute the lowercase hexadecimal SHA-256 digest of the exact request body, using the empty byte string for a bodyless request. Join the nonce, uppercase HTTP method, exact path including its query string, and body digest with one newline between fields. Compute HMAC-SHA256 over this string with the device password as the key and encode the result in lowercase hexadecimal.
- Send the client header plus
X-bcMeter-Nonce,X-bcMeter-Body-SHA256andX-bcMeter-Proofon the intended request. To check a proof without changing settings, signGET /api/auth/verifyand look for"authorized":true. Obtain a fresh nonce for the next owner request.
For bcMeter V1 and Raspberry Pi DIY User
Request the protected GET /api/maintenance-logs ZIP when you need a support bundle. Review it before sharing since it can include recent measurement logs.
Measurement and configuration
| Request | Result |
|---|---|
GET /api/status |
JSON including status (0 idle, 1 starting, 2 sampling, 3 stopped with an error), session (whether a log session is open), error, error_msg, bc, atn, flow (L/min), time_synced and version. When stop_pending is true, finalization is still running.
|
GET /api/system · GET /api/logs |
System reports device, storage and network information. Some fields such as the MAC address are blank in ordinary reads. Use an owner-signed GET /api/system?private=1 for private system details. The logs endpoint returns a structured health report including hardware, measurement, system and network sections.
|
GET /api/control?action=synctime&ts=EPOCH&tz=Europe/Berlin |
Set the clock using Unix time in seconds. Use the timezone for the measurement site. |
GET /api/control?action=start · GET /api/control?action=stop |
Start a session or request a stop. For a one-session indoor/outdoor selection append &indoor=1 or &indoor=0 to start. Start can return 409 for an unsynchronized clock, 423 for missing calibration or 424 for calibration older than 28 days. A 202 stop response means cleanup continues. Wait for stop_pending=false and session=false before treating the file as final.
|
GET /api/control?action=calibrate · GET /api/calibration |
Install a clean filter and stop sampling before starting calibration. The start call returns 202 when accepted. Poll the second endpoint for running, done, ok, elapsed_ms and log. A finished, successful run has done=true and ok=true. Use the setup wizard for first calibration.
|
GET /api/config · POST /api/config |
Read a JSON object keyed by setting. Entries have value, type, description and parameter (settings group). Send only edited fields as JSON, for example {"sample_time":300} for a 300-second sampling interval. Apply acquisition changes while idle. Owner settings require a proof. A redacted value is unsuitable for copying into a write.
|
GET /api/control?action=identify flashes the device indicator. GET /api/control?action=clear_error clears the recorded measurement error. GET /api/crash reports the last reset. Its ordinary response contains a summary.
Reboot and shutdown require a confirm query parameter matching the action. Erasing stored logs and factory reset require both matching confirmation and an owner proof. A missing confirmation returns 428. Use the device interface for these actions.
For bcMeter V1 and Raspberry Pi DIY User
The factory_reset action requires an owner proof and confirm=factory-reset. It stops sampling and restores settings, including the device password and last calibration date. Measurement files, saved Wi-Fi connections and the device-specific correction factor remain. The Pi stays running. Unsupported control actions return HTTP 400.
Downloading data
curl --fail --show-error -H 'X-bcMeter-Client: bcmctl' "$device/api/files"
GET /api/files lists session files as a JSON array. Select a returned name. GET /api/csv?file=FILENAME and GET /api/files?name=FILENAME retrieve the selected CSV. For example, set file to a name from the list and run:
curl --fail --show-error -H 'X-bcMeter-Client: bcmctl' --get \ --data-urlencode "file=$file" "$device/api/csv" -o measurement.csv
GET /api/csv without a filename uses the session selected on the device. It falls back to the newest stored log if the selected session file is unavailable. An idle instrument can therefore return a previous session. If the device has no log to return, the response contains only the CSV header. GET /api/files?name=FILENAME&manifest=1 retrieves the session's JSON manifest when available. The list reports manifest_available and active. For SD-card logs use GET /api/sdfiles.
POST /api/files/upload with {"name":"FILENAME"} asks the device to upload the named, completed session. A 202 response means queued. A 422 response can indicate disabled sharing, missing location or provisional timestamps. DELETE /api/files takes the name query parameter, owner proof and confirm=delete_log. The device rejects deletion of its active session with 409.
For bcMeter V1 and Raspberry Pi DIY User
Use GET /api/csv?view=chart to retrieve chart data with precise coordinates removed. For raw CSV, send the local client header. Omit the filename to select the active session, the newest saved session, or a header when there are no logs.
Wi-Fi and firmware updates
| Request | Result |
|---|---|
GET /api/wifi/scan?refresh=1 · GET /api/wifi/status |
Request a scan and read cached results in networks (SSID, RSSI and security flag). Poll /api/wifi/scan while scanning is true. The status endpoint reports the current connection.
|
POST /api/wifi/connect · GET /api/wifi/connect/status |
Submit JSON with ssid and pass (8–63 characters). After a 202 response, poll connection status for state, log and ip. This operation requires owner access after setup.
|
POST /api/wifi · POST /api/wifi/delete |
Save Wi-Fi credentials and request reconnection, or forget credentials and return to hotspot mode. The save accepts JSON with ssid and pass. Deletion requires owner proof and ?confirm=wifi-delete.
|
GET /api/ap-security · POST /api/device/password |
The first call reports secured and password_set. Its password field is empty. After onboarding, use the second call with the current owner's proof to change the device password. Use the setup wizard to establish the first password. The wizard uses GET and POST /api/onboarding/setup and POST /api/onboarding/claim.
|
POST /api/device/rename |
Change the device name and local hostname. Send JSON with a name field containing 1–32 characters. This requires owner proof.
|
GET /api/ota/status · POST /api/ota/check · POST /api/ota/skip |
Read update availability, advertised version and progress, request a new check, or skip the offered version. After requesting a check, read status again. |
POST /api/ota/apply · POST /api/update |
Apply the update offered by the device or supply a compatible firmware image as a raw binary body. Applying an offered update requires ?confirm=ota_apply. Direct binary upload requires the X-Firmware-SHA256 header containing the image digest. A successful update reboots the device.
|
For bcMeter V1 and Raspberry Pi DIY User
GET /api/ap-security reports that the setup hotspot is locked open. Apply an offered update with POST /api/ota/apply?confirm=ota-apply. To install a local archive, upload it to POST /api/update as multipart data with an owner proof and the X-Firmware-SHA256 header. Use .tar.gz, .tgz or .zip and wait for the web interface to reconnect.
Location, cloud sharing and optical diagnostics
| Request | Result |
|---|---|
GET /api/location · POST /api/location |
Read available, timezone and the coordinates/source when available. Supply lat and lon as JSON numbers to set a location, with optional IANA timezone. Set next_session_only to true to stage a position for the next session. An active session blocks changes to its current position.
|
POST /api/location/discover |
Request location discovery. Availability depends on location settings, network access and available positioning hardware. |
GET /api/cloud/status · POST /api/cloud/consent |
Check local sharing, server consent and any pending change. Use ?local=1 for local status. The operator must explicitly accept the current privacy notice to enable sharing, or confirm pausing it. Changes can return 202 while synchronization is pending. Pausing stops uploads locally and preserves stored data.
|
POST /api/cloud/upload · GET /api/cloud/upload/status |
Request a cellular upload with owner proof and JSON {"transport":"cellular"}. A 202 response includes a request_id. Read the owner-protected status endpoint for the outcome. Cloud sharing and an available cellular data path are required.
|
POST /api/optical_diagnostic/start · GET /api/optical_diagnostic/status · POST /api/optical_diagnostic/cancel |
Owner proof is required for all three calls. Start takes an empty body and requires ?resume_after=0 or ?resume_after=1 to specify whether to resume an eligible measurement. A 202 response contains run_id. Poll for state, stage and active.
|
For column names, units and file versions, see CSV data format. For filter changes and calibration, see Maintenance.