IoT Fundamentals · Study deck

From Bytes to Meaning

Picture a temperature value that keeps the same bytes after an update but silently changes units.

Physics Phoebe is your guide for this deck.

datarepresentation
Physics Phoebe, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

A useful byte contract preserves the capture, identifies the field representation, and makes the decode repeatable.

  • Preserve captured bytes.The raw sequence lets another engineer repeat the decode.
  • Numeric fields need an explicit contract.Width, sign, byte order, scale, and unit determine the value.
  • Validate each representation with its own rule.Text, flags, and structured data need different checks.
Preserve raw bytes. Decode with width, sign, byte order, scale, and unit. Validate text, flags, and structured fields with their own contracts.
iotclass.org

Major section

In 60 Seconds · Start With the Story

Firmware means the program stored on a device to control its hardware.

  • A payload means the part of a message that carries the application data.
  • The deeper sections explain bits, bytes, integers, text, floating point, packed fields, and schema changes.
  • Every IoT reading eventually becomes bytes.

Key terms

Data representation
Data representation is the name for those rules, and most "wrong value" bugs in IoT are really disagreements about them.

Why it matters

The same bytes initially produce conflicting results because neither decoder has a complete interpretation rule.

iotclass.org

Major section

Bytes Are Evidence, Meaning Is a Contract

They could be a price of ten dollars and fifteen cents, a time of 10:15, a year, a part number, or a temperature of 101.5 stored in tenths.

  • The digits are identical.
  • Bytes work the same way, one level lower: the bits are fixed, but their meaning depends on a shared agreement.

Key terms

Counting characters
Counting characters is not the same as counting the bytes they occupy.

Why it matters

Each boundary needs an agreed interpretation so that changing representation preserves the measurement.

Data representation reviews keep raw bytes visible while checking the contract that turns them into numbers, text, flags, or validated values.
Data representation reviews keep raw bytes visible while checking the contract that turns them into numbers, text, flags, or validated values.
iotclass.org

Major section

Bytes Are Evidence, Meaning Is a Contract (continued)

This gives: Bytes Are Evidence, Meaning Is a Contract evidence to revisit.

  • The important idea is not "store data efficiently." The important idea is agreement.
  • A useful first check is to ask what the bytes are allowed to become.
  • The wrong choice gives a different, often plausible, number.
iotclass.org

Major section

Bytes Are Evidence, Meaning Is a Contract (continued)

A number that "looks reasonable" is not proof that the rules were right.

  • The same sequence may be a scaled integer, a UTF-8 string, a group of status flags, or a structured payload field.
  • Each choice has different proof: numeric values need range checks, text needs byte-length checks, flags need bit labels, and structured fields need a schema version.
  • Beginner ExamplesThe byte 0x50 is decimal 80, not decimal 50.
iotclass.org

Major section

Bytes Are Evidence, Meaning Is a Contract (continued)

Encoding and scale carry meaningText needs an encoding, and raw integers usually need a scale and units before they become real measurements.

  • The middle column stores that count as a register value and packet bytes; the right adds payload structure and application context.
  • The reading was careful and still wrong, because the label, the contract, was missing.
  • Reading hexadecimal as if it were decimal is one of the most common decode mistakes.
iotclass.org

Major section

Bytes Are Evidence, Meaning Is a Contract (continued)

If you only need the intuition, this layer is enough: keep the original bytes as evidence, write down the rules used to decode them, and check the result against a plausible range.

  • The One-Minute ViewWidth and sign set the range How many bytes a field uses, and whether it can be negative, decide which values it can even represent.
  • Byte order assembles valuesA multi-byte number can be built most-significant-first or least-significant-first.
  • A device name and a measurement are both "data," but text and numbers follow different rules.
iotclass.org

Major section

Apply It: Decode a Field With a Contract

A reliable decode is a short, ordered procedure, not a guess.

  • The goal is a value you can defend later, with the original bytes and the exact rules kept together so the same work is reproducible.
  • Swapping the order would give 0xEB00 = 60160, a very different value.
  • Top bit is 0, so positive.

