Zephyr Peripheral Samples on the Wio-LR2021 Dev Kit

Introduction
The workspace ships several samples that exercise the non-radio hardware of the kit, including: the board self-test, the OLED display test, the Grove connector and the camera test. Each sample is a complete Zephyr application, so you can read it, change it and flash it independently.
All samples follow the same rhythm: build, flash, read the console. Build commands are given once per sample; the flags themselves are explained in Develop with Zephyr.
Run the samples in the order below. The self-test proves the I2C and SPI wiring that the other three applications rely on.
1. Board self-test
This is the first application to run on a new board. It checks the buses, the GPIO expander, the OLED, the LED, both buttons and the LR2021 transceiver, then prints a verdict per test case.
cd .../wio-lr2021-dev-kit-zephyr/wio_lr2021_dev_kit_test
west build -p always -b wio_lr2021_dev_kit/esp32s3/procpu -d build_test -- -DBOARD_ROOT=../
west flash -d build_test
The run is fully automatic except for the button case, which asks you to press USER and then BOOT. Press the reset button to run the whole test again.
The console excerpts on this page drop the Zephyr prefix ([00:00:00.320,000] <inf> board_test:) and keep the message text only, so that the lines fit on screen.
If all the peripherals work normally, you should see the following logs on your console:
--- I2C0 bus, PCA9535 expander and SH1106 OLED ---
[PASS] I2C0 controller is ready
I2C scan found 2 device(s)
0x21
0x3d
[PASS] PCA9535 registers can be written and read back
--- User LED (PCA9535 P06, active low) ---
[PASS] LED reads back as on
...
--- USER (GPIO46) and BOOT (GPIO0) buttons ---
Press and hold the USER button (waiting up to 5000 ms)...
USER button press detected, release it now
--- SPI2 bus and LR2021 transceiver ---
LR2021 firmware version: 1.24
[PASS] Two consecutive GetVersion reads return the same version
================ TEST SUMMARY ================
25 checks, 0 failed
Every check goes through one helper, so the counters and the log format never drift:
static bool check(bool condition, const char *description)
{
checks_run++;
if (condition) {
LOG_INF(" [PASS] %s", description);
} else {
checks_failed++;
LOG_ERR(" [FAIL] %s", description);
}
return condition;
}
The I2C scan needs no driver support: a zero-length write transfers only the address byte and reports whether the device acknowledged. That is the SMBus "quick command" and it touches no registers:
static int i2c_probe_addr(uint16_t addr)
{
return i2c_write(i2c0, NULL, 0, addr);
}
A missing LR2021 or a stuck SPI bus is reported as FAIL with the raw GetVersion answer. The test reads the version twice on purpose: a constant 0x00 or 0xFF means the bus is shorted or floating, not that the radio is fine.
2. OLED and LVGL
The OLED Wio-LR2021 Dev Kit uses is a 128x64 SH1106 panel on I2C0 address 0x3d. Its devicetree node is named ssd1306_128x64 because it uses the ssd1306 driver, and it is the chosen zephyr,display device, so display applications find it without naming it.
cd .../wio-lr2021-dev-kit-zephyr/wio_lr2021_dev_kit_display_test
west build -p always -b wio_lr2021_dev_kit/esp32s3/procpu -d build_display -- -DBOARD_ROOT=../
west flash -d build_display
The application runs five test cases: device probe, blanking, six full-frame patterns, a LVGL screen, and a visual confirmation that waits 15 s for you to press USER. A timeout is a SKIP, not a failure, so an unattended run still finishes.
--- framebuffer patterns ---
[PASS] pattern 3: checkerboard
[PASS] pattern 6: border and cross
--- LVGL ---
[PASS] LVGL width matches the panel
[PASS] label widget created
[PASS] line widget created
--- visual confirmation ---
press the USER button within 15 s to confirm
[PASS] operator confirmed the panel output
The LVGL case is a compact tour of the API: get the active screen, create widgets, then let LVGL render. Monochrome panels need no color setup beyond CONFIG_LV_COLOR_DEPTH_1:
screen = lv_screen_active();
label = lv_label_create(screen);
lv_label_set_text(label, "LVGL OK");
lv_obj_set_style_text_color(label, lv_color_white(), 0);
line = lv_line_create(screen);
lv_line_set_points(line, line_points, ARRAY_SIZE(line_points));
/* Run a few refresh cycles so the widgets reach the panel. */
for (int i = 0; i < 5; i++) {
lv_timer_handler();
k_msleep(20);
}
lv_timer_handler() only advances LVGL's internal state. Call it periodically, or lv_refr_now(NULL) when you cannot wait, otherwise the panel shows the previous frame.
3. Grove sensor

