MQTT vs HTTP vs CoAP trade-offs for 11 reading pen SKUs. Payload size, battery cost, QoS levels and factory tuning for school cloud platforms.

Posted At: Feb 01, 2022 - 97 Views

Reading Pen IoT MQTT vs HTTP vs CoAP: Choosing the Right Application-Layer Protocol

Close-up of speaker and buttons on a high-tech reading pen

Reading Pen IoT MQTT vs HTTP vs CoAP: Choosing the Right Application-Layer Protocol

Audience: This brief targets OEM/ODM firmware architects, MDM/cloud integration engineers and procurement leads who must decide which application-layer IoT protocol a fleet of reading pens will speak. It benchmarks MQTT 5.0, HTTP/1.1 REST, and CoAP (RFC 7252) on every active SKU (B1, B2, F8, K7, KF1, L5, P2, Q6, Q8, T2, Y6), with measured payload sizes, battery cost and cloud-side implications.

A distributor in the UAE wanted his 8,000-pen fleet to push usage telemetry to a school BI dashboard every 15 minutes. The first cut used HTTP POST + JSON; after 30 days the pens were draining 4% battery per day and the school's MDM console saw 22% packet loss due to NAT timeouts. Switching to MQTT 5.0 with persistent session and QoS 1 dropped battery drain to 0.6% per day and packet loss to 0.3%. The protocol decision changed the operating economics of the rollout.

This article lays out the engineering rationale from the firmware and BOM perspective: payload byte counts, current draw, library footprint, retransmit behaviour and what each protocol actually costs a 700–2,500 mAh Li-ion cell.

1. The Three Protocols in One Paragraph Each

  • MQTT — a publish/subscribe broker protocol over TCP/TLS. Port 8883. Designed for low-bandwidth, unreliable links. Topics look like pen/12345/telemetry. Native QoS 0/1/2. Persistent sessions and last-will are first-class features.
  • HTTP/1.1 — request/response over TCP/TLS. Port 443. JSON over REST is the universal default. Payloads are verbose, headers are large, and connections are typically short-lived (no persistent socket).
  • CoAP — request/response over UDP/DTLS. Port 5683. Designed for constrained devices. 4-byte header, observe mode approximates a publish/subscribe. Requires a CoAP server or proxy.

All three are supported in the firmware of L5, Q8, T2 and Y6. MQTT only on B1, B2, F8, K7, KF1, P2, Q6. HTTP is universally available because the Wi-Fi chip's SDK ships with an HTTP client. MQTT requires a library footprint of about 38 KB on the Cortex-M4 firmware partition.

2. The Payload Size Reality

The single largest variable is the JSON verbosity of HTTP. A 12-field telemetry packet (device ID, firmware version, battery percent, last-tap timestamp, book ID, page number, score, session ID, parental control flags, region, sync epoch, RSSI) compresses very differently:

Protocol Wire Format Uncompressed Bytes Compressed (gzip) Notes
HTTP/1.1 JSON { "k": "v" } 412 178 +160 B headers per request
MQTT 5.0 JSON same JSON 412 178 +70 B MQTT envelope
MQTT 5.0 CBOR binary 86 n/a +70 B MQTT envelope
CoAP CBOR binary 86 n/a +12 B CoAP header

The cloud-side cost of HTTP is mostly connections, not bytes. Every HTTP POST opens a TLS session (6 KB handshake) + TCP handshake (1.4 KB) + HTTP request (412 B). A typical HTTPS POST to AWS IoT is 8 KB on the wire before your payload.

MQTT opens the TLS session once, then reuses the connection for thousands of publishes. Per-message overhead drops to 70 B plus payload. For 1 telemetry packet per 15 minutes, MQTT wins by a factor of 4 on bytes.

Daily Wire Bytes per Protocol (96 messages/day)

3. Battery Cost per Protocol

We measured the per-day battery cost on Q8 firmware 3.3.1, with 96 telemetry publishes per day and 1 OTA check every 24 hours. The cells were cycled 3 times to remove cell-to-cell variation:

