---
title: "Solar sensor node: the radio link"
heading: Choosing the node's bit rate and transmit schedule, receiver sensitivity from the noise floor, free-space and ground-level range, the time each packet spends on the air, the energy it costs, and how range and battery life trade against each other
eyebrow: D13 · Lesson 4 · Solar sensor node
xp: 40
---

::: hook
The radio is usually the hungriest part of a sensor node: tens of milliamps while it transmits, against microamps asleep. Its two big choices pull against each other. A slower bit rate makes the receiver more sensitive, so the link reaches farther, but every packet stays on the air longer and costs more energy. A good design picks the slowest rate that still fits the battery, and a transmit schedule that fits the data.
:::

::: play
- The link margin of an 868 MHz node at 14 dBm with 2.15 dBi antennas and 1 dB of cable loss, against distance, in free space and over flat ground with antennas 2 m and 10 m high (the two-ray model of D9, valid beyond a few hundred meters).
- The receiver's sensitivity is $-174 + 10\log_{10}R + 6 + 10$ dBm: thermal noise in the bit rate's bandwidth, a 6 dB noise figure and 10 dB of SNR for the demodulator.
- Lower the bit rate: every factor of 4 buys 6 dB, which doubles free-space range but only multiplies ground-level range by √2. The airtime readout shows what it costs.
:::

```sim plot
view: graph
x: d = 0.1..50 log
y: M = -40..70
slider: P = 0..20 = 14 dBm
slider: R = 300..50000 = 4800 log
plot: P + 4.3 - 1 - (-174 + 10*log(R) + 16) - (20*log(d) + 20*log(868) + 32.44) | samples: 400 | label: margin in free space, dB (d in km)
plot: P + 4.3 - 1 - (-174 + 10*log(R) + 16) - (40*log(d) + 120 - 20*log(20)) | samples: 400 | color: ch3 | label: margin over flat ground
plot: 10 + 0*d | dashed | color: ch4 | label: 10 dB margin
readout: sensitivity, dBm = -174 + 10*log(R) + 16 | digits: 4
readout: ground range at 10 dB margin, km = 10^((P + 4.3 - 1 - (-174 + 10*log(R) + 16) - 10 + 20*log(20) - 120)/40) | digits: 3
readout: airtime of a 20-byte frame, ms = 240/R*1000 | digits: 3
```

::: predict
## A node lowers its bit rate from 4800 to 1200 bit/s. How much does its range over flat ground grow?

- [ ] It doesn't change
- [x] By √2, about 41%
- [ ] It doubles
- [ ] It quadruples

::: reveal
A quarter of the bit rate is a quarter of the noise bandwidth, 6 dB more sensitivity. Over flat ground the received power falls as $1/d^4$, so 6 dB buys a factor of $10^{6/40}$ = 1.41 in distance; in free space ($1/d^2$) it would double. Meanwhile each packet takes four times as long to send.
:::
:::

::: nameit
## Sensitivity

The receiver needs a certain SNR in a bandwidth about equal to the bit rate R, above the thermal floor of −174 dBm/Hz plus its noise figure:

$$S = -174 + 10\log_{10}R + \text{NF} + \text{SNR}_\text{req}\ \text{dBm}$$

## Range

The allowed path loss is $P_t + G_t + G_r - L - S - \text{margin}$. Free space loses $20\log_{10}(4\pi d/\lambda)$, so range scales as $10^{\text{dB}/20}$; near the ground, beyond the breakpoint $4h_th_r/\lambda$ (232 m for 2 m and 10 m at 868 MHz), loss is $40\log_{10}d - 20\log_{10}(h_th_r)$ and range scales as $10^{\text{dB}/40}$ (D9). Raising an antenna helps as much as more power.

## Airtime and energy

