Commit 816d2c47 authored by Peter Bigot's avatar Peter Bigot Committed by Maureen Helm
Browse files

samples: sensor: dht: add sample



Add a sample to test the Aosong temperature/humidity sensor.

Signed-off-by: default avatarPeter Bigot <peter.bigot@nordicsemi.no>
parent 0cfac519
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
#

cmake_minimum_required(VERSION 3.13.1)
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(dht)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
+45 −0
Original line number Diff line number Diff line
.. _dht:

DHT: Aosong DHT Digital-output Humidity and Temperature Sensor
##############################################################

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

This sample application periodically (0.5 Hz) measures the ambient
temperature and humidity. The result is written to the console.

Wiring
*******

This sample uses an external breakout for the sensor.  A devicetree
overlay must be provided to identify the sensor variant and the GPIO
used to control the sensor.

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

After providing a devicetree overlay that specifies the sensor location,
build this sample app using:

.. zephyr-app-commands::
   :zephyr-app: samples/sensor/dht
   :board: nrf52_pca10040
   :goals: build flash

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

.. code-block:: console

   *** Booting Zephyr OS build zephyr-v2.1.0-329-g38418b26c4cc  ***
   [0:00:00.027]: 20.0 Cel ; 48.7 %RH
   [0:00:02.053]: 19.8 Cel ; 48.7 %RH
   [0:00:04.079]: 20.0 Cel ; 48.7 %RH
   [0:00:06.105]: 19.8 Cel ; 48.7 %RH
   [0:00:08.130]: 20.0 Cel ; 48.8 %RH
   [0:00:10.156]: 20.1 Cel ; 48.8 %RH
   [0:00:12.182]: 19.7 Cel ; 48.7 %RH
   [0:00:14.207]: 20.0 Cel ; 48.8 %RH

<repeats endlessly>
+15 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2019 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/ {
	dht22 {
		compatible = "aosong,dht";
		status = "okay";
		label = "DHT22";
		dio-gpios = <&gpio0 11 0>;
		dht22;
	};
};
+14 −0
Original line number Diff line number Diff line
#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
#

CONFIG_SENSOR=y
CONFIG_GPIO=y
CONFIG_DHT=y

# Need float format support
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_NANO=n
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
+13 −0
Original line number Diff line number Diff line
#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
#

sample:
  name: DHT Sensor Sample
tests:
  sample.sensor.dht:
    build_only: true
    platform_whitelist: nrf52_pca10040
    tags: sensors
Loading