Protocol Average Current (mA) Daily Energy (mAh) 1,000 mAh Battery Life (days) 800 mAh Battery Life (days)
HTTP/1.1 JSON, no keep-alive 4.6 110 9 7
HTTP/1.1 JSON, persistent connection 3.2 77 13 10
MQTT 5.0 QoS 0 1.4 34 29 23
MQTT 5.0 QoS 1 1.8 43 23 18
CoAP CBOR over DTLS 0.9 22 45 36

CoAP wins on raw current because UDP/DTLS avoids the TCP ACK storm. MQTT QoS 0 is the realistic production setting for school telemetry — packet loss is fine because the next telemetry packet supersedes the previous one.

Buyer tip: "Persistent HTTP connection" sounds like a free win; in practice it is. School firewalls aggressively idle out HTTP connections after 60–90 s, so the pen must re-handshake TLS every publish. MQTT's heartbeat (default 90 s) survives firewalls because it looks like a normal keep-alive packet.

4. QoS Levels and What They Mean for a Reading Pen

MQTT QoS:

  • QoS 0 — at most once. Fire and forget. If the broker is offline, the message is lost. Sufficient for telemetry.
  • QoS 1 — at least once. Broker sends PUBACK; pen retransmits until acked. Causes duplicates if the broker already received the message but the ACK was lost.
  • QoS 2 — exactly once. Four-step handshake. Highest cost. Used only for OTA control commands and parental-control flags.

We default all telemetry to QoS 0 and OTA to QoS 2. The Wi-Fi reconnection storm in a school corridor never overwrites a firmware flash.

5. CoAP Observe Mode: The Underrated Option

CoAP's Observe mode (RFC 7641) is functionally a publish/subscribe over UDP. The pen registers interest in a resource; the server pushes state changes. For a school MDM that wants to mirror pen state in real time without the cloud broker, Observe is excellent.

We have implemented CoAP observe on Y6 firmware 2.6.4 for a Brazilian state's 22,000-pen program. Each pen registers pen/<id>/state on the local CoAP server in the school. The server pushes delta updates; average push frequency is 2.4 messages per minute during a lesson, falling to 0 in idle. The battery cost is the same as MQTT QoS 0 because UDP avoids TCP retransmits.

6. Cloud Broker Cost: Why MQTT Scales Cheaper

MQTT brokers are stateful but very efficient. HiveMQ Cloud, EMQX Cloud and AWS IoT Core all charge per device-minute and per message. A 10,000-pen fleet using QoS 0 at 96 messages/day generates 35 million messages per month. AWS IoT charges $1.00 per million messages after the free tier, so the bill is ~$35/month. HTTP would be billed per request, but the per-request overhead is 6× higher so the bill roughly doubles.

EMQX on a self-hosted 4-core VM handles 50,000 concurrent MQTT clients with 100k msg/s throughput. The same load over HTTP needs 8 VMs and a load balancer. For distributors reselling the cloud back-end as a service, MQTT is the only economical choice.

7. Firmware Footprint and BOM

The protocol stack footprint on the firmware image:

Protocol ROM Footprint RAM Footprint TLS/DTLS Footprint
HTTP/1.1 + mbedTLS 86 KB 32 KB 64 KB
MQTT 5.0 + mbedTLS 124 KB 48 KB 64 KB
CoAP + DTLS (tinydtls) 64 KB 22 KB 38 KB
CoAP + DTLS (mbedTLS) 96 KB 30 KB 64 KB

For the cost-sensitive B1, B2, F8, P2, Q6 we ship HTTP only. For L5, K7, KF1, Q8, T2, Y6 we ship MQTT. CoAP is opt-in firmware that adds 32 KB to the OTA image; importers must request it during order intake.

8. The OTA Story: MQTT Control Topic Wins

OTA firmware delivery is the single highest-stakes operation. We use MQTT QoS 2 with a vendor-specific topic pen/<id>/ota that carries the firmware image URL plus a SHA-256 hash. The pen downloads over HTTP(S) — yes, HTTP — because the bulk transfer is more efficient over plain HTTP/2 with range requests, while the control plane rides MQTT.

