9 Edge Acquisition: Power and Gateway Functions
9.1 Overview
This first route builds the power ledger and defines the translation, buffering, and security functions a non-IP gateway must own.
This is part 1 of 2. Continue with Edge Acquisition: Missing Data and Field Design for the second focused route.
9.2 Start With the Story
Spend the Battery on the Field Decision
Picture a vineyard unit that checks soil once each hour and sends a warning only when plants may be at risk. The team wants a full season of life, but a bench test shows only the current used during one quick reading.
List every state in one day: sleep, wake, sense, compute, send, listen, retry, and recover. A duty cycle is the share of time spent active compared with the full period. Multiply each state current by its time. Add the rare bad day when the link is weak or the unit restarts.
A protocol is the agreed set of rules used for an exchange. LoRaWAN is a long-range, low-power set of network rules for small radio messages. Its reach can help a field unit, but retries, receive windows, and poor coverage still spend energy. Measure them at the site.
A gateway is the unit that links the field radio network to another service. Turn it off during the trial. The sensor should keep the fact with its source, time, unit, and quality. It should send later without hiding the gap or sending the same event as new.
Change one factor at a time. Shorten the report period. Add a retry. Cool the battery. Delay the outside link. Compare life, warning time, lost facts, and recovery work against written pass limits.
Put the result in a daily table that a field worker can read. Show the normal day, weak-link day, and restart day. Name the largest cost and the next change worth testing. Keep the raw measure beside the estimate.
Repeat the table after the case, antenna, battery, or code changes. A small change can alter wake time or cause more retries. The old life claim must not follow the product without a new check.
This first budget is a useful estimate, not a life guarantee. Practitioner builds the full state and gateway plan. Under the Hood follows missing data, admission rules, battery chemistry, and failure cases that a simple average cannot show.
Picture an IoT team using the ideas in Edge Power and Gateways during a live operations review. A device has produced messy evidence, an analytic step is about to change an alert or control decision, and someone has to explain why the result should be trusted.
Read this page as that path from sensor evidence to accountable action. Start with what the system observes, keep the model or data treatment visible, and finish with the check that would convince an operator, maintainer, or auditor to act.
This chapter has two linked jobs:
- First turn active, transmit, and sleep current into a battery-life ledger.
- Then optimize the duty cycle and test it with the calculator.
- Next move from devices to gateways: translation, buffering, security, and missing-data handling.
- Finally pressure-test the ideas with vineyard, LoRaWAN, wildlife collar, and store-and-forward cases.
Checkpoints recap the main decisions. Optional calculation panels can be collapsed on a first read.
9.3 Learning Objectives
By the end of this chapter, you will be able to:
- Calculate Power Budgets: Compute battery life for IoT devices based on duty cycling and transmission patterns
- Design Duty Cycling Strategies: Configure active, transmit, and sleep cycles and evaluate their impact on battery longevity
- Explain Gateway Functions: Describe how gateways enable non-IP devices to participate in IoT networks through protocol translation
- Implement Store-and-Forward: Design and assess reliable data pipelines that survive network outages
Edge data acquisition is about collecting and pre-processing sensor data right where the devices are, before sending it to the cloud. Think of a smart mailroom that sorts and summarizes incoming letters instead of forwarding every piece of junk mail to the CEO. This local filtering saves bandwidth, reduces costs, and speeds up responses.
9.4 Prerequisites
Before diving into this chapter, you should be familiar with:
- Edge Data Acquisition: Architecture: Understanding device categories and connectivity paths
- Edge Data Acquisition: Sampling and Compression: Data reduction techniques for bandwidth optimization
- Basic electrical concepts: Familiarity with current, voltage, and power calculations
9.5 Power Management and Duty Cycling
Start with the device: every gateway promise depends on a node that wakes, measures, transmits, and sleeps again.
Key Concepts
- Energy harvesting: Generating power for edge devices from ambient sources (solar, vibration, thermal gradients, RF) to enable autonomous operation in locations without permanent power infrastructure.
- Duty cycling: Periodically powering down sensor hardware and radio between measurements to dramatically reduce average current consumption, extending battery life from days to years.
- Gateway protocol translation: Converting between device-side protocols (BLE, Zigbee, Modbus) and cloud-side protocols (MQTT, HTTPS, AMQP) at the gateway, enabling heterogeneous device ecosystems to integrate with standard cloud platforms.
- Store-and-forward: A gateway capability that buffers sensor data locally during connectivity outages and transmits it to the cloud when connectivity is restored, preventing data loss during network failures.
- Power budget analysis: A calculation determining the average power consumption of an edge device across all operating modes (active sensing, radio transmission, sleep) to estimate battery life or harvesting requirements.
- Watchdog timer: A hardware timer that resets the microcontroller if not periodically refreshed by the application, providing automatic recovery from software hangs in unattended edge deployments.
Battery life is the primary constraint for most edge IoT devices. Understanding power consumption patterns is essential for designing practical systems.
9.6 Power States
Most IoT microcontrollers support multiple power states:
| State | ESP32 Current | Activity |
|---|---|---|
| Active | 80-240 mA | CPU + Wi-Fi active |
| Light Sleep | 0.8 mA | CPU paused, Wi-Fi off |
| Deep Sleep | 10 uA | Only RTC active |
| Hibernation | 2.5 uA | Only wake timer |
9.7 Duty Cycling Formula
Average current consumption with duty cycling:
Where:
- = time in active mode (sensing, processing)
- = time transmitting
- = time in sleep mode
- , , = current draw in each mode
Battery life calculation:
9.8 Example Calculation
Scenario: ESP32 with 2500 mAh battery
| Mode | Duration (per hour) | Current | Energy Contribution |
|---|---|---|---|
| Active | 30 seconds | 25 mA | 0.208 mAh |
| Transmit | 10 seconds | 120 mA | 0.333 mAh |
| Deep Sleep | 3560 seconds | 0.01 mA | 0.010 mAh |
Average current: (30 x 25 + 10 x 120 + 3560 x 0.01) / 3600 = 0.55 mA
Battery life: 2500 mAh / 0.55 mA = 4,545 hours = 189 days
9.9 Optimized Design
Reduce active to 5 seconds, transmit to 2 seconds:
| Mode | Duration (per hour) | Current | Energy Contribution |
|---|---|---|---|
| Active | 5 seconds | 25 mA | 0.035 mAh |
| Transmit | 2 seconds | 120 mA | 0.067 mAh |
| Deep Sleep | 3593 seconds | 0.01 mA | 0.010 mAh |
Average current: (5 x 25 + 2 x 120 + 3593 x 0.01) / 3600 = 0.112 mA
Battery life: 2500 mAh / 0.112 mA = 22,321 hours = 2.5 years
Improvement factor: 4.9x (from ~6 months to 2.5+ years)
9.10 External Nano-Power Timer and Load Disconnect
Deep sleep still leaves the MCU, regulator, sensor bias network, and board leakage connected to the battery. When the sampling interval is minutes or hours, an external timer can make a stronger boundary: it powers the load only for one acquisition transaction, then physically disconnects that load after firmware reports completion.
A TPL5110-class arrangement has two power domains. The timer remains connected to the battery at nanoamp-class quiescent current. Its DRV output controls a MOSFET or load switch feeding the MCU, sensors, and radio. The MCU’s DONE output returns to the timer. Keep those signals distinct from a reset pin: DRV controls energy to the entire load, while a low-to-high DONE transition is the firmware’s declaration that durable work has finished. For the TPL5110 specifically, DRV low turns the external MOSFET on and DRV high turns it off; other timer/load-switch combinations may use the opposite polarity.
Follow one cycle:
- Off interval.
DRVholds the TPL5110’s MOSFET off, and only timer, switch leakage, and any deliberately retained domain draw current. - Timed wake. At the programmed interval, the TPL5110 drives
DRVlow; the MOSFET conducts, the rail rises, and the MCU starts from reset rather than resuming retained RAM. - Acquire and transmit. Firmware initializes peripherals, samples the sensor, records a timestamp or sequence, and attempts the bounded communication policy.
- Commit state. Before shutdown, firmware stores only the state required for the next cold boot and verifies that the write or queued hand-off completed.
- Assert
DONE. A clean low-to-high transition tells the timer to driveDRVhigh. The MOSFET removes power until the next interval.
The energy ledger must include the always-on timer and switch leakage. For a period , load-on time , load current , timer current , and off-state leakage ,
Suppose the load draws 25 mA for 0.50 s every 600 s, the timer draws 0.035 microamps, and the disconnected load path leaks 0.10 microamps:
The active burst still dominates, but the example shows why board leakage belongs beside the timer data-sheet number. A 10 microamp regulator or programming interface left across the battery would materially change the result even though the MCU is physically off.
| Design boundary | Question to prove |
|---|---|
| Rail rise | Does voltage settle before the MCU or sensor leaves reset, including battery and cold-temperature impedance? |
| Cold boot | Can all required state be reconstructed without retained RAM? |
DONE timing | Is DONE asserted only after flash writes, radio hand-off, and output-safe state complete? |
| Failed transaction | Does firmware stop after a bounded retry count and record loss honestly rather than keeping the rail on forever? |
| Hung firmware | Does the programmed maximum-on interval bound a missing DONE, and is a shorter independent watchdog also required? |
| Manual/service wake | Can a technician wake the unit without creating an unbounded bypass current? |
For the TPL5110, a missing DONE does not leave the load on indefinitely. The device holds the load on for the programmed interval minus roughly 50 ms, then forces DRV high for the final 50 ms before the next cycle. That maximum-on window is a hardware recovery boundary, but it may be far longer than the application’s safe fault time. Choose the interval so legitimate cold boot, sensing, and radio retries fit, then add an independent watchdog when a hung actuator or high-current radio must be cut off sooner. Record both the normal DONE time and the forced-off time in the fault test.
9.11 Interactive Battery Life Calculator
Use this calculator to explore how duty cycling parameters affect battery life. Adjust active time, transmit time, current draw, and battery capacity to see real-time results.
Why does transmission dominate power budget?
For an ESP32 with LoRa module transmitting 50 bytes:
- Deep sleep: 10 µA × 3600s = 0.01 mAh/hour
- Active (sensing): 80 mA × 5s = 0.111 mAh per activation
- LoRa TX (SF7, +14 dBm): 120 mA × 2s = 0.067 mAh per transmission
Energy per transmission:
Energy per sensing:
Total active energy: per cycle
If transmitting every 5 minutes (12×/hour):
- Active/TX energy:
- Sleep energy:
- TX represents of total energy
Batching strategy: Transmit 6 readings once per 30 min (2×/hour) instead of 12×/hour:
- Active/TX energy:
- Battery life improves by
Radio dominates because TX power (120 mA) is 12× higher than active CPU (10 mA baseline), even though TX duration is shorter.
Checkpoint: Duty-Cycle Ledger
You now know:
- Baseline: 0.55 mA average gives 4,545 hours, or 189 days, from 2500 mAh.
- Optimized: 5 seconds active and 2 seconds transmit drops average current to 0.112 mA.
- Result: 22,321 hours, about 2.5 years, or 4.9x better than baseline.
9.12 Knowledge Check: Battery Life
9.13 Quiz 1: Battery Life Calculation
9.14 Gateway Functions for Non-IP Devices
The hardware photograph in Figure 9.1 grounds the gateway discussion in its two physical boundaries: field-side interfaces and an IP-capable processing and network side. Inspect the visible connector groups before assigning software responsibilities to the board.
Photo: Laserlicht, CC BY-SA 4.0
Read Figure 9.1 from the GPIO header to the processor, memory, USB, and Ethernet interfaces. The header can meet sensors or controllers through local electrical interfaces; the Linux-capable compute and network ports can buffer records, translate protocols, keep logs, and establish secure upstream sessions. The board itself does not guarantee any of those behaviors. It connects the chapter’s running narrative to implementation: gateway responsibility comes from the software, credentials, storage, and failure policy built across those two sides.
Once the node can survive on battery, ask whether its data can cross protocols and outages.
Gateways serve as critical bridges between non-IP devices and the internet. Key functions include:
9.15 Protocol Translation
- Convert sensor-specific protocols (Modbus, BACnet, Zigbee) to IP protocols
- Translate between MQTT, CoAP, and HTTP as needed
- Handle message format conversion (binary to JSON)
9.16 Data Buffering
A field gateway needs a buffering contract before an outage proves it missing. Figure 9.2 follows one vineyard reading from durable append through bounded storage, oldest-first replay, and cloud reconciliation.
In Figure 9.2, Append preserves sensed_at and sequence before the link fails, while Bound makes the 96 kB limit operational rather than silently overwriting evidence. After Reconnect, the durable ACK cursor advances only on receipt; Reconcile then prevents a replayed noon value from masquerading as a current sample.
- Store data during network outages
- Batch multiple sensor readings for efficient transmission
- Implement store-and-forward for intermittent connectivity
9.17 Security Functions
Energy optimisation becomes unsafe when it removes the mechanisms that make a command dependable. Figure 9.3 puts the secure wake and recovery work inside the same charge ledger as sleep and radio transmission.
The Wake defensibly card in Figure 9.3 checks brownout, secure boot, and a monotonic counter before the valve rail is enabled. Recover safely reserves enough energy for signature verification, flash writing, reboot, and reporting, making security and rollback cross-cutting power requirements rather than optional radio overhead.
The gateway diagram in Figure 9.4 brings protocol translation, buffering, and security into one route so the trust checks can be placed before data or commands cross the boundary.
- Encrypt data before transmission to cloud
- Authenticate devices and manage credentials
- Filter and validate incoming commands
Inspect Figure 9.4 now to see where those checks sit relative to protocol translation, outage buffering, and the cloud-facing session.
Trace Figure 9.4 from the non-IP protocols through translation and buffering to the cloud-facing IP path. Then inspect the security layer across that flow: device identity belongs at admission, encryption protects the upstream session, validation constrains payloads, and buffering must preserve protected records during outages. Security is therefore not a final wrapper around translated data. This completes the gateway narrative by showing that semantic preservation, outage recovery, and trust enforcement are simultaneous responsibilities at the same boundary.
9.18 Fail-Closed Gateway Admission Control
Read the Fail-Closed Gateway Admission Control material as a decision path rather than as isolated entries. First identify the operating condition in each entry and keep its units, timing, source, and assumed system state attached to it. Next compare the entries at the point where responsibility changes between device, gateway, network, analytic service, and operator; that hand-off is where apparently similar choices often produce different outcomes. Then follow the failure case: ask what becomes stale, delayed, unavailable, or unsafe, who detects it, and what evidence permits recovery. Finally connect the result to the chapter’s running design record by naming the selected behavior, the rejected alternative, the measurement that justifies the choice, and the condition that forces a recheck. That order turns the examples or comparison into an auditable engineering argument.
For industrial or safety-critical gateways, security should start before the protocol bridge accepts a device. A fail-closed gateway uses a default-deny policy:
- Check the device identity first, such as an approved MAC address, serial number, certificate, or provisioning record.
- Reject and log unknown devices before TLS or application traffic begins.
- Start the TLS or mTLS handshake only for approved devices.
- Apply command filtering and payload validation before forwarding data to the cloud or issuing actuator commands.
| Choice | Use when | Risk if chosen poorly |
|---|---|---|
| Fail-closed whitelist | Critical infrastructure, industrial gateways, small controlled fleets | Stale allow-lists can block legitimate replacements until provisioning is updated. |
| Fail-open blacklist | Consumer or rapidly changing fleets where onboarding speed dominates | Unknown or cloned devices may connect before they are explicitly blocked. |
Encryption protects data confidentiality, but it does not prove device identity by itself. A gateway that validates identity, encrypts transport, and rejects unknown devices before forwarding traffic has a smaller attack surface than a gateway that only wraps every connection in TLS.
Checkpoint: Gateway Responsibilities
You now know:
- Protocol translation maps Modbus, BACnet, and Zigbee into MQTT, HTTPS, or AMQP.
- Store-and-forward keeps readings during outages instead of losing the time window.
- Fail-closed admission checks identity first, rejects unknown devices, then starts TLS or mTLS.
9.19 Continue to Part 2
Continue with Edge Acquisition: Missing Data and Field Design.
