IoT Fundamentals · Study deck
Binary Data Formats for IoT
Picture a compact sensor record whose receiver swaps the byte order and reports the wrong temperature.
Physics Phoebe is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Explain: The important idea is not "always make messages smaller." The important idea is a trade: binary formats save bytes only when both the sender and the receiver share the rules for decoding them.
- Explain: CBOR and MessagePack: Self-Describing Binary CBOR (Concise Binary Object Representation, IETF RFC 8949) is "binary JSON": the same data model of maps, arrays, numbers, strings, and booleans, encoded as typed bytes.
- Explain: It supports the chapter's selection rule: choose the most inspectable representation that meets the link budget and ensure every compact byte remains decodable across versions.
Major section
In 60 Seconds
JavaScript Object Notation, or JSON, is a text format built from named values.
- A protocol means shared rules for exchanging messages.
- A binary format must define equally clear field boundaries and meaning.
- Encode one known record, change its version, truncate it, corrupt one byte, and decode it with another implementation.
Major section
In 60 Seconds (continued)
Saving bytes was not useful because the meaning was no longer shared.
- This runway does not prove that one format fits every link.
- The deeper sections compare compact formats, schemas, framing, byte order, checks, versioning, tooling, and ownership costs.
- Binary formats help when bytes, power, or storage are constrained, but the format is a contract.
Major section
Start With the Story · How to Use: How It Works: Pick the Encoding Contract
You will compare compact encodings and choose a format whose decoder and version rules your system can support.
- The first panel establishes that boundaries and an integrity check are prerequisites, while the second exposes the risk of optimizing size before defining meaning.
Major section
What Compact Binary Buys
A binary data format keeps the same facts but stores them as typed bytes instead of text, so the message gets much smaller.
- The important idea is not "always make messages smaller." The important idea is a trade: binary formats save bytes only when both the sender and the receiver share the rules for decoding them.
Major section
What Compact Binary Buys (continued)
They pay off when bandwidth, power, or storage are tight and both ends agree on a schema or decoding contract.
- When the link is comfortable and humans need to inspect data, readable text is often the better default.
- Full sentences are clear to anyone but slow and bulky.
- The capacity gain is therefore not a free ranking.
Major section
What Compact Binary Buys (continued)
Shorthand is far more compact, but only readers who know your shorthand can recover the meaning.
- For example, a battery soil-moisture node on LoRaWAN may send temperature, relative humidity, battery voltage, and a timestamp every half hour.
- Exact byte counts change with field names, numeric ranges, and identifiers.
- Smaller is not automatically better.
Major section
What Compact Binary Buys (continued)
CBOR retains typed structure at about 18 bytes, fitting two.
- CBOR can keep the message self-describing while shrinking the encoding, while a custom layout might store temperature as signed centidegrees and battery voltage as millivolts.
- That last step is only sensible if the gateway, decoder tests, and version notes are owned by the same deployment.
- The One-Minute ViewText is readable but heavy JSON carries field names, quotes, and digits as text on every message.
Major section
What Compact Binary Buys (continued)
The stable pattern is what matters: JSON repeats readable structure, CBOR keeps typed structure with less text overhead, and raw binary removes nearly everything except the values and the decoder contract.
- JSON keeps field names and punctuation visible at roughly 32 bytes, so 51 B/32 B=1.59 and only one complete reading fits.
- Raw binary uses about 4 bytes, fitting twelve, but moves field order, scaling, byte order, status meaning, and schema version into an external contract.
- A LoRaWAN or Sigfox node with a tiny per-message budget benefits from a compact format, because every byte is airtime and energy.
Major section
What Compact Binary Buys (continued)
It supports the chapter's selection rule: choose the most inspectable representation that meets the link budget and ensure every compact byte remains decodable across versions.
- Binary is compact but needs a contractTyped bytes drop most of the textual overhead, but the receiver must know the types, field meaning, and byte order.
- Beginner ExamplesA device on Wi-Fi or Ethernet sending to a dashboard can keep JSON, because bandwidth and battery are not the binding constraint.
- An opaque eight-byte payload that no current tool can decode is a liability, not an optimization.
Major section
Apply It: Choose and Apply a Binary Format
CBOR and MessagePack: Self-Describing BinaryCBOR (Concise Binary Object Representation, IETF RFC 8949) is "binary JSON": the same data model of maps, arrays, numbers, strings, and booleans, encoded as typed bytes.
- CBOR has a registered CoAP Content-Format and is a strong default for LoRaWAN and NB-IoT.
Major section
Apply It: Choose and Apply a Binary Format (continued)
Custom Binary: Hand-Packed BytesCustom binary defines a fixed byte layout that your code packs and unpacks directly.
- Protocol Buffers: Schema-Defined BinaryProtocol Buffers (Protobuf) is defined by a.proto schema.
- Each field is identified by a small field number instead of a name, so field names never travel on the wire.
- Each branch asks what the receiver needs, making parser ownership part of the format decision.
Major section
Apply It: Choose and Apply a Binary Format (continued)
That makes it very compact and very fast to parse with generated code, but it is not self-describing: both ends need the schema to decode a message.
- It produces the smallest messages and the fastest parsing, but there is no tooling, no self-description, and no automatic schema evolution.
- Custom binary appears last because owning its byte layout also means owning documentation, tests, and migration.
- The sizes below are approximate and specific to this payload, but the ranking holds in general.
Major section
Under the Hood: How the Bytes Are Built · Checkpoint: Summary
Each format reaches its size by removing a different layer of overhead.
- Understanding the encoding lets you estimate payload sizes, debug wire-format problems, and evolve a schema without breaking deployed devices.
- This map is 55 bytes.
- Protocol Buffers EncodingA Protobuf message is a series of fields.
Deck summary
Key takeaways
JavaScript Object Notation, or JSON, is a text format built from named values.
- Saving bytes was not useful because the meaning was no longer shared.
- You will compare compact encodings and choose a format whose decoder and version rules your system can support.
- A binary data format keeps the same facts but stores them as typed bytes instead of text, so the message gets much smaller.
- They pay off when bandwidth, power, or storage are tight and both ends agree on a schema or decoding contract.
Retrieval practice
Recall check 1 of 4