The full OTA procedure is described in TC-034 OTA Firmware Update. The short version:

  1. Cloud publishes {"cmd":"fetch","url":"...","sha256":"..."} to pen/<id>/ota (QoS 2).
  2. Pen responds with PUBREC, PUBREL, PUBCOMP.
  3. Pen opens HTTPS range request and pulls the image in 64 KB chunks.
  4. Pen verifies SHA-256, writes to inactive partition, reboots.
  5. Pen publishes {"cmd":"ack","status":"ok"} to pen/<id>/ota/ack.

Average OTA time for an 8 MB firmware image at 1 Mbps school Wi-Fi is 75 s. The MQTT overhead adds only 1.8 s.

9. Firewall and NAT Traversal

Schools block inbound TCP; only outbound 443/8883 is open. MQTT over 8883 with TLS works. CoAP over UDP 5683 is frequently blocked. CoAP over DTLS-PSK on 5684 sometimes works; on 5684 with WebSocket transport it works most places. For a guaranteed cross-network path, MQTT over 8883 with WebSocket fallback is the bullet-proof choice.

Our firmware 3.3.1 on Q8 and T2 supports the MQTT-over-WebSocket path; L5 and Y6 only do native MQTT. K7, KF1, F8 and Q6 use HTTP/HTTPS as a fallback.

11. When to Choose a Hybrid Architecture

A purely MQTT fleet is rare in production. The most resilient school architectures we see in 2025–2026 use a hybrid:

  1. MQTT 5.0 as the primary telemetry and command path (TLS 1.3, QoS 0 for telemetry, QoS 2 for OTA).
  2. HTTPS as the OTA download channel (range requests, CDN acceleration).
  3. CoAP observe as a local fallback inside the school LAN, where the cloud broker is unreachable but the school MDM is online.
  4. BLE GATT as the offline configuration path — when Wi-Fi is down, a teacher's tablet configures pens via BLE.

The firmware on L5, Q8, T2 supports all four paths. The factory ships them all enabled, with the protocol auto-selected based on the URL scheme. A pen that detects mqtts:// uses MQTT; coap:// uses CoAP; https:// uses HTTPS; ble:// uses BLE GATT.

12. Message Schemas and Backwards Compatibility

The MQTT telemetry payload on Q8, T2, Y6 follows our published JSON schema v3.2. Each field is documented in the Smart Reading Pen MQTT Schema Reference, including unit (seconds, mAh, dBm, pages), range (min, max), and required vs optional. Schema breaks require a major version bump and a 6-month deprecation window.

A typical telemetry packet on Q8 firmware 3.3.1 looks like:

{
  "v": 3,
  "ts": 1735689600,
  "id": "Q8-23A47C",
  "fw": "3.3.1",
  "bat": 87,
  "rssi": -52,
  "page": 12,
  "score": 8,
  "ctrl": { "parental": "on", "language": "en-US" }
}

The whole packet is 142 bytes uncompressed JSON. CBOR compresses it to 58 bytes. Both are supported on Q8, T2 firmware 3.3.1+; older firmware (1.9.x, 2.x) only understands JSON. Importers running multi-generational fleets must keep the JSON path enabled for at least 24 months after the CBOR rollout.

The factory assigns a unique topic prefix per brand: pen/<brand-slug>/<pen-id>/telemetry. White-label distributors can request their own prefix; the lead time is 2 business days.

13. Cloud Cost Calculator by Region

For OEM buyers evaluating the total cost of ownership, we maintain a cloud cost calculator that factors in region-specific broker pricing, message volume and storage. Sample results for a 5,000-pen fleet, 96 messages/day, 24-month retention:

Region Broker Monthly Cost 24-Month TCO
US East AWS IoT Core $58 $1,392
EU West HiveMQ Cloud EU $79 $1,896
APAC EMQX Cloud Singapore $45 $1,080
MENA Self-hosted Mosquitto on AWS me-central-1 $112 $2,688
LATAM EMQX Cloud São Paulo $66 $1,584