A frame of $8n + 80$ bits (D12's framing with a CRC) takes $(8n + 80)/R$ seconds. Each transmission costs $I_\text{tx}V$ times that, and averaged over the reporting interval it adds $I_\text{tx}t_\text{air}/T$ to the node's current.

## Choosing

Pick the slowest bit rate whose airtime still fits the energy budget and any duty-cycle rule (the 868 MHz band limits most devices to 1% of the time on air), and report no more often than the data needs.
:::

::: example
## What's the free-space range at 4800 bit/s with a 20 dB margin, and the ground-level range at 10 dB?

::: solution
1. **Sensitivity at 4800 bit/s.**
   $$\begin{aligned} S &= -174 + 36.8 + 16 \\ &= -121.2\ \text{dBm} \end{aligned}$$
2. **Free-space range.** With a 20 dB margin the allowed loss is
   $$\begin{aligned} L &= 14 + 4.3 - 1 \\ &\quad + 121.2 - 20 \\ &= 118.5\ \text{dB} \end{aligned}$$
   which free space reaches at 23.1 km.
3. **Ground-level range.** With 10 dB of margin the allowed loss is 128.5 dB:
   $$\begin{aligned} d &= 10^{(128.5 + 26.0 - 120)/40}\ \text{km} \\ &= 7.3\ \text{km} \end{aligned}$$
4. **At 1200 bit/s.** The ground-level range grows to 10.3 km.

**Answer:** 23.1 km in free space with a 20 dB margin, and 7.3 km near the ground with 10 dB (10.3 km at 1200 bit/s).
:::
:::

::: example
## The node sends 20 bytes every 10 minutes at 4800 bit/s, drawing 40 mA while transmitting, 2.05 mA for 5 ms of processing and 0.052 mA asleep. How long does a 2000 mAh battery last?

::: solution
1. **Frame time.**
   $$\begin{aligned} t &= \frac{240}{4800}\ \text{s} \\ &= 50\ \text{ms} \end{aligned}$$
2. **Radio's share.** Averaged over 600 s:
   $$\begin{aligned} I_{\text{radio}} &= \frac{40 \times 0.05}{600}\ \text{mA} \\ &= 3.3\ \mu\text{A} \end{aligned}$$
3. **Processing's share.**
   $$\begin{aligned} I_{\text{cpu}} &= \frac{2.05 \times 0.005}{600}\ \text{mA} \\ &= 0.017\ \mu\text{A} \end{aligned}$$
4. **Total, with about 52 µA asleep.**
   $$\begin{aligned} \bar I &= (3.3 + 0.017 + 52)\ \mu\text{A} \\ &= 55.3\ \mu\text{A} \end{aligned}$$
5. **Battery life.**
   $$\begin{aligned} t &= \frac{2000\ \text{mAh}}{\bar I} \\ &= 1506\ \text{days} \end{aligned}$$
6. **At 1200 bit/s.** The radio's share quadruples to 13.3 µA and the life drops to 1276 days.

**Answer:** about 1506 days at 4800 bit/s, and 1276 days at 1200 bit/s.
:::
:::

::: check
kind: python

## Work out the node's sensitivity, range, airtime and battery life.

```python starter
import math

C = 299792458.0

def fspl_db(d_m, f_hz):
    # Free-space path loss in dB: 20*log10(4*pi*d*f/c).
    return 0.0

def sensitivity_dbm(bitrate, nf_db=6.0, snr_db=10.0):
    # The weakest signal the receiver decodes: -174 dBm/Hz + 10*log10(bitrate) + noise figure
    # + the SNR the demodulator needs.
    return 0.0

def max_range_m(p_dbm, gains_db, losses_db, sens_dbm, f_hz, margin_db):
    # The distance at which free-space loss leaves exactly margin_db above the sensitivity.
    return 0.0

def airtime_s(payload_bytes, bitrate):
    # A frame of 8*payload_bytes + 80 bits (D12's frame with its CRC) at bitrate bits per second.
    return 0.0

def battery_days(capacity_mah, interval_s, payload_bytes, bitrate,
                 tx_ma=40.0, awake_ma=2.05, awake_s=0.005, sleep_ma=0.052):
    # Every interval_s the node is awake for awake_s and transmits for the frame's airtime, and
    # sleeps the rest. Average the three currents over the interval and return the battery's life
    # in days.
    return 0.0
```

```python solution
import math

C = 299792458.0

def fspl_db(d_m, f_hz):
    return 20*math.log10(4*math.pi*d_m*f_hz/C)

def sensitivity_dbm(bitrate, nf_db=6.0, snr_db=10.0):
    return -174 + 10*math.log10(bitrate) + nf_db + snr_db

def max_range_m(p_dbm, gains_db, losses_db, sens_dbm, f_hz, margin_db):
    allowed = p_dbm + gains_db - losses_db - sens_dbm - margin_db
    return C/(4*math.pi*f_hz)*10**(allowed/20)

def airtime_s(payload_bytes, bitrate):
    return (8*payload_bytes + 80)/bitrate

def battery_days(capacity_mah, interval_s, payload_bytes, bitrate,
                 tx_ma=40.0, awake_ma=2.05, awake_s=0.005, sleep_ma=0.052):
    t = airtime_s(payload_bytes, bitrate)
    avg = (tx_ma*t + awake_ma*awake_s + sleep_ma*(interval_s - t - awake_s))/interval_s
    return capacity_mah/avg/24
```

```python tests
assert abs(fspl_db(5000, 868e6) - 105.2) < 0.05, f"5 km at 868 MHz loses 105.2 dB; got {fspl_db(5000, 868e6):.2f}."
assert abs(sensitivity_dbm(4800) - (-121.2)) < 0.05, f"At 4800 bit/s the sensitivity is −174 + 36.8 + 6 + 10 = −121.2 dBm; got {sensitivity_dbm(4800):.2f}."
_d = max_range_m(14, 4.3, 1, sensitivity_dbm(4800), 868e6, 20)
assert abs(fspl_db(_d, 868e6) - (14 + 4.3 - 1 + 121.19 - 20)) < 0.02, "At the maximum range the path loss uses up everything but the margin."
assert abs(_d/1000 - 23.1) < 0.05, f"That's about 23.1 km in free space; got {_d/1000:.2f} km."
assert abs(airtime_s(20, 4800) - 0.05) < 1e-12, "20 bytes plus 80 bits of frame at 4800 bit/s take 50 ms."
_life = battery_days(2000, 600, 20, 4800)
assert abs(_life - 1506) < 2, f"A report every 10 minutes leaves the battery about 1506 days; got {_life:.0f}."
assert battery_days(2000, 600, 20, 1200) < _life, "A slower bit rate keeps the transmitter on longer."
```

::: right
Right. Your budget finds 23.1 km of free-space range at 4800 bit/s and 1506 days of battery, and shows the slower rate costing battery life.
:::
:::

::: check
given: R = 300 | 1200 | 4800 | 50000; F = 3 | 6 | 10
answer: -174 + 10*log(R) + F + 10
unit: dBm
tolerance: 0.5%

## A receiver has a {F} dB noise figure and needs 10 dB of SNR at {R} bit/s. What's its sensitivity?

::: right
Right. −174 + 10 log {R} + {F} + 10 = {answer} dBm.
:::

::: misses
- [-174 + 10*log(R) + 10] Include the noise figure.
- [any] Not yet. The thermal floor in the bit rate's bandwidth, plus the noise figure and the required SNR.
:::
:::

::: check
given: n = 10 | 20 | 50; R = 1200 | 4800 | 50000
answer: (8*n + 80)/R*1000
unit: ms
tolerance: 0.5%

## How long is a frame with {n} payload bytes and 80 bits of framing on the air at {R} bit/s?

::: right
Right. {answer} ms.
:::

::: misses
- [8*n/R*1000] Count the framing bits too.
- [any] Not yet. Bits over the bit rate.
:::
:::

::: check
given: M = 2 | 4 | 10 | 16
answer: M^0.25
tolerance: 0.5%

## A node divides its bit rate by {M}. By what factor does its range over flat ground grow?

::: right
Right. $10\log_{10}M$ dB of sensitivity, and range goes as the 40th root of the dB: $M^{1/4}$ = {answer}.
:::

::: misses
- [sqrt(M)] That's free space, where loss grows as $d^2$.
- [any] Not yet. Ground-level loss grows as $d^4$.
:::
:::

::: check
given: I = 20 | 40 | 120; t = 20 | 50 | 200; T = 60 | 600 | 3600
answer: I*t/T
unit: µA
tolerance: 0.5%

## A radio draws {I} mA for {t} ms every {T} s. How much does it add to the node's average current?

::: right
Right. {I} mA × {t} ms/{T} s = {answer} µA.
:::

::: misses
- [I*t/T/1000] Check the units: mA × ms/s is µA.
- [any] Not yet. Current times on-time over the interval.
:::
:::

::: check
kind: parts
given: Pt = 0 | 10 | 14; f = 433 | 868 | 2450; d = 0.5 | 2 | 5; S = -100 | -110

## A link sends {Pt} dBm at {f} MHz over {d} km between 0 dBi antennas; the receiver's sensitivity is {S} dBm.

::: part
answer: 20*log(4*pi*d*1e3*f*1e6/2.998e8)
tolerance: 0.5%

### What is the free-space path loss, in dB?

::: misses
- [10*log(4*pi*d*1e3*f*1e6/2.998e8)] Path loss in dB is $20\log_{10}(4\pi d/\lambda)$.
- [any] Not yet. $20\log_{10}(4\pi d/\lambda)$.
:::
:::

::: part
answer: Pt - 20*log(4*pi*d*1e3*f*1e6/2.998e8) - S
tolerance: 0.5%

### What is the link margin, in dB?

::: misses
- [Pt - 20*log(4*pi*d*1e3*f*1e6/2.998e8) + S] The margin is the received power minus the sensitivity.
- [any] Not yet. $P_t - L - S$.
:::
:::

::: right
Right. Free space is the best case; real links need extra margin for walls, foliage and fading.
:::
:::

::: check
given: m = 6 | 12 | 20; d = 1 | 3
answer: d*10^(m/20)
unit: km
tolerance: 0.5%

## A free-space link closes at {d} km with {m} dB of spare margin. How far could it reach with zero margin?

::: right
Right. Free-space loss grows 20 dB per decade of distance, so {m} dB buys a factor $10^{m/20}$: {answer}.
:::

::: misses
- [d*10^(m/10)] Path loss in free space goes as $d^2$: use $10^{m/20}$ for distance.
- [any] Not yet. $d \times 10^{m/20}$.
:::
:::

::: explain
## Why does a lower bit rate reach farther, and what does it cost?

::: model
The receiver's noise power is proportional to the bandwidth it listens to, and that bandwidth is set by the bit rate, so slowing the data narrows the bandwidth and lets less noise in. The same received signal then has more SNR, so the link still works at a weaker signal, which means a greater distance. The cost is time: each packet takes proportionally longer to send, so the transmitter is on longer and uses more energy per packet, and the channel is occupied longer, which matters for duty-cycle limits and for other nodes sharing it.
:::
:::

::: practice

::: check
given: R = 100 | 1e6; F = 2 | 15
answer: -174 + 10*log(R) + F + 10
unit: dBm
tolerance: 0.5%

## Sensitivity at {R} bit/s, NF {F} dB?

::: misses
- [any] $-174 + 10\log_{10}R + \text{NF} + 10$.
:::
:::

::: check
given: I = 5 | 300; t = 2 | 1000; T = 10 | 86400
answer: I*t/T
unit: µA
tolerance: 0.5%

## Radio's average: {I} mA for {t} ms every {T} s?

::: misses
- [any] $I_\text{tx}t/T$.
:::
:::
:::