Key terms

Units
Units are tenths of a degree.

Capture the original byte sequence before any tool formats or rounds it, so the evidence is not lost.

iotclass.org

Major section

Apply It: Decode a Field With a Contract (continued)

Walkthrough: From Raw Bytes to a Trusted ValuePreserve the raw bytes: Capture the original byte sequence before any tool formats or rounds it, so the evidence is not lost.

  • If the top bit were set, the value would be negative under two's complement.
  • Units are tenths of a degree.
  • Reporting 235 degrees would be a unit error, not a sensor fault.
iotclass.org

Major section

Under the Hood: Ranges, Two's Complement, and Byte Order

Knowing the mechanism lets you predict ranges, recognize overflow, and explain why a byte-order mistake produces a number that still looks believable.

  • Bases and Positional ValueDecimal, binary, and hexadecimal are different notations for the same quantities.
  • An unsigned 8-bit field holds 0 to 255.
  • Both readings are arithmetically valid.

Key terms

When an out-of-range result
When an out-of-range result is stored in an unsigned N-bit field, it wraps modulo 2^N instead of saturating.

Why it matters

Canonical network order is useful precisely because it makes that hidden agreement common across implementations.

Range selection workflow that lists minimum and maximum values, checks signedness, chooses field width, tests boundaries, and reviews overflow behavior.
Range selection starts with the valid minimum and maximum values, then checks signedness, width, boundaries, and overflow behavior before the field type is accepted.
iotclass.org

Major section

Under the Hood: Ranges, Two's Complement, and Byte Order (continued)

Each digit's value is its symbol times the base raised to the digit's position.

  • Fixed-Width RangesAn IoT field usually has a fixed number of bits, which caps how many distinct values it can hold.
  • A signed 8-bit field holds -128 to 127.
  • Contract Must Record.
iotclass.org

Major section

Under the Hood: Ranges, Two's Complement, and Byte Order (continued)

Signed overflow must not be assumed to wrap.

  • An unsigned 16-bit field holds 0 to 65535.
  • Include fault values before testing a candidate width, so an unusual reading cannot silently exceed the chosen range.
  • Silent unsigned wraparound is a classic source of impossible-looking jumps in counters and timers.
iotclass.org

Major section

Under the Hood: Ranges, Two's Complement, and Byte Order (continued)

A type is suitable only when every valid value fits and the out-of-range behaviour is deliberate.

  • When an out-of-range result is stored in an unsigned N-bit field, it wraps modulo 2^N instead of saturating.
  • Two's Complement and SignAlmost all systems store signed integers in two's complement, where the most significant bit carries negative weight.
  • Encoding, byte limit, allowed characters, invalid-input behavior.
iotclass.org

Major section

Under the Hood: Ranges, Two's Complement, and Byte Order (continued)

The same bits decode very differently depending on whether the field is signed.

  • Byte Order (Endianness)A multi-byte value can be stored most significant byte first (big-endian) or least significant byte first (little-endian).
  • Both results are real integers, so a byte-order mistake rarely throws an error.
  • Below, the character policy controls accepted symbols, while the byte limit controls storage.
  • Misread status because reserved bits were assumed zero.
iotclass.org

Major section

Under the Hood: Ranges, Two's Complement, and Byte Order (continued)

It quietly produces a wrong-but-plausible value, which makes endianness one of the hardest representation bugs to spot without a known-good test vector.

  • In UTF-8, a character occupies one to four bytes: the ASCII range uses a single byte, while many accented, symbol, and non-Latin characters use more.
  • Counting characters is therefore not the same as counting bytes, so a field limited to a fixed number of bytes may hold fewer characters than expected.
  • Ignoring signedness: A fault code stored as a small negative number can be read as a huge positive counter.
iotclass.org

Major section

Under the Hood: Ranges, Two's Complement, and Byte Order (continued)

