Extras/DHT improvements: makefile fix, replace DHT_TYPE macro by param (#252)
This commit is contained in:
parent
574f944fbb
commit
2ab9beb946
5 changed files with 38 additions and 36 deletions
|
@ -1,4 +1,4 @@
|
|||
PROGRAM=dht_sensor
|
||||
PROGRAM = dht_sensor
|
||||
EXTRA_COMPONENTS = extras/dht
|
||||
include ../../common.mk
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "esp/uart.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "dht.h"
|
||||
#include <dht/dht.h>
|
||||
#include "esp8266.h"
|
||||
|
||||
/* An example using the ubiquitous DHT** humidity sensors
|
||||
|
@ -16,6 +16,7 @@
|
|||
* from a sensor attached to GPIO pin 4.
|
||||
*/
|
||||
uint8_t const dht_gpio = 4;
|
||||
const dht_sensor_type_t sensor_type = DHT_TYPE_DHT22;
|
||||
|
||||
void dhtMeasurementTask(void *pvParameters)
|
||||
{
|
||||
|
@ -28,7 +29,7 @@ void dhtMeasurementTask(void *pvParameters)
|
|||
gpio_set_pullup(dht_gpio, false, false);
|
||||
|
||||
while(1) {
|
||||
if (dht_read_data(dht_gpio, &humidity, &temperature)) {
|
||||
if (dht_read_data(sensor_type, dht_gpio, &humidity, &temperature)) {
|
||||
printf("Humidity: %d%% Temp: %dC\n",
|
||||
humidity / 10,
|
||||
temperature / 10);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue