samples: sensors: drop dht sample as a more generic one exists
This sample adds no value compared to generic_dht_polling or sensor shell. Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This commit is contained in:
parent
5f65b30117
commit
7147b344a6
7 changed files with 0 additions and 183 deletions
|
@ -1,12 +0,0 @@
|
||||||
#
|
|
||||||
# Copyright (c) 2019 Nordic Semiconductor ASA
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.20.0)
|
|
||||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
|
||||||
project(dht)
|
|
||||||
|
|
||||||
FILE(GLOB app_sources src/*.c)
|
|
||||||
target_sources(app PRIVATE ${app_sources})
|
|
|
@ -1,45 +0,0 @@
|
||||||
.. _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: nrf52dk/nrf52832
|
|
||||||
: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>
|
|
|
@ -1,11 +0,0 @@
|
||||||
/*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
/ {
|
|
||||||
dht22 {
|
|
||||||
compatible = "aosong,dht";
|
|
||||||
status = "okay";
|
|
||||||
dio-gpios = <&gpiob 9 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -1,14 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 Nordic Semiconductor ASA
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
/ {
|
|
||||||
dht22 {
|
|
||||||
compatible = "aosong,dht";
|
|
||||||
status = "okay";
|
|
||||||
dio-gpios = <&gpio0 11 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
|
||||||
dht22;
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -1,13 +0,0 @@
|
||||||
#
|
|
||||||
# Copyright (c) 2019 Nordic Semiconductor ASA
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
CONFIG_SENSOR=y
|
|
||||||
CONFIG_GPIO=y
|
|
||||||
|
|
||||||
# Need float format support
|
|
||||||
CONFIG_REQUIRES_FULL_LIBC=y
|
|
||||||
CONFIG_REQUIRES_FLOAT_PRINTF=y
|
|
||||||
CONFIG_CBPRINTF_FP_SUPPORT=y
|
|
|
@ -1,17 +0,0 @@
|
||||||
#
|
|
||||||
# Copyright (c) 2019 Nordic Semiconductor ASA
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
common:
|
|
||||||
filter: CONFIG_FULL_LIBC_SUPPORTED
|
|
||||||
sample:
|
|
||||||
name: DHT Sensor Sample
|
|
||||||
tests:
|
|
||||||
sample.sensor.dht:
|
|
||||||
build_only: true
|
|
||||||
platform_allow: nrf52dk/nrf52832
|
|
||||||
integration_platforms:
|
|
||||||
- nrf52dk/nrf52832
|
|
||||||
tags: sensors
|
|
|
@ -1,71 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 Nordic Semiconductor ASA
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <zephyr/kernel.h>
|
|
||||||
#include <zephyr/device.h>
|
|
||||||
#include <zephyr/drivers/sensor.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
static const char *now_str(void)
|
|
||||||
{
|
|
||||||
static char buf[16]; /* ...HH:MM:SS.MMM */
|
|
||||||
uint32_t now = k_uptime_get_32();
|
|
||||||
unsigned int ms = now % MSEC_PER_SEC;
|
|
||||||
unsigned int s;
|
|
||||||
unsigned int min;
|
|
||||||
unsigned int h;
|
|
||||||
|
|
||||||
now /= MSEC_PER_SEC;
|
|
||||||
s = now % 60U;
|
|
||||||
now /= 60U;
|
|
||||||
min = now % 60U;
|
|
||||||
now /= 60U;
|
|
||||||
h = now;
|
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%u:%02u:%02u.%03u",
|
|
||||||
h, min, s, ms);
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
const struct device *const dht22 = DEVICE_DT_GET_ONE(aosong_dht);
|
|
||||||
|
|
||||||
if (!device_is_ready(dht22)) {
|
|
||||||
printf("Device %s is not ready\n", dht22->name);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
int rc = sensor_sample_fetch(dht22);
|
|
||||||
|
|
||||||
if (rc != 0) {
|
|
||||||
printf("Sensor fetch failed: %d\n", rc);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct sensor_value temperature;
|
|
||||||
struct sensor_value humidity;
|
|
||||||
|
|
||||||
rc = sensor_channel_get(dht22, SENSOR_CHAN_AMBIENT_TEMP,
|
|
||||||
&temperature);
|
|
||||||
if (rc == 0) {
|
|
||||||
rc = sensor_channel_get(dht22, SENSOR_CHAN_HUMIDITY,
|
|
||||||
&humidity);
|
|
||||||
}
|
|
||||||
if (rc != 0) {
|
|
||||||
printf("get failed: %d\n", rc);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("[%s]: %.1f Cel ; %.1f %%RH\n",
|
|
||||||
now_str(),
|
|
||||||
sensor_value_to_double(&temperature),
|
|
||||||
sensor_value_to_double(&humidity));
|
|
||||||
k_sleep(K_SECONDS(2));
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue