WiFi & Bluetooth Sensor Node
Demo Complete
The demo is finished. It didn't use any ACUs. You can now continue working with this project like normal.
SWO_ISP low for ISP entry0x44Table
| Function | Schematic Pin / Net | Connected To | Direction | Notes |
|---|---|---|---|---|
| I2C SDA | U1:ULP_GPIO_0 / I2C_SDA | U4 SDA, R9 10 kΩ pull-up | Bidirectional | SHT41 address 0x44 |
| I2C SCL | U1:ULP_GPIO_1 / I2C_SCL | U4 SCL, R10 10 kΩ pull-up | Output | Short on-board bus |
| Status LED | U1:ULP_GPIO_8 / STATUS_LED | R11 1 kΩ → LED1 → GND | Output | Drive high to turn on |
| eFuse fault | U1:UULP_VBAT_GPIO_3 / EFUSE_FLT_N | U2 FLT, R7 pull-up | Input | Active-low fault |
| Power-good | U1:UULP_VBAT_GPIO_2 / PWR_PGOOD | U3 PG1, R8 pull-up | Input | Active-high/open-drain good via pull-up |
| SWDIO | U1:JTAG_TMS_SWDIO / SWDIO | J2 pin 2 | Debug | SWD data |
| SWCLK | U1:JTAG_TCK_SWCLK / SWCLK | J2 pin 4 | Debug | SWD clock |
| UART RX MCU | U1:GPIO_8 / UART_RX_MCU | J2 pin 7 | Input | ISP UART RX |
| UART TX MCU | U1:GPIO_9 / UART_TX_MCU | J2 pin 8 | Output | ISP UART TX |
| Reset | U1:POC_IN, RESET_N | SW1, J2 pin 10 | Input/reset | POC_IN reset button, RESET_N monitor/debug |
C
// app_pinmap.h — map these to the SDK GPIO/port macros for your selected SiWx917 board support package. #pragma once #define PIN_I2C_SDA_NET "ULP_GPIO_0" // schematic net I2C_SDA #define PIN_I2C_SCL_NET "ULP_GPIO_1" // schematic net I2C_SCL #define PIN_STATUS_LED_NET "ULP_GPIO_8" // schematic net STATUS_LED #define PIN_EFUSE_FLT_N_NET "UULP_VBAT_GPIO_3" #define PIN_PWR_PGOOD_NET "UULP_VBAT_GPIO_2" #define SHT41_I2C_ADDR 0x44u #define SENSOR_INTERVAL_MS 5000u
C
#include <stdint.h> #include <stdbool.h> #include <stdio.h> #include <string.h> #include "sl_status.h" #include "sl_sleeptimer.h" #include "sl_wifi.h" #include "sl_net.h" #include "app_pinmap.h" // Replace these three low-level functions with the SiWx917 SDK I2C/GPIO calls selected in the project configurator. extern sl_status_t board_i2c_write(uint8_t addr, const uint8_t *data, uint16_t len); extern sl_status_t board_i2c_read(uint8_t addr, uint8_t *data, uint16_t len); extern void board_gpio_write_status_led(bool on); extern bool board_gpio_read_efuse_fault_n(void); extern bool board_gpio_read_pwr_pgood(void); extern void board_platform_init(void); extern uint32_t board_millis(void); static uint8_t sht4x_crc8(const uint8_t *data, uint8_t len) { uint8_t crc = 0xFF; for (uint8_t i = 0; i < len; i++) { crc ^= data[i]; for (uint8_t bit = 0; bit < 8; bit++) { crc = (crc & 0x80) ? (uint8_t)((crc << 1) ^ 0x31) : (uint8_t)(crc << 1); } } return crc; } static sl_status_t sht41_read(float *temp_c, float *rh_pct) { const uint8_t cmd = 0xFD; // high precision T/RH measurement uint8_t rx[6] = {0}; sl_status_t st = board_i2c_write(SHT41_I2C_ADDR, &cmd, 1); if (st != SL_STATUS_OK) return st; sl_sleeptimer_delay_millisecond(10); st = board_i2c_read(SHT41_I2C_ADDR, rx, sizeof(rx)); if (st != SL_STATUS_OK) return st; if (sht4x_crc8(&rx[0], 2) != rx[2] || sht4x_crc8(&rx[3], 2) != rx[5]) { return SL_STATUS_FAIL; } uint16_t t_ticks = ((uint16_t)rx[0] << 8) | rx[1]; uint16_t rh_ticks = ((uint16_t)rx[3] << 8) | rx[4]; *temp_c = -45.0f + 175.0f * ((float)t_ticks / 65535.0f); *rh_pct = -6.0f + 125.0f * ((float)rh_ticks / 65535.0f); if (*rh_pct > 100.0f) *rh_pct = 100.0f; if (*rh_pct < 0.0f) *rh_pct = 0.0f; return SL_STATUS_OK; } static void wifi_start_station(void) { // Start from a Silicon Labs SiWx917 Wi-Fi station example and fill credentials in the SDK config. // Keep this call non-fatal: the sensor node should still report over UART/debug if Wi-Fi is unavailable. sl_wifi_init(NULL, NULL, NULL); } void app_init(void) { board_platform_init(); board_gpio_write_status_led(false); wifi_start_station(); printf("SiWG917 T/RH sensor node starting\n"); } void app_process_action(void) { static uint32_t last_ms = 0; uint32_t now = board_millis(); if ((now - last_ms) < SENSOR_INTERVAL_MS) return; last_ms = now; bool power_good = board_gpio_read_pwr_pgood(); bool efuse_ok = board_gpio_read_efuse_fault_n(); if (!power_good || !efuse_ok) { printf("Power warning: PGOOD=%u EFUSE_FLT_N=%u\n", power_good, efuse_ok); } float temp_c = 0.0f, rh = 0.0f; sl_status_t st = sht41_read(&temp_c, &rh); if (st == SL_STATUS_OK) { board_gpio_write_status_led(true); printf("T=%.2f C RH=%.2f %%\n", temp_c, rh); // TODO: publish over Wi-Fi HTTP/MQTT or expose over BLE GATT characteristic. board_gpio_write_status_led(false); } else { printf("SHT41 read failed: 0x%08lx\n", (unsigned long)st); } }
app.c and implement the board-specific I2C/GPIO wrappers using the SDK configurator.slc generate && make if using the command-line Silicon Labs flow.Platform & Toolchain
Pin Mapping
Example Project Configuration
Complete Firmware Source
Build & Flash Instructions