An STM32 build for aging in place: 60 GHz mmWave vital-sign radar, fall detection and OneNet cloud monitoring
For an elderly person living alone, the dangerous moments are the quiet ones. A fall in the bathroom, a heart that suddenly races, a gas burner left on — none of them announce themselves, and by the time a relative notices an unanswered phone call it may be hours too late.
The obvious answer has been the wearable: a wristband or a pendant with an emergency button. It works exactly as long as the wearer remembers to put it on, keeps it charged and can still reach the button after falling. In practice that is three assumptions too many.
A 60 GHz millimetre-wave radar removes all three. Mounted on a wall or ceiling, it reads the tiny chest movement caused by breathing and heartbeat, reports whether the room is occupied, and estimates posture — with nothing worn, nothing pressed and no camera image captured. This project is a complete, reproducible teaching build around that idea: an STM32F103C8T6 at the centre, an R60ABD1 60 GHz vital-sign radar as the sensor, an ESP8266 for Wi-Fi, and OneNet as the cloud dashboard a family member opens on a phone.
What the system actually does
Eight functions run on one MCU:
- Contactless breathing and heart rate. The radar faces the person's chest and reports a respiratory rate (0–25 breaths/min) and a heart rate (0–100 bpm) roughly every three seconds — no chest strap, no wristband.
- Presence detection. The radar decides whether the monitored area is occupied, so a long absence can be flagged as the person having left the room.
- Fall detection and alarm. Two sources feed this: the radar's own motion, posture and in-bed/out-of-bed reporting, plus a software check on the vital-sign time series.
- Body temperature. An MLX90614 infrared thermometer reads forehead or wrist temperature contactlessly and alarms above 38 °C.
- Room temperature and humidity. A DHT11 on a single-wire bus.
- Carbon monoxide. An MQ7 sensor watches for gas, with an alarm above threshold.
- Local alarm. An active buzzer sounds if heart rate is above 110 bpm, body temperature above 38 °C, CO above 80 %, or a fall is detected.
- Cloud upload. The ESP8266 pushes all eight values over MQTT to OneNet, where a drag-and-drop visual page becomes the remote monitor.
A 1.44-inch TFT shows the same values locally, in eight rows, so the device is useful with no network at all.
Architecture: four layers
The build separates cleanly into sensing, control, transport and application layers.
- Sensing — the R60ABD1 radar (UART), MLX90614 (software I²C), DHT11 (single-wire), MQ7 (analog into an ADC channel) and three push buttons.
- Control — the STM32F103C8T6 parses the radar protocol, polls the other sensors, refreshes the display, evaluates alarm conditions and assembles the upload payload.
- Transport — an ATK-ESP8266 joins the local 2.4 GHz network over AT commands, opens a TCP passthrough connection to the OneNet MQTT broker, and posts JSON data points.
- Application — OneNet stores the values in its device model; the platform's visual editor turns them into a shareable web page for phone and desktop.

Bill of materials
| # | Role | Part | Interface |
|---|---|---|---|
| 1 | MCU | STM32F103C8T6 minimum-system board | — |
| 2 | Debugger | ST-Link | SWD |
| 3 | Vital-sign radar | R60ABD1 (60 GHz) | UART |
| 4 | Wi-Fi | ATK-ESP8266 | UART + AT commands |
| 5 | Display | 1.44" TFT, 128×128 | bit-banged SPI |
| 6 | Body temperature | MLX90614 | software I²C |
| 7 | Room temp/humidity | DHT11 | single-wire |
| 8 | Carbon monoxide | MQ7 | analog / ADC |
| 9 | Alarm | Active buzzer (via SS8050 NPN) | GPIO |
| 10 | Status | LEDs (board + external) | GPIO |
| 11 | Input | 3 tactile buttons | GPIO |

