zephyr/samples/sensor/thermometer
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: sensor: thermometer: update sample 2023-04-07 13:30:59 +02:00
src samples, tests, boards: Switch main return type from void to int 2023-04-14 07:49:41 +09:00
CMakeLists.txt
prj.conf
README.rst samples: sensor: thermometer: update sample 2023-04-07 13:30:59 +02:00
sample.yaml samples: sensor: thermometer: update sample 2023-04-07 13:30:59 +02:00

.. _thermometer-sample:

Thermometer sample
##################

Overview
********

This sample application periodically measures the ambient temperature
at 1Hz. The result is written to the console.

Wiring
*******

VDD pin should be connected to 2.3V to 5.5V
GND pin connected to 0V
VOUT pin connected to the ADC input pin.

.. _`MCP970X Sensor`: http://ww1.microchip.com/downloads/en/devicedoc/20001942g.pdf

An overlay is provided for the nrf52840dk_nrf52840 board with the
sensor connected to pin AIN7.

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

To build for the nrf52840dk_nrf52840 board use:

.. zephyr-app-commands::
	:zephyr-app: samples/sensor/thermometer
	:board: nrf52840dk_nrf52840
	:goals: build flash
	:compact:


To build for other boards and ambient temperature sensors, enable the sensor
node that supports ``SENSOR_CHAN_AMBIENT_TEMP`` and use an overlay to create an
alias named ``ambient-temp0`` to link to the node.  See the overlay used for the
``nrf52840dk_nrf52840`` board within this sample:
``boards/nrf52840dk_nrf52840.overlay``

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

.. code-block:: console

	*** Booting Zephyr OS build zephyr-v3.3.0-1205-g118f73e12a70 ***
	Thermometer Example (arm)
	Temperature device is 0x6150, name is mcp9700a
	Temperature is 24.0°C
	Temperature is 24.1°C
	Temperature is 24.2°C
	Temperature is 24.1°C
	Temperature is 24.0°C
	Temperature is 24.1°C