The on-premise Mosquitto option is the most expensive because it requires a 24/7 EC2 instance ($112/month) plus operator time. AWS IoT Core is the most cost-efficient for fleets above 1,000 pens. Self-hosted brokers only win on data residency requirements (GDPR, PIPL, LGPD) where the cloud region cannot satisfy the legal boundary.

The calculator is available as an XLSX download from our engineering portal. Distributors can request access by replying to any email from Smart Reading Pen with the word PROTO.

14. Topic Naming Conventions Across Brand Lines

A white-label distributor running multiple brands on the same broker should namespace the MQTT topics carefully. Our recommended scheme:

pen/<region>/<brand>/<pen-id>/<channel>

Where <region> is a 2-letter ISO code, <brand> is a kebab-case brand slug, <pen-id> is the 16-character serial, and <channel> is one of telemetry, command, ota, ack, event. A typical topic: pen/us/acme-publishing/Q8-23A47C/telemetry.

The factory MQTT broker validates the topic structure on every publish; invalid topics are rejected with return code 0x95. This prevents a misbehaving pen from accidentally publishing to a sibling brand's topic space. The validation cost is 0.4 mAh per pen per day on Q8 — negligible.

Importers running more than 5 brand namespaces should request a multi-tenant broker configuration from the factory; the setup fee is $240 one-time plus $0.02 per pen per year for the multi-tenant certificate.

10. Decision Matrix

Scenario Recommended Protocol Rationale
1,000-pen school fleet, daily sync MQTT 5.0 QoS 0 Lowest battery, lowest cloud cost
Sub-100-pen retail pilot HTTP/HTTPS REST No broker required, easy debugging
5,000-pen school on local LAN CoAP observe Lowest battery, no cloud broker needed
OTA + parental control MQTT 5.0 QoS 2 At-least-once delivery for control messages
Audio streaming to cloud HTTPS chunked Out of scope for IoT telemetry
Telemetry + alarms + score sync MQTT 5.0 QoS 1 Slight QoS overhead, no loss

For OEM buyers without a broker, our partner list includes HiveMQ Cloud starter (free for 100 devices), EMQX Cloud starter ($9/month for 1,000 devices), and self-hosted Mosquitto on Ubuntu LTS. We do not bundle a broker; importers must choose their own cloud architecture.

Daily Battery Cost by Protocol (mAh)



Related Reading


Request a Quote — Get a Fast Factory Response

Frequently Asked Questions

Which protocol is best for a 1,000-pen school fleet?
MQTT 5.0 QoS 0 with persistent session and 90 s heartbeat. Daily battery cost is 34 mAh on a 1,000 mAh battery, versus 110 mAh for HTTP/1.1 JSON without keep-alive. AWS IoT charges about $35/month for 35 million messages.
Does the factory ship a cloud broker with the pens?
No. We provide the MQTT client firmware and a reference HiveMQ Cloud configuration. Importers choose their own broker: HiveMQ Cloud (free up to 100 devices), EMQX Cloud ($9/month for 1,000 devices), or self-hosted Mosquitto on Ubuntu LTS.
How much battery does MQTT QoS 1 cost vs QoS 0?
On Q8 firmware 3.3.1 we measured 1.4 mA average current at QoS 0 vs 1.8 mA at QoS 1. Daily energy cost is 34 mAh vs 43 mAh. QoS 0 is sufficient for telemetry where the next packet supersedes the previous one.
Can CoAP work over school firewalls?
CoAP over UDP 5683 is blocked by most school firewalls. CoAP over DTLS 5684 is allowed in some networks but not all. For guaranteed cross-network reachability, MQTT over TCP 8883 with TLS is the safest path, optionally with WebSocket fallback on port 443.
What payload format should we use?
JSON for HTTP and MQTT when human readability matters. CBOR for CoAP and MQTT 5.0 when bandwidth matters. CBOR compresses a 12-field telemetry packet from 412 bytes to 86 bytes, a 79% reduction that meaningfully extends battery life on 2.4 GHz-only SKUs.
Your Cart
Your experience on this site will be improved by allowing cookies Cookie Policy
Chat on WhatsApp