The STM32F103C8T6 is a Cortex-M3 at 72 MHz with 64 KB flash and 20 KB SRAM, three USARTs, two SPI, two I²C blocks and multiple ADC channels — enough for the three serial ports this build needs (one for debug logging, one for the ESP8266, one for the radar), the ADC channel for the MQ7, and the GPIO for screen, buttons, buzzer and LEDs. It is cheap and extremely well documented, which is why it is the standard teaching choice.
One small detail worth copying: the firmware disables JTAG and keeps only SWD, which frees PB3 and PB4 for ordinary I/O. On a project this pin-hungry, two recovered pins matter.
The buzzer deserves its own note. It is an inductive load and the MCU pin cannot source enough current for it, so an SS8050 NPN transistor switches it, with a 1N5819 flyback diode across the buzzer to absorb the reverse voltage when it switches off.
Wiring, and the three supply traps
The radar, ESP8266, MQ7 and MLX90614 all run from 5 V; the TFT runs from 3.3 V. The rule that catches everyone is the crossover: the MCU's TX goes to the module's RX, and the MCU's RX to the module's TX.
Three supply traps are worth stating up front:
- The ESP8266 must have a stiff 5 V rail. Wi-Fi transmit peaks above 300 mA. Feed it 3.3 V, or a weak USB port, and you get the classic symptom: the AT commands answer fine, but the module reboots the moment it tries to join the network.
- MQ7 is a heated sensor. It has a heater inside, so it needs tens of seconds of warm-up before readings settle. The firmware samples a baseline at boot and subtracts it as a zero-point — that is what the
MQ7_basecalibration is for. - Keep the buzzer and LEDs off the sensor supply. High-current switching on the same rail as a sensor will drag the voltage down and reset it.
Talking to the cloud: OneNet over MQTT
OneNet is the China Mobile IoT platform, and this build uses its multi-protocol MQTT product. Data points are posted using the device model, so the eight values map to eight identifiers:
HeartRate, RespiratoryRate, People, Fall, MLX90614, MQ7, DHT11_T, DHT11_H
The spelling is not cosmetic. The JSON key sent by the firmware must match the identifier defined in the product exactly, including case, or the platform silently drops the data point.
Topics follow a fixed shape:
# subscribe: everything the platform sends down
$sys/{PRODUCT_ID}/{DEVICE_NAME}/#
# publish: a JSON data-point batch
$sys/{PRODUCT_ID}/{DEVICE_NAME}/dp/post/json
The login password is not a static secret — it is a token computed from the account's AccessKey with HMAC-SHA1 over a resource string, an expiry timestamp and the method, then Base64-encoded:
version=2018-10-31&res=products%2F{PRODUCT_ID}&et={EXPIRY_TS}&method=sha1&sign={SIGNATURE}
Because the token carries an expiry (et), a device deployed for years will eventually need it regenerated. Keep the small helper script that computes it — it is the difference between a five-minute fix and an afternoon of confusion.
The payload the firmware assembles with a single sprintf looks like this:
{"id":123,"dp":{
"HeartRate":[{"v":80}],
"DHT11_T":[{"v":20}],
"DHT11_H":[{"v":60}],
"MLX90614":[{"v":36.2}],
"MQ7":[{"v":10}],
"People":[{"v":1}],
"Fall":[{"v":0}],
"RespiratoryRate":[{"v":18}]}}
Once the points arrive, OneNet's visual editor assembles the remote page: drag in gauges and number cards, bind each one to a data stream, and add a filter script where a value needs a unit or a label. A temperature card, for example, can prefix the value with text and append the degree symbol; a presence flag can be turned into "in room" or "away".
The radar protocol
The R60ABD1 is a 60 GHz biometric-sensing radar from Hi-Link with the signal processing built in. It is not a raw radar front end — it is effectively a serial sensor that reports finished results: presence, respiration rate, heart rate, motion, in-bed state and sleep state. That packaging is what makes the project approachable: there is no Doppler processing or FMCW maths to write.
Every frame is exactly 10 bytes:
| Byte | Field | Meaning |
|---|---|---|
| 1 | Header 1 | 0x53 ('S') |
| 2 | Header 2 | 0x59 ('Y') |
| 3 | Message type | 0x80 / 0x81 / 0x84 / 0x85 … |
| 4 | Command | 0x01 / 0x02 / 0x05 … |
| 5 | Length high | 0x00 |
| 6 | Length low | 0x01 |
| 7 | Data | the value or state |
| 8 | Checksum | sum of bytes 1–7, low 8 bits |
| 9 | Tail 1 | 0x54 ('T') |
| 10 | Tail 2 | 0x43 ('C') |
Validity is a two-byte test — the frame must open with 0x53 0x59 — and the type byte then selects the branch. The message types this build decodes:
0x80— status:cmd 0x01presence (0x00absent /0x01present),cmd 0x02motion (0x00still /0x01moving /0x02vigorous).0x81— respiration:cmd 0x02carries the respiratory rate, 0–25, reported about every three seconds.0x84— sleep monitoring: in-bed/out-of-bed and sleep stage (light, deep). Reserved here, since the build monitors living areas rather than a bed.0x85— heart:cmd 0x02carries the heart rate, 0–100.
The checksum is a plain byte sum. To enable the vital-sign stream, the firmware sends this ten-byte command:
// enable heartbeat / vital-sign reporting
u8 enable_cmd[] = {0x53,0x59,0x85,0x00,0x00,0x01,0x01,0x3D,0x54,0x43};
// checksum: 0x53+0x59+0x85+0x00+0x00+0x01+0x01 = 0x13D -> low byte 0x3D
The most common trap with this radar follows directly from that: if the heart-rate frames never arrive, suspect the feature is simply not enabled. Send the enable command once during initialisation before assuming a wiring fault.

