Weather Report

UART Binary Protocol Exercise

Task

The weather sensor on this board measures temperature, humidity and air pressure, and every few milliseconds it sends all three to the chip as raw bytes. Your program turns those bytes into a line a person can read.

For every frame the sensor sends, print one line like this: T:235 H:769 P:10132 and keep going for as long as the board runs.

Circuit

Block diagram: U2 weather sensor's TX wired to U1 STM32F4 USART1 RX on PA10, with a common ground, and USART1 TX on PA9 going to a TP1 serial monitor

Pass condition

Each frame prints one line, in the order the frames arrive.

Expected output for the one-frame case: the sensor sends the six bytes 00 EB, 03 01 and 27 94 for temperature, humidity and pressure, and the program prints the line T:235 H:769 P:10132

Notes

A frame is six bytes: temperature, then humidity, then pressure. Each reading is an unsigned 16-bit number from 0 to 65535, sent as two bytes. The high byte comes first and the low byte second. The high byte is the larger part of the number. The readings count in tenths: 235 means 23.5 C, 769 means 76.9 %, 10132 means 1013.2 hectopascals. A hectopascal is a unit of air pressure. Print them as they are, with no decimal point. The sensor starts sending after your program is running, so the first byte you read starts a frame.

Related challenges

Loading the interactive arena.