From a coin-cell BLE sensor to a live dashboard.
An illustrative end-to-end configuration: a BLE sensor designed for 5+ years on one battery, a BLE gateway on Ethernet or Wi-Fi, an MQTT broker, and web and mobile dashboards that update as each message arrives.
One sensor, one gateway, one dashboard
A temperature and humidity sensor sits in a cold room, a plant or a field enclosure where changing batteries is expensive. It must run for five years or more, report regularly, and show up live on a dashboard.
Note: All values on this page are illustrative starting points for a design discussion. Real figures are measured on your hardware and finalised during development.
| Item | Illustrative target |
|---|---|
| Sensor device | BLE 5 SoC, temperature and humidity sensor, non-connectable advertising |
| Power source | Single CR2032 coin cell (225 mAh nominal); alternatives: CR2450, Li-SOCl2 (e.g. 1/2 AA) |
| Battery-life target | 5 years or more at the configured reporting interval |
| Reporting interval | 10 s advertising of the latest reading (tunable 5 to 60 s) |
| Gateway | BLE scanner with Ethernet and Wi-Fi uplink, local buffering, mains powered |
| Transport | MQTT 3.1.1 / 5 over TLS (port 8883); WebSockets over TLS for browsers |
| Consumers | Web dashboard, mobile app, alerts, long-term storage |
BLE Device → BLE Gateway → Ethernet/Wi-Fi → MQTT Broker → Dashboard / App
Select a step to see what happens there and how we configure it. Press Replay to watch a reading travel the whole path.
1BLE Sensor Device
Wakes on an RTC timer, measures temperature and humidity, packs a compact reading into a BLE advertising packet, then returns to deep sleep.
Key configuration
- Non-connectable (broadcast-only) advertising: no connection setup, lowest energy per message
- Advertising interval 10 s (tunable); all three advertising channels
- Transmit power 0 dBm, reduced (-4 dBm or lower) if the range allows
- Payload of about 10 bytes in manufacturer-specific data: device type, sequence number, temperature, humidity, battery millivolts
- Connectable mode only on button press for commissioning (short connection interval, then back to broadcast)
2BLE Gateway
Always-on, mains-powered node that scans for the sensor adverts, validates them, adds a timestamp and signal strength, and turns each reading into an MQTT message.
Key configuration
- Continuous passive scanning with a filter on company ID / device allow-list
- De-duplicates repeats using the sequence number; timestamps with NTP time
- Adds RSSI and gateway ID; converts binary payload to JSON
- Store-and-forward buffer in flash if the network or broker is down
- Over-the-air firmware update and remote configuration over MQTT
3Ethernet / Wi-Fi
The gateway reaches the internet or plant network over a wired or wireless link, secured end to end.
Key configuration
- Ethernet preferred for fixed installs (stable, no RF contention); Wi-Fi as fallback or where cabling is hard
- DHCP or static IP; DNS and NTP reachability checked at boot
- TLS with server certificate verification; per-gateway credentials or client certificates
- Reconnect with exponential back-off and jitter, so a power cut does not trigger a reconnect storm
- Link-state LED and diagnostic topic for field support
4MQTT Broker
The broker receives each message on a topic and delivers it to every subscriber: dashboards, apps, alert rules and a database writer.
Key configuration
- Self-hosted (Mosquitto, EMQX) or managed cloud MQTT service
- TLS on 8883; WebSockets over TLS for browsers and mobile apps
- Topic-level access control: a gateway may only publish under its own prefix
- Retained status messages and Last Will so offline gateways are visible
- Rule or subscriber that writes readings to a time-series database for history
5Web Dashboard / Mobile App
The user interface subscribes to the telemetry topics and redraws charts, gauges and status indicators when a new message arrives.
Key configuration
- Subscribes to wildcard topics for a site, e.g. thartek/plant01/+/+/telemetry
- Live widgets update in place; history and trends are fetched from the database
- Threshold alerts (e.g. high temperature, low battery, no message for N minutes)
- Mobile app adds push notifications and offline cache
- Authentication and per-site permissions so each customer sees only their devices
What we set, and why
Five decisions determine battery life, reliability and how easily the data scales to more devices.
1. Low-power advertising and connection intervals
Every radio event costs energy, so the interval is the single biggest lever on battery life. For periodic sensor data, broadcast-only advertising avoids connection overhead entirely. Connections are kept for the rare moments they are needed, such as commissioning or configuration.
Rule of thumb: halving the interval roughly doubles the radio share of the energy budget. Use the calculator below to see the effect.
| Parameter | Illustrative value | Why |
|---|---|---|
| Advertising type | Non-connectable, undirected | No connection setup or acknowledgements |
| Advertising interval | 10 s (range 5 to 60 s) | Radio event rate sets average current |
| Advertising channels | All three (37, 38, 39) | Robustness against Wi-Fi interference |
| TX power | 0 dBm, lower if range allows | Lower TX power means less charge per event |
| Config-mode connection interval | 100 ms during commissioning only | Quick parameter transfer, then return to broadcast |
| Config-mode timeout | Short (e.g. 60 s), then sleep | Prevents a forgotten connection draining the cell |
| Gateway scan | Continuous passive scan | Mains powered, so it never misses an advert |
2. Battery-life budget (interactive)
Average current = sleep current + sensor average + (charge per advertising event / interval). Change any input to see the estimated life.
- Average current
- --
- Radio share
- --
- Usable energy
- --
| Advertising interval | Average current | Estimated life | Meets 5 years? |
|---|
Defaults are illustrative: 225 mAh nominal CR2032, 80% usable, 6 µC per three-channel advertising event. Coin-cell capacity falls with pulse current, low temperature and age, so we verify the real result with current profiling and a battery model before committing to a life claim.
3. MQTT topic structure
A predictable hierarchy lets dashboards subscribe with wildcards, lets the broker enforce per-gateway access rules, and lets you add sites and devices without code changes.
- Lowercase, no spaces, no leading slash, stable IDs
- Hierarchy goes from broad to specific: owner / site / gateway / device / message type
- Data never goes in the topic, only in the payload
- One message type per topic (telemetry, alert, status, cmd)
- Access control by prefix: a gateway may publish only under its own gateway ID
thartek/{site}/{gateway_id}/{device_id}/telemetry gateway -> broker QoS 1
thartek/{site}/{gateway_id}/{device_id}/alert gateway -> broker QoS 1
thartek/{site}/{gateway_id}/status gateway -> broker QoS 1, retained (+ Last Will)
thartek/{site}/{gateway_id}/cmd/# broker -> gateway QoS 1
# Example
thartek/plant01/gw-7f3a/ble-a1b2c3/telemetry
# Dashboard subscriptions
thartek/plant01/+/+/telemetry all sensors on site plant01
thartek/plant01/gw-7f3a/# everything from one gateway4. QoS levels
MQTT offers three delivery guarantees. Higher QoS costs extra packets, so we choose per message type. The BLE hop itself is broadcast-only and has no acknowledgement; reliability is added at the gateway-to-broker hop and by the sequence number, which lets the dashboard detect gaps and ignore duplicates.
| Message | QoS | Retain | Reason |
|---|---|---|---|
| Telemetry | 1 | No | At-least-once delivery; duplicates removed using seq |
| Alerts (low battery, threshold) | 1 | No | Must arrive; duplicates harmless |
| Gateway status / Last Will | 1 | Yes | New subscribers see online/offline state immediately |
| Commands and config to gateway | 1 | No | Reliable delivery; commands are idempotent |
| High-rate, non-critical data | 0 | No | Lowest overhead where loss is acceptable |
QoS 2 (exactly-once) is reserved for rare cases where a duplicate would cause harm; it needs a four-step handshake. Use persistent sessions so queued messages survive short disconnects.
5. Payload format
Over the air, the sensor sends a compact binary record so each advertisement stays short, which saves energy. The gateway expands it to self-describing JSON for the broker, which is easy for dashboards, databases and third-party tools to consume.
- Versioned schema (<code>v</code>) so fields can be added without breaking subscribers
- UTC ISO-8601 timestamp added by the gateway from NTP time
- Explicit units in field names (<code>temp_c</code>, <code>rh_pct</code>, <code>batt_mv</code>)
- Sequence number for de-duplication and gap detection
- Gateway adds <code>rssi_dbm</code> for link-quality monitoring; about 200 bytes per message
{
"v": 1,
"device_id": "ble-a1b2c3",
"gateway_id": "gw-7f3a",
"ts": "2026-11-06T11:42:10Z",
"seq": 18452,
"temp_c": 26.4,
"rh_pct": 54.2,
"batt_mv": 2950,
"batt_pct": 88,
"rssi_dbm": -71,
"fw": "1.2.0"
}How the data looks on the dashboard and the app
Both screens below are driven by one simulated MQTT feed. Each time a message arrives, the gauges, charts, status indicators and device table update in place. Nothing is refreshed or reloaded.
| Device | Temp | Battery | Status |
|---|---|---|---|
| ble-a1b2c3 | -- °C | --% | Online |
| ble-d4e5f6 | -- °C | 76% | Online |
| ble-90ab12 | -- | 9% (low) | Stale · 6 min |
1. A message arrives
The gateway publishes a reading to the broker. Every subscribed screen receives it through its open WebSocket connection.
2. Widgets update in place
The app parses the JSON and moves the gauge needles, extends the chart line and refreshes the status chips, with no page reload.
3. Rules raise alerts
A reading above the threshold shows an alert banner. A device that stops sending is flagged as stale after a set time.
How a browser subscribes
A web dashboard connects to the broker over secure WebSockets and subscribes to the site's telemetry topics. Production systems usually also store every message in a time-series database, so history, reports and alerts do not depend on a browser being open.
const client = mqtt.connect('wss://broker.example.com:8084/mqtt', {
username: 'dashboard-plant01', password: TOKEN
});
client.on('connect', () =>
client.subscribe('thartek/plant01/+/+/telemetry', { qos: 1 }));
client.on('message', (topic, payload) => {
const d = JSON.parse(payload.toString());
updateGauges(d); // temp_c, rh_pct, batt_pct
appendToChart(d); // ts, temp_c, rh_pct
});Need a connected device like this?
We design the sensor, gateway, firmware, broker integration and dashboards as one system.