Physics Phoebe says: answer from memory, then check your reasoning.
Q1Which format comparison gives a team the right decoder trade-off?
Show answer
Answer: B Each choice trades wire size against readability, schema, and parser responsibility.
Retrieval practice
Recall check 2 of 4

Physics Phoebe says: answer from memory, then check your reasoning.
Q2When is a compact binary payload format usually the right direction?
Show answer
Answer: C Binary formats save bytes only when the decoding rules are explicit and shared by both ends.
Retrieval practice
Recall check 3 of 4

Physics Phoebe says: answer from memory, then check your reasoning.
Q3A LoRaWAN sensor must send temperature, humidity, and a timestamp every 15 minutes, and the payload limit at its data rate is about 51 bytes. The team wants minimal deployment coordination. Which format fits best?
Show answer
Answer: D CBOR comfortably fits this payload and needs no shared schema, which keeps a simple deployment simple.
Retrieval practice
Recall check 4 of 4

Physics Phoebe says: answer from memory, then check your reasoning.
Q4A team must add a new optional field to a deployed Protobuf message without breaking devices still running the old firmware. What is the safe change?
Show answer
Answer: C Unknown field numbers are skipped by older decoders, so new and old code interoperate.
Print reference
Answers
Answer key.
- B · Each choice trades wire size against readability, schema, and parser responsibility.
- C · Binary formats save bytes only when the decoding rules are explicit and shared by both ends.
- D · CBOR comfortably fits this payload and needs no shared schema, which keeps a simple deployment simple.
- C · Unknown field numbers are skipped by older decoders, so new and old code interoperate.