zephyr/samples/sensor/tmp116
Keith Packard 0b90fd5adf samples, tests, boards: Switch main return type from void to int
As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.

Most of these changes were automated using coccinelle with the following
script:

@@
@@
- void
+ int
main(...) {
	...
-	return;
+	return 0;
	...
}

Approximately 40 files had to be edited by hand as coccinelle was unable to
fix them.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-14 07:49:41 +09:00
..
boards samples: sensors: Remove label property from devicetree overlays 2022-07-19 08:23:35 -05:00
src samples, tests, boards: Switch main return type from void to int 2023-04-14 07:49:41 +09:00
CMakeLists.txt cmake: increase minimal required version to 3.20.0 2021-08-20 09:47:34 +02:00
prj.conf sensors: Remove unnecessary Kconfig setting of sensors 2022-07-25 15:18:56 +02:00
README.rst samples: sensor: tmp116: Add sample code for tmp117 2020-12-20 13:02:21 -05:00
sample.yaml yamllint: indentation: fix files in samples/ 2023-01-04 14:23:53 +01:00

.. _ti_tmp116_sample:

TI_TMP116 Sample
################

Description
***********

This sample application periodically takes temperature readings using the ti_tmp116
sensor driver. The result is written to the console. This sample also included the code
to use the  features provided by TMP117, which is a sensor similar to TMP116

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

This sample needs a TI TMP116 or TI TMP117 sensor connected to the target board's I2C
connector.


Wiring
******

This sample is tested with Nucleo STM32F401RE board.

The sensor operates at 3.3V and uses I2C to communicate with the board.

External Wires:

* Breakout **GND** pin <--> Nucleo **GND** pin
* Breakout **VCC** pin <--> Nucleo **3V3** pin
* Breakout **SDA** pin <--> Nucleo **CN5-D14** pin
* Breakout **SCL** pin <--> Nucleo **CN5-D15** pin

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

In order to build the sample, connect the board to the computer with a USB cable and enter the
following commands:

.. zephyr-app-commands::
   :zephyr-app: samples/sensor/tmp116
   :board: nucleo_f401re
   :goals: build flash
   :compact:

Sample Output
*************
The output can be seen via a terminal emulator (e.g. minicom). Connect the board with a USB cable
to the computer and open /dev/ttyACM0 with the below serial settings:

* Baudrate: 115200
* Parity: None
* Data: 8
* Stop bits: 1

The output should look like this:

.. code-block:: console

    Device TMP116 - 0x200010a8 is ready
    temp is 26.7031250 oC
    temp is 26.7109375 oC
    ...