Two techniques worth stealing
Serial framing with no known frame length
Both the radar and the ESP8266 deliver variable-length frames over UART, so how does the firmware know when a frame has ended? The build uses a neat trick: interrupt-per-byte plus timer-based idle detection.
Every received byte enters the receive interrupt, is appended to a buffer, and resets and restarts a timer. As long as bytes keep arriving the timer never expires. When the line falls silent for ~20 ms, the timer overflows, and the overflow interrupt raises a "frame complete" flag that the main loop picks up.
void USART3_IRQHandler(void) { // radar on USART3
u8 data;
if (USART3->SR & (1 << 5)) { // RX not empty
TIM3->CNT = 0; // reset the idle timer
TIM3->CR1 |= (1 << 0); // start it
data = USART3->DR;
if (USART3_RX_FLAG == 0) // don't overwrite a pending frame
USART3_RX_BUFFER[USART3_RX_CNT++] = data;
}
}
void TIM3_IRQHandler(void) { // 20 ms of silence => one frame
if (TIM3->SR & (1 << 0)) {
TIM3->SR &= ~(1 << 0);
USART3_RX_FLAG = 1;
TIM3->CR1 &= ~(1 << 0); // stop until the next frame starts
}
}
The payoff is a receiver that does not block, does not drop frames and does not need to know the frame length in advance — a pattern that drops onto any serial peripheral, which is why it is written twice here (TIM2 for the ESP8266, TIM3 for the radar).
Fall detection from the vital-sign series
The radar already reports motion and posture, but the firmware adds a second opinion. The idea is simple: a fall or a sudden medical event produces a sharp, short-lived swing in heart rate and respiration, which shows up as a spike in variance. The code keeps the last ten heart-rate and ten respiratory readings in a ring buffer and computes mean and standard deviation. A fall is suspected when all three of these hold at once:
- heart-rate standard deviation > 15,
- respiratory standard deviation > 4,
- current heart rate more than 20 % away from the mean.
A lastFallStatus latch keeps one abnormal episode from re-triggering the buzzer over and over.
This is deliberately described as educational, not medical. A production fall detector should lean on the radar's posture and height sensing first, use vital-sign variance only as a supporting signal, and add duration thresholds and human confirmation to keep false positives down.
Alarm logic
The alarm condition is a single OR across five inputs:
if (HeartRate > 110 || MLX90614 > 38 || MQ7 > 80 || Fall == 1 || Fall_SOS == 1)
BEEP = 1;
else
BEEP = 0;
On the thresholds: above 110 bpm at rest suggests the person is unwell; above 38 °C is a fever; above 80 % CO is the MQ7's relative-concentration ceiling rather than a calibrated ppm figure; Fall is the software verdict; and Fall_SOS is a button-pressed emergency. The three buttons give the build a way to exercise the whole alarm-and-upload path without a radar or a real fall — one button clears the alarm and one simulates an emergency.
A note on the MQ7: the percentage it produces is a relative concentration, adequate for threshold alarming in a teaching build. Real ppm measurement needs calibration against the sensor's sensitivity curve.

Debugging order, and the faults you will actually hit
The most useful advice in the whole build is the order of debugging: modules first, then the network, then everything together. Confirm the screen and the local sensors work on their own, then connect the radar to a USB-serial adapter at 115200 baud and watch for frames opening with 0x53 0x59, then bring up the Wi-Fi and MQTT path while reading the debug log, and only then look at the cloud.
The short list of faults worth memorising:
- No radar data — check baud rate and the TX/RX crossover first; then check the module reports at all on a PC; then suspect the vital-sign feature is not enabled.
- The ESP8266 will not join — it is 2.4 GHz only, so 5 GHz networks are invisible to it; keep SSIDs ASCII; give it a real 5 V supply.
- MQTT login fails — verify product ID, device name and token together, and check the token's expiry; make sure the TCP connection is up before the MQTT CONNECT.
- OneNet shows nothing — nine times out of ten the device-model identifiers do not match the JSON keys exactly, or the publish topic is wrong.
- MLX90614 reads 0 or a nonsense value — scan the I²C bus for the
0x5Aaddress, then re-check the software I²C SDA/SCL wiring and timing.
Where it fits
This is a teaching build rather than a product, but the skeleton is genuinely reusable: swap the transport for LoRaWAN or MQTT over Wi-Fi, swap the cloud for a self-hosted broker, and the sensing-to-alarm logic carries over unchanged. The radar half of the design — presence and vital signs without a wearable — is also the part that is quietly becoming mainstream, which is why off-the-shelf millimetre-wave presence sensors now sit alongside DIY radar modules in the same catalogue.
If you are building anything in the aging-in-place or occupancy-sensing space, the two ideas here are worth taking even if you never touch an STM32: framing serial data by idle timing instead of frame length, and treating a sudden variance spike in a slow sensor as an event worth flagging.
IOTTourChina covers open-source IoT projects and China-made devices as part of its developer resource. Details should be confirmed against the hardware datasheets and the platform's official documentation.
This article is part of the mmWave Radar channel.