We use the Grove Sensor SHT40 in this sample. The Grove connector is I2C1 on GPIO43 and GPIO44. Those pins are also shared with UART0, which is why I2C1 is disabled in the board devicetree(DTS) and the sample has to enable it with an overlay. The console is the USB-JTAG controller, so disabling UART0 costs you nothing.
/ {
aliases {
grove-sensor = &grove_sht40;
};
};
&i2c1 {
status = "okay";
clock-frequency = <I2C_BITRATE_STANDARD>;
pinctrl-0 = <&i2c1_default>;
pinctrl-names = "default";
grove_sht40: sht40@44 {
compatible = "sensirion,sht4x";
reg = <0x44>;
repeatability = <2>;
power-domains = <&grove_power_enable>;
};
};
&uart0 {
status = "disabled";
};
&pinctrl {
i2c1_default: i2c1_default {
group1 {
pinmux = <I2C1_SDA_GPIO43>, <I2C1_SCL_GPIO44>;
bias-pull-up;
drive-open-drain;
output-high;
};
};
};
The grove-sensor alias gives the application a stable name to look up, and the connector is powered by PCA9535 output P04, modelled as the grove_power_enable regulator and attached to the sensor as a power domain. The regulator core switches the rail on before the driver touches the bus, so the application never drives a GPIO by hand.
cd .../wio-lr2021-dev-kit-zephyr/wio_lr2021_dev_kit_grove_test
west build -p always -b wio_lr2021_dev_kit/esp32s3/procpu -d build_grove -- -DBOARD_ROOT=../
west flash -d build_grove
After the self-test passes, the application samples every two seconds, and a USER press takes an extra sample immediately:
--- Grove power rail (PCA9535 P04) ---
[PASS] Grove power rail is enabled
I2C1 scan found 1 device(s)
0x44
[PASS] CRC-checked sample fetch completed
Temperature: 24.531250 C
Humidity: 41.187500 %RH
Sampling every 2000 ms, press the USER button for an immediate sample
Periodic sample: temperature=24.531250 C, humidity=41.187500 %RH
Never touch the SHT40 from interrupt context. The sample's button handler only schedules a delayable work item, which also debounces the contact: a press that is already pending is not scheduled twice.
4. Camera viewer
The camera test sample needs the Media Hat, the shield and the Wi-Fi blobs. It captures QVGA RGB565 frames from the GC2145, runs a small HTTP server on a Wi-Fi access point, and lets any browser on the same network watch the stream.
/* you will need the espressif hal blob for this sample */
west blobs fetch hal_espressif
cd .../wio-lr2021-dev-kit-zephyr/wio_lr2021_dev_kit_camera_test
west build -p always -b wio_lr2021_dev_kit/esp32s3/procpu -d build_camera -- -DBOARD_ROOT=../ -DSHIELD=seeed_wio_lr2021_dev_kit_media_hat
west flash -d build_camera
The application first runs a five-case self-test, and only starts the viewer when it passes. Then the console prints the access point details:
- Connect your computer to the Wi-Fi network Wio-LR2021-CAM, password 12345678.
- Open
http://192.168.4.1in a browser. - Keep the page open. It fetches a new frame as soon as the previous one has been drawn.

Wio-LR2021 Dev Kit camera test
--- device ---
[PASS] GC2145 camera device is ready
sensor: gc2145@3c
negotiated RGB565 320x240, pitch 640, size 153600
3 frames in 250 ms (12 fps), 0 truncated frame(s), 0 byte(s) lost
15 checks, 0 failed
AP enabled: SSID "Wio-LR2021-CAM", browse to http://192.168.4.1
GET / returns an embedded HTML page, and GET /frame returns a 20-byte header followed by a raw RGB565 frame straight out of the camera buffer:
| Field | Size | Meaning |
|---|---|---|
magic | 4 bytes | Frame marker, rejects stale responses |
width, height | 2 bytes each | 320 x 240 |
format | 2 bytes | CAMERA_FRAME_FMT_RGB565 |
flags | 2 bytes | Reserved, zero |
seq | 4 bytes | Publish counter; gaps mean dropped frames |
len | 4 bytes | Payload bytes, width * height * 2 |
The server feeds three browsers at the same time (CONFIG_APP_MAX_HTTP_CLIENTS), so close a tab before you open the page on a fourth device.
The camera runs out of PSRAM, and the sample is tuned for 40 MHz octal PSRAM. Do not raise the PSRAM clock: the 80 MHz timing is not implemented for the ESP32-S3 in this tree, and the frame pipeline starts losing buffers. Keep CONFIG_ESP_SPIRAM_HEAP_SIZE and the DMA descriptor count as they are unless you also re-measure throughput.
Troubleshooting
Q1: The self-test reports FAIL on the I2C0 bus
The expander at 0x21 and the OLED at 0x3d must both answer. If the scan is empty, check that the board is powered over USB-C and not through the Grove connector, then look for a shield that was seated while the board was on: remove power first, reseat and retry.
Q2: The Grove sensor is not detected
I2C1 is disabled by default, so a build without the overlay produces an empty scan. Confirm that the build used -DBOARD_ROOT=../ and that the module is plugged into the Grove port, not into a header. The scan must show 0x44.
Q3: "west build" fails with "SHIELD ... not found"
The shield lives in wio-lr2021-dev-kit-zephyr/boards/shields/, so it is only visible when -DBOARD_ROOT=../ is passed together with -DSHIELD=. Both flags belong after -- on the west build line.
Q4: The Wi-Fi network does not appear
The access point starts only after the self-test passes and the blobs are present. Run west blobs fetch hal_espressif, rebuild with -p always, and give the radio a few seconds after the AP enabled: SSID "Wio-LR2021-CAM" line before you scan for the network again.
Resources
Tech Support & Product Discussion
Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.