Skip to content

Commit

Permalink
sample: board: add SensorTile.box Pro sample for testing sensors
Browse files Browse the repository at this point in the history
Add sample to test SensorTile.box Pro sensors on board.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
  • Loading branch information
avisconti committed Oct 30, 2023
1 parent 33e3ba1 commit 5c5c239
Show file tree
Hide file tree
Showing 5 changed files with 408 additions and 0 deletions.
10 changes: 10 additions & 0 deletions samples/boards/sensortile_box_pro/sensors-on-board/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2023 STMicroelectronics
#
# SPDX-License-Identifier: Apache-2.0
#
cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(sensortile_box_pro)

target_sources(app PRIVATE src/main.c)
70 changes: 70 additions & 0 deletions samples/boards/sensortile_box_pro/sensors-on-board/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.. _sensortile_box_pro_sample_sensors:

ST SensorTile.box Pro on-board sensors test
###########################################

Overview
********
This sample provides an example of how to read sensors data
from the SensorTile.box Pro board.

This sample enables all sensors of SensorTile.box Pro board, and then
periodically reads and displays data on the console from the following
sensors:

- HTS221: ambient temperature and relative humidity
- LSM6DSV16X: 6-Axis acceleration and angular velocity

Requirements
************

The application requires a SensorTile.box Pro board connected to the PC
through USB. The board shows up as a USB CDC class standard device.

References
**********

- :ref:`sensortile_box_pro_board`

Building and Running
********************

Build and flash the sample in the following way:

.. zephyr-app-commands::
:zephyr-app: samples/boards/sensortile_box_pro/sensors-on-board
:board: sensortile_box_pro
:goals: build flash

Please note that flashing the board requires a few preliminary steps described
in :ref:`sensortile_box_pro_board`.

Then, power cycle the board by disconnecting and reconnecting the USB cable.
Run your favorite terminal program to listen for output.

.. code-block:: console
$ minicom -D <tty_device> -b 115200
Replace :code:`<tty_device>` with the correct device path automatically created on
the host after the SensorTile.box Pro board gets connected to it,
usually :code:`/dev/ttyUSBx` or :code:`/dev/ttyACMx` (with x being 0, 1, 2, ...).
The ``-b`` option sets baud rate ignoring the value from config.

Sample Output
=============

The sample code outputs sensors data on the SensorTile.box Pro console.

.. code-block:: console
SensorTile.box Pro dashboard
HTS221: Temperature: 26.4 C
HTS221: Relative Humidity: 60.5%
LSM6DSV16X: Accel (m.s-2): x: -0.158, y: 0.158, z: 9.811
LSM6DSV16X: GYro (dps): x: 0.003, y: 0.000, z: -0.005
1:: lsm6dsv16x acc trig 836
1:: lsm6dsv16x gyr trig 836
<repeats endlessly every 2s>
14 changes: 14 additions & 0 deletions samples/boards/sensortile_box_pro/sensors-on-board/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CONFIG_LOG=y
CONFIG_PRINTK=y
CONFIG_SPI=y
CONFIG_I2C=y
CONFIG_GPIO=y

# config sensors
CONFIG_SENSOR=y
CONFIG_SENSOR_LOG_LEVEL_DBG=y
CONFIG_HTS221_TRIGGER_NONE=y
CONFIG_LSM6DSV16X_TRIGGER_OWN_THREAD=y
CONFIG_LIS2MDL_TRIGGER_OWN_THREAD=y

CONFIG_CBPRINTF_FP_SUPPORT=y
12 changes: 12 additions & 0 deletions samples/boards/sensortile_box_pro/sensors-on-board/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sample:
description: SensorTile.box Pro board testing
name: SensorTile.box Pro test
tests:
sample.board.sensortile_box_pro.sensors-on-board:
harness: sensor
platform_allow: sensortile_box_pro
tags: sensors
depends_on:
- i2c
- spi
- gpio

0 comments on commit 5c5c239

Please sign in to comment.