Common PitfallsReading hexadecimal as decimal: The base must be confirmed first, or values can be wrong by amounts that depend on the digits.

  • Assuming byte order: Without a documented order, a value can decode to a believable wrong number that survives into dashboards.
  • Treating text as unlimited: Identifiers and topic names still occupy bytes, and multi-byte characters can overflow a fixed field.
  • Changing a schema without versioning: If field order or meaning changes silently, deployed receivers decode new payloads as old ones.
  • Canonical network order is useful precisely because it makes that hidden agreement common across implementations.
iotclass.org

Major section

Checkpoint: Summary · Key Takeaway

Raw bytes are evidence; their meaning comes from a shared interpretation contract, not from the bytes alone.

  • Numeric fields need base, width, signedness, byte order, scale, and units before they can be trusted.
  • Two's complement and endianness can both turn the same bytes into different, plausible values, so signedness and byte order must be documented per field.
  • Fixed-width fields have hard ranges; unsigned results wrap modulo 2^N, while signed overflow needs an explicit policy.
iotclass.org

Deck summary

Key takeaways

Firmware means the program stored on a device to control its hardware.

  • They could be a price of ten dollars and fifteen cents, a time of 10:15, a year, a part number, or a temperature of 101.5 stored in tenths.
  • This gives: Bytes Are Evidence, Meaning Is a Contract evidence to revisit.
  • A number that "looks reasonable" is not proof that the rules were right.
  • Encoding and scale carry meaningText needs an encoding, and raw integers usually need a scale and units before they become real measurements.
iotclass.org

Retrieval practice

Recall question 1

Physics Phoebe says: answer from memory, then check your reasoning.

Q1A packet carries a measurement, a device label, status flags, and a structured event. Which review matches each to the right proof?

ACheck value range, label length, flag bits and event schema.
BUse numeric range checks for text labels and event objects.
CUse text length alone for every packet field, including status flags.
DTreat the event as self-describing because it arrived in a packet.
Show answer

Answer: A Each representation needs a different decoding and validation rule.

iotclass.org

Retrieval practice

Recall question 2

Physics Phoebe says: answer from memory, then check your reasoning.

Q2Two systems receive the exact same bytes but report two different values. What is the most likely cause?

AThey applied different interpretation rules, such as a different width.
BOne sensor must be broken because identical bytes should produce identical readings on both systems.
CBytes are inherently ambiguous and can never be decoded reliably
DThe network reordered the bits during transmission
Show answer

Answer: A Identical bytes only decode to the same value when both ends share the same representation contract.

iotclass.org

Retrieval practice

Recall questions 3 and 4

Physics Phoebe says: answer from memory, then check your reasoning.

Q3A payload field is documented as signed 16-bit, big-endian, in tenths of a degree, and the bytes are 00 EB. What value should be reported?

AReport 23.5 degrees C.
BReport 235 degrees C.
CReport -23.5 degrees C.
DRequest calibration offset.
Show answer

Answer: A 0x00EB is 235, the top bit is clear so it is positive, and tenths of a degree gives 23.5.

Q4The two bytes FF 38 are decoded as a signed 16-bit big-endian integer. What value results?

ASigned value: -200
BUnsigned reading: 65336
CPositive value: 200
DNegative value: -65336
Show answer

Answer: A 0xFF38 is 65336 as unsigned, and as a signed 16-bit value it is 65336 - 65536 = -200.

iotclass.org

Print reference

Answers

Answer key.

  1. A · Each representation needs a different decoding and validation rule.
  2. A · Identical bytes only decode to the same value when both ends share the same representation contract.
  3. A · 0x00EB is 235, the top bit is clear so it is positive, and tenths of a degree gives 23.5.
  4. A · 0xFF38 is 65336 as unsigned, and as a signed 16-bit value it is 65336 - 65536 = -200.
iotclass.org
When the lecture answer frame appears, check four decisions. Match each field to its validation rule. Compare the two receiver contracts. Decode zero-zero-E-B as twenty-three point five degrees Celsius. Decode F-F-three-eight as minus two hundred. If one result differs, find the first rule you skipped.