{"id":13343775,"url":"https://github.com/HomeSmartMesh/sdk-hsm-thingy53","last_synced_at":"2025-03-12T06:30:27.875Z","repository":{"id":159132006,"uuid":"624748546","full_name":"HomeSmartMesh/sdk-hsm-thingy53","owner":"HomeSmartMesh","description":"Zephyr Samples for Nordic Thingy53 dev kit OpenThread mesh with json data, BME688 BSEC2 for Air Quality, Light color, RGB Les, Battery","archived":false,"fork":false,"pushed_at":"2024-01-27T12:27:58.000Z","size":996,"stargazers_count":13,"open_issues_count":0,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-10-29T14:22:07.998Z","etag":null,"topics":["air-quality","bh1749","bme688","bsec2","light-color","mesh-networks","openthread","sensor","thingy53","thread","zephyr","zephyr-rtos"],"latest_commit_sha":null,"homepage":"https://homesmartmesh.netlify.app/boards/thingy53/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HomeSmartMesh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-04-07T06:58:36.000Z","updated_at":"2024-08-18T18:59:52.000Z","dependencies_parsed_at":"2024-02-21T06:48:01.807Z","dependency_job_id":null,"html_url":"https://github.com/HomeSmartMesh/sdk-hsm-thingy53","commit_stats":{"total_commits":100,"total_committers":2,"mean_commits":50.0,"dds":"0.020000000000000018","last_synced_commit":"058fc96a85e2a470442d08df169e4b3d65872697"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HomeSmartMesh%2Fsdk-hsm-thingy53","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HomeSmartMesh%2Fsdk-hsm-thingy53/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HomeSmartMesh%2Fsdk-hsm-thingy53/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HomeSmartMesh%2Fsdk-hsm-thingy53/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HomeSmartMesh","download_url":"https://codeload.github.com/HomeSmartMesh/sdk-hsm-thingy53/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243171362,"owners_count":20247876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["air-quality","bh1749","bme688","bsec2","light-color","mesh-networks","openthread","sensor","thingy53","thread","zephyr","zephyr-rtos"],"created_at":"2024-07-29T19:32:00.841Z","updated_at":"2025-03-12T06:30:27.831Z","avatar_url":"https://github.com/HomeSmartMesh.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\nZephyr reference samples for Thingy53 dev kit, simple reference samples and sensors server\n## Features\n* Air quality with BME688 driver and library integrating Bosch's BSEC2 library for IAQ (Indoor Air Quality) measurements.\n* Mesh Network with OpenThread broadcasting UDP packets as client and running a sensors server.\n* C++ application with json inputs for config and outputs for sensors enables direct mapping to MQTT\n* RGB Led, Light color, Battery\n\n![SensorsServer](./design/OverviewDataFlow-wide.webp)\n\n* Raspberry pi server repo : https://github.com/HomeSmartMesh/raspi\n\n## Dev Kit\nBelow is an open box Nordic Thingy53 attached to USB and j-Link debugger\n![USB Attachments](./design/thingy53-usb-attachments.webp)\n\n## Hardware\n* Nordic's [Thingy53](https://www.nordicsemi.com/Products/Development-hardware/Nordic-Thingy-53) IoT Prototyping platform\n* Segger's [j-Link Edu mini](https://www.segger.com/products/debug-probes/j-link/models/j-link-edu-mini/) (optional)\n\nUsed Sensors in this repo's samples\n* BME688 Digital nose : low power gas, pressure, temperature \u0026 humidity sensor with AI\n    * [BME688 Product page](https://www.bosch-sensortec.com/products/environmental-sensors/gas-sensors/bme688/)\n    * [BME688 Datasheet](https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bme688-ds000.pdf)\n\n* Color sensor BH1749NUC\n    * [BH1749NUC Datasheet](https://fscdn.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1749nuc-e.pdf)\n    * Measures Red, Green, Blue and IR\n    * Illuminance Detection Range 80 klx (0.0125 lux/count)\n\n## Repo structure\n![Dependencies](./design/dependencies.drawio.svg)\n\n## Drivers and libraries\nThe following drivers and libraries have been created in this repo\n* BME688 Zephyr Driver : in [drivers/sensor/bme688](drivers/sensor/bme688)\n    * `BME68x-Sensor-API` vendor driver integration https://github.com/boschsensortec/BME68x-Sensor-API\n    * Using Zephyr's Sensor API in C language for usage in BME688 simple forced mode\n    * Driver extension functions to use BME688 in Parallel mode and get all x10 gas measures\n* BME688 Server : in [subsys/bme688_server](subsys/bme688_server)\n    * C++ wrapper to configure the BME688 usage in json structure (temperatures profile and durations)\n    * handler delivers the sensor results in a json structure (temperature, humidity, pressure, gas-0..gas-9)\n    * `Bosch-BSEC2-Library` .a vendor's binary integration for IAQ (Indoor Air Quality) measurements https://github.com/boschsensortec/Bosch-BSEC2-Library\n\nBME688 Components and Data\n\n![BME688DriversLib](./design/BME688DriversLib.drawio.svg)\n\n## Usage\n```bash\nmkdir thingy53\ncd thingy53\n\u003ewest init -m https://github.com/HomeSmartMesh/sdk-hsm-thingy53 --mr main\n\u003ewest update\n```\nbuilding a sample\n```bash\ncd hsm/samples/20_sensors_server\nwest build\nwest build -- -DOVERLAY_CONFIG=\"overlay-logging.conf\"\n```\nflashing using an attached debugger\n```\n\u003ewest flash\n```\nrecover by deleting flash\n```\n\u003ewest flash --recover\n```\n\nflashing manually\n* connect to USB\n* power on while holding SW2 down, see details on [updating thingy53 through USB](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/working_with_nrf/nrf53/thingy53_gs.html#updating-through-usb)\n* with nRFConnect Programmer flash `hsm\\samples\\20_sensors_server\\build\\zephyr\\dfu_application.zip`\n\nSerial Port\n* USB Serial Port : with the config `CONFIG_STDOUT_CONSOLE=y` this board creates a UAB virtual COM port of stdout. Note using the nRFSDK Connect Serial Terminal allows auto detection and reconnect of serial ports, very useful to recover automatically after flashing\n* RTT Debugger Serial Port : using `CONFIG_USE_SEGGER_RTT=y` it is possible to have logs with the attached debugger and without using the board USB device, this needs rebuild the sample differently though.\n\n## joining a thread network\nsample with joiner config `CONFIG_OPENTHREAD_JOINER_PSKD` are [13_ot_joiner](#13_ot_joiner), [14_ot_udp_echo_server](#14_ot_udp_echo_server), [15_udp_json_endpoint](#15_udp_json_endpoint) and [20_sensors_server](#20_sensors_server)\nNote: Make sure to press the Thingy53 button after the raspberry pi commissioner is started. The button will reset the device and try to join thread networks on the new startup.\n\njoining info:\n* the `eui64` can be known by first flashing the logging version with `overlay-logging.conf`\n* without knowing the `eui64` it is also possible to commission with '*' as `eui64` parameter\n\non the raspberry pi\n```shell\nsudo ot-ctl\ncommissioner start\ncommissioner joiner add * ABCDE2\n```\n\n# Samples details\nfor convenience and given that this repo is providing samples for `thingy53_nrf5340_cpuapp` board, it has been configured in the CMakeLists.txt to be taken as default board, it is still possbile to override it with -b option.\n## 01_alive_counter_uart\n[samples/01_alive_counter_uart](./samples/01_alive_counter_uart)\n\nsimplest program for checking UART with a live counter\n## 02_rgb_led\n[samples/02_rgb_led](./samples/02_rgb_led)\n\ncontrolling the colors of the Red Green and Blue LEDs with pwm\n* function for setting x3 float colors\n* function for blinking a color\n\n## 03_battery\n[samples/03_battery](./samples/03_battery)\n\n* Power Management Integrated Circuit specification [nPM1100_PS_v1.3.pdf](https://infocenter.nordicsemi.com/pdf/nPM1100_PS_v1.3.pdf)\n* Thingy53 schematics `PCA20053_Schematic_And_PCB.pdf`\n\nused pios\n* Battery Measure ENABLE P0.16 `vbatt.power-gpio` in `thingy53_nrf5340_common.dts`\n* Battery Measure BAT_MEAS P0.06/AIN2 `vbatt.io-channels` in `thingy53_nrf5340_common.dts`\n* Battery charging Indicator CHG PMIC_STATUS P1.00 `battery-charge-gpios` in `app.overlay`\n\n## 04_bme680\n[samples/04_bme680](./samples/04_bme680)\n\nNote: Do not use this sample, it is for info only, using BME680 driver for BME688 can only fetch temp,hum,press but not gas due to difference in registers config\n\n* this sample is based on [BME680 Zephyr sample](https://docs.zephyrproject.org/latest/samples/sensor/bme680/README.html) from Nordic's fork [nRF BME680 Zephyr sample](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/samples/sensor/bme680/README.html)\n* this samples uses the device drivers declaration `bosch,bme680` in the thingy53 dts file `thingy53_nrf5340_common.dts` used for\n    * Temperature\n    * Air pressure\n    * Humidity\n\n## 05_bme688\n[samples/05_bme688](./samples/05_bme688)\n\n* sample demonstrating the usage of the BME688 C driver wrapper over Zephyr's sensor API and using Bosch's `BME68x-Sensor-API`\n* config flag `CONFIG_BME688=y`\n\nOutput\n```shell\ndel_period = 142590\nTemperature(deg C), Pressure(Pa), Humidity(%), Gas resistance(ohm)\n25.24, 95917.63, 40.48, 23992.50\nnew data , no Gas Index , Gas Meas Valid , Heat Stability\n```\n\nreferences\n* Nordic DevZone Forum : https://devzone.nordicsemi.com/f/nordic-q-a/98569/gas-resistance-values-from-bme688-on-thingy-53\n\n## 06_bme688_parallel\n[samples/06_bme688_parallel](./samples/06_bme688_parallel)\n\n* introducing usage additional custom functions to enable usage of BME688 in prallel mode still in C language\n* config flag `CONFIG_BME688=y`\n* `bme688_set_mode_default_conf()`\n* `bme688_data_get()`\n\n## 07_bme688_parallel_cpp\n\n!! crashing to be fixed !! in the meanwhile and for parallel mode see 06_bme688_parallel\n\n[samples/07_bme688_parallel_cpp](./samples/07_bme688_parallel_cpp)\n\n* a C++ wrapper for bme688_server library\n* config flags `CONFIG_BME688=y` and `CONFIG_BME688_SERVER=y`\n* `set_bme688_config()` with temperatures and durations in a json structure\n* `start_bme688()` with a handler that gets a json structure with temperature, humidity, pressure, gas-0..gas-9\n\n## 08_bme688_bsec2\n[samples/08_bme688_bsec2](./samples/08_bme688_bsec2)\n\n* Enables the BSEC2 part of the bme688_server library, `Bosch-BSEC2-Library` .a vendor's binary integration for IAQ (Indoor Air Quality) measurements https://github.com/boschsensortec/Bosch-BSEC2-Library\n* new flag `CONFIG_BME688_BSEC2=y` in addition to `CONFIG_BME688=y` and `CONFIG_BME688_SERVER=y`\n* returns `iaq`, `iaq_accuracy`, `co2_eq`, `breath_voc`, `stabilization` and `runin` calculated from the bsec2 library\n\n\n## 09_bh1749\n[samples/09_bh1749](./samples/09_bh1749)\n\n* Color sensor BH1749NUC\n    * [BH1749NUC Datasheet](https://fscdn.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1749nuc-e.pdf)\n    * Measures Red, Green, Blue and IR\n    * Illuminance Detection Range 80 klx (0.0125 lux/count)\n\n\n\n## 11_openthread_shell\n[samples/11_openthread_shell](./samples/11_openthread_shell)\n\n\n* provides a shell on the USB UART interface that allows to manually configure the openthread stack\n\nbuild\n```shell\ncd thingy53/hsm/samples/11_openthread_shell\n\u003ewest build\n```\n\n## 12_ot_udp_client\n[samples/12_ot_udp_client](./samples/12_ot_udp_client)\n\n* using a fixed openthread network config allows to hard-code network credentials for testing only (not suited for deployment), even when used for local deployments it is unpractical as the device needs to be flashed everytime the network parameters change\n* loops sending alive counter messages as thread udp packets\n* `overlay-logging.conf` uses RTT and USB log for openthread state and loop count\n\nbuild options\n```shell\n\u003ewest build\n\u003ewest build -- -DOVERLAY_CONFIG=\"overlay-logging.conf\"\n```\n\n## 13_ot_joiner\n[samples/13_ot_joiner](./samples/13_ot_joiner)\n\n* Commissioning with a joiner PSKd (Pre-Shared Key for the Device) `ABCDE2`\n    * needs the commissioner to be ready for this device\n* short SW2 button press \u003c 1 sec : soft reset `SYS_REBOOT_WARM`\n    * will retry joining if not attached\n* long SW2 button press \u003e 1 sec : OpenThread Farctory reset (delete credentials) and `SYS_REBOOT_COLD`\n    * will try joining a new network\n* `overlay-logging.conf` uses RTT and USB log and prints the following on startup\n    * Joiner `eui64`\n    * Joiner `pskd` built with in the provided config\n    * the qrcode text containing the `eui64` and `pskd` as parameters\n    * a url to a generated qrcode image to be used for joining\n* loops sending alive counter messages as thread udp packets\n\nbuild options\n```shell\n\u003ewest build\n\u003ewest build -- -DOVERLAY_CONFIG=\"overlay-logging.conf\"\n```\n\n## 14_ot_udp_echo_server\n[samples/14_ot_udp_echo_server](./samples/14_ot_udp_echo_server)\n\n* OpenThread broadcasts udp packet\n* separate `udp_rx_handler` thread\n* binds to port 4242 and echoes back received characters (printed as text)\n\n## 15_udp_json_endpoint\n[samples/15_udp_json_endpoint](./samples/15_udp_json_endpoint)\n\n* OpenThread server endpoint can receive json commands and send back responses\n\n\n## 20_sensors_server\n[samples/20_sensors_server](./samples/20_sensors_server)\n\n* OpenThread Joiner device\n* OpenThread mesh client broadcasts udp json packet with Voltage, Alive counter, Charging status, ambient light RGB IR, Temperature, pressure, humidity and Indoor Air Quality\n* OpenThread server endpoint can receive json commands and send back responses\n\non rasp\n```shell\n\u003esudo ot-ctl\nudp open\nudp send ff02::1 4242 hi_there_now\n```\n\n# Plan\n* MQTT publish sample\n* reliable ot tx rx, e.g. tcp, websocket, session,... for packet request response\n* Python MQTT Translator for request response with json bodies\n* RGB Led notification service\n* sensors json logger service (configurable sensors and rates)\n* ot lifecycle, if not connected, restart after timeout, which will retry join\n* system lifecycle, watchdog restart\n* power measurements\n* microhpone streaming\n* microphone local\n\n# Deveopment guide\nThis repository is a [Zephyr workspace application](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/develop/application/index.html#zephyr-workspace-application) that contains the samples source code only therefore lightweight to clone and manage, yet it tracks an exact reference of all dependencies that get deployed once initialized with `west init`\n\n## Hints and Tricks\n* k_sleep in interrupt functions might lead to os crash, usage of LOG effect unclear so to be avoided\n* Fifo, Lifo, Queue take pointers only, user allocates the data but there's also `k_fifo_alloc_put`\n* Message Queues copy the data provided in a ring buffer, (overwrite oldest)\n* Work queues are used to delay functions execution or order multiple functions execution\n\n\n## How was this repo created\n* step one is to get familiar with Zephyr a good reference is https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/develop/index.html\n* second is to focus on the subsection for west https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/develop/west/index.html\n\nThis repository is targetting an nRF dev kit, thereforeit is safer to derive it from nRF's fork of Zephyr and other dependencies. the steps are :\n* west.yml dependencies taken from https://github.com/nrfconnect/sdk-nrf/blob/main/west.yml\n* the default remote is hsm instead of ncs, therefore in the `projects:` the remote ncs needs to be added where applicable\n* in the application `zephyr`, the `name-allowlist` helps reduce the dependencies from Zephyr\n* note also some Zephyr dependencies can be replaced with top level projects such as mbedtls which is then taken from nRF fork and not from Zephyr\n* in case of Kconfig wanrings, it is necessary to compare with the original repo (ncs/nrf) and find the directory (dependency) where that flag is used e.g. missing config for `NRF_MODEM_LIB_SHMEM_CTRL_SIZE` which default is `NRF_MODEM_SHMEM_CTRL_SIZE` defined in `nrfxlib\\nrf_modem\\Kconfig` that shows a dependency from `nrfconnect/nrf` to `nrfconnect/nrfxlib`\n\n## Zephyr references\n* Kernel services : https://docs.zephyrproject.org/latest/kernel/services/index.html\n\n## Project references\n* https://www.hackster.io/wassimfilali/indoor-air-quality-with-thingy53-and-bme688-5c763b\n* https://devzone.nordicsemi.com/f/nordic-q-a/98569/gas-resistance-values-from-bme688-on-thingy-53\n* https://devzone.nordicsemi.com/f/nordic-q-a/92593/using-bsec-2-library-for-bme688-with-thingy53\n* https://community.bosch-sensortec.com/t5/MEMS-sensors-forum/How-to-convert-gas-res-to-AIQ-in-thingy53/m-p/67211/highlight/false#M13176\n* https://www.hackster.io/mahmood-ul-hassan/how-to-read-nordic-thingy-53-onboard-bme688-sensor-003560\n* https://community.bosch-sensortec.com/t5/MEMS-sensors-forum/IAQ-from-BME688-on-NRF9160-ZephyrRTOS/m-p/50953\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHomeSmartMesh%2Fsdk-hsm-thingy53","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHomeSmartMesh%2Fsdk-hsm-thingy53","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHomeSmartMesh%2Fsdk-hsm-thingy53/lists"}