# TSM_PicoW_Sensor This project utilizes the Raspberry Pi Pico W board to measure data (humidity and temperature) and publish these values to an MQTT broker. ## Project Overview The TSM_PicoW_Sensor firmware collects sensor data and publishes it to an MQTT broker over Wi-Fi. The configuration is flexible and can be updated at runtime using a serial terminal. The project supports automated testing, including remote execution via a J-Link tunnel. --- ## CI/CD > **Note:** The automated test job in the CI pipeline is currently commented out because a Pico W board is not always available. To enable automated testing, uncomment the test job in the CI configuration and ensure a J-Link tunnel is set up as described below. --- ## Target Configuration The device parameters (Wi-Fi credentials, MQTT broker, topics, etc.) are stored in flash memory and can be configured via a serial terminal (baud rate: **115200**). After updating any parameter, restart the device to apply changes. ### Wi-Fi Setup Set the Wi-Fi SSID and password using the following commands: ```shell McuMinINI write settings.ini WiFi ssid "YOUR_SSID" McuMinINI write settings.ini WiFi pass "YOUR_PASSWORD" ``` ### MQTT Setup Configure the MQTT broker and authentication: ```shell McuMinINI write settings.ini MQTT broker "BROKER_NAME" McuMinINI write settings.ini MQTT user "USERNAME" McuMinINI write settings.ini MQTT pass "PASSWORD" ``` Set the MQTT topic names: ```shell McuMinINI write settings.ini MQTT topic_sensor_update "///update" McuMinINI write settings.ini MQTT topic_send_measurement "///cmd/measure" ``` --- ## Build Instructions The project uses CMake presets for different build configurations: **Debug**, **Release**, and **Test**. ### Configure the Project Here are the avalaible cmake presets: ```shell cmake --preset Debug cmake --preset Release cmake --preset Test ``` ### Build the Project Here are the build options: ```shell cmake --build --preset app-debug cmake --build --preset app-release cmake --build --preset app-test ``` ## Running Tests The project supports running tests both locally and remotely. Remote testing is useful for CI pipelines or when the hardware is not directly connected to your development machine. ### Remote Test Execution To execute tests on a target connected to another machine (e.g., in a CI/CD environment): #### 1. On the Host Machine (with the Pico W board) Start a J-Link Remote Server with tunneling enabled: ```shell JLinkRemoteServerCL -UseTunnel -TunnelBySN ``` Sample output: ``` 2025-06-04 08:43:57 - Remote Server started 2025-06-04 08:43:57 - Connected to J-Link with S/N 801000372 2025-06-04 08:43:57 - Resolving tunnel server name (jlink-europe.segger.com)... 2025-06-04 08:43:57 - Tunnel server IP: 185.162.249.2 2025-06-04 08:43:57 - Registered at tunnel server 2025-06-04 08:43:57 - Waiting for client connection ``` The serial number (e.g., `801000372`) is your **tunnel ID**. #### 2. On the Development/CI Machine Configure CMake to use the tunnel ID: ```shell cmake --preset Test -DTUNNEL_ID=801000372 ``` When you run the tests, they will be executed on the remote host machine where the Pico W board is connected.