doc(pico-sensor): updated readme
This commit is contained in:
@@ -1,75 +1,92 @@
|
|||||||
# TSM_PicoW_Sensor
|
# TSM_PicoW_Sensor
|
||||||
This project uses the PicoW board to publish sensor values (humidity and temperature) to an MQTT broker.
|
|
||||||
|
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
|
## Target Configuration
|
||||||
|
|
||||||
Use a serial terminal (baud rate: 115200) to configure the board by sending commands. The application stores the parameters in flash memory. You must restart the device to apply any changes.
|
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
|
### Wi-Fi Setup
|
||||||
|
|
||||||
|
Set the Wi-Fi SSID and password using the following commands:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
McuMinINI write settings.ini WiFi ssid "YOUR_SSID"
|
McuMinINI write settings.ini WiFi ssid "YOUR_SSID"
|
||||||
McuMinINI write settings.ini WiFi pass "YOUR_PASSWORD"
|
McuMinINI write settings.ini WiFi pass "YOUR_PASSWORD"
|
||||||
```
|
```
|
||||||
|
|
||||||
### MQTT
|
### MQTT Setup
|
||||||
|
|
||||||
|
Configure the MQTT broker and authentication:
|
||||||
|
|
||||||
Broker information:
|
|
||||||
```shell
|
```shell
|
||||||
McuMinINI write settings.ini MQTT broker "BROKER_NAME"
|
McuMinINI write settings.ini MQTT broker "BROKER_NAME"
|
||||||
McuMinINI write settings.ini MQTT user "USERNAME"
|
McuMinINI write settings.ini MQTT user "USERNAME"
|
||||||
McuMinINI write settings.ini MQTT pass "PASSWORD"
|
McuMinINI write settings.ini MQTT pass "PASSWORD"
|
||||||
```
|
```
|
||||||
|
|
||||||
Topic names:
|
Set the MQTT topic names:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
McuMinINI write settings.ini MQTT topic_sensor_update "<user>/<room>/<device>/update"
|
McuMinINI write settings.ini MQTT topic_sensor_update "<user>/<room>/<device>/update"
|
||||||
McuMinINI write settings.ini MQTT topic_send_measurement "<user>/<room>/<device>/cmd/measure"
|
McuMinINI write settings.ini MQTT topic_send_measurement "<user>/<room>/<device>/cmd/measure"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Build
|
---
|
||||||
Project has `Debug`, `Release` and `Test` targets, using CMake Presets.
|
|
||||||
|
## Build Instructions
|
||||||
|
|
||||||
|
The project uses CMake presets for different build configurations: **Debug**, **Release**, and **Test**.
|
||||||
|
|
||||||
|
### Configure the Project
|
||||||
|
|
||||||
|
Here are the avalaible cmake presets:
|
||||||
|
|
||||||
**Configure:**
|
|
||||||
```shell
|
```shell
|
||||||
cmake --list-presets
|
|
||||||
cmake --preset Debug
|
cmake --preset Debug
|
||||||
cmake --preset Release
|
cmake --preset Release
|
||||||
cmake --preset Test
|
cmake --preset Test
|
||||||
```
|
```
|
||||||
|
|
||||||
**Build:**
|
### Build the Project
|
||||||
|
|
||||||
|
Here are the build options:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
cmake --build --list-presets
|
|
||||||
cmake --build --preset app-debug
|
cmake --build --preset app-debug
|
||||||
cmake --build --preset app-release
|
cmake --build --preset app-release
|
||||||
cmake --build --preset app-test
|
cmake --build --preset app-test
|
||||||
```
|
```
|
||||||
|
|
||||||
**Test:**
|
## Running Tests
|
||||||
```shell
|
|
||||||
ctest --list-presets
|
|
||||||
ctest --test-dir build/Test -R Led_1
|
|
||||||
```
|
|
||||||
|
|
||||||
**Workflow:**
|
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.
|
||||||
```shell
|
|
||||||
cmake --workflow --list-presets
|
|
||||||
```
|
|
||||||
|
|
||||||
## Running Tests on Another Machine
|
### Remote Test Execution
|
||||||
|
|
||||||
To run tests on a target connected to another machine (e.g., in a GitLab CI pipeline), follow these steps:
|
To execute tests on a target connected to another machine (e.g., in a CI/CD environment):
|
||||||
|
|
||||||
### On the Host Machine
|
#### 1. On the Host Machine (with the Pico W board)
|
||||||
|
|
||||||
Set up a J-Link tunnel to make the target accessible from anywhere:
|
Start a J-Link Remote Server with tunneling enabled:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
JLinkRemoteServerCL -UseTunnel -TunnelBySN
|
JLinkRemoteServerCL -UseTunnel -TunnelBySN
|
||||||
```
|
```
|
||||||
|
|
||||||
The terminal output should look like this:
|
Sample output:
|
||||||
|
|
||||||
```
|
```
|
||||||
2025-06-04 08:43:57 - Remote Server started
|
2025-06-04 08:43:57 - Remote Server started
|
||||||
@@ -80,10 +97,14 @@ The terminal output should look like this:
|
|||||||
2025-06-04 08:43:57 - Waiting for client connection
|
2025-06-04 08:43:57 - Waiting for client connection
|
||||||
```
|
```
|
||||||
|
|
||||||
`801000372` is the tunnel ID required to reach the target. Include it in your CMake command:
|
The serial number (e.g., `801000372`) is your **tunnel ID**.
|
||||||
|
|
||||||
|
#### 2. On the Development/CI Machine
|
||||||
|
|
||||||
|
Configure CMake to use the tunnel ID:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
cmake --preset Test -DTUNNEL_ID=801000372
|
cmake --preset Test -DTUNNEL_ID=801000372
|
||||||
```
|
```
|
||||||
|
|
||||||
When you run the tests, they will automatically execute on the host machine.
|
When you run the tests, they will be executed on the remote host machine where the Pico W board is connected.
|
||||||
Reference in New Issue
Block a user