expand to tree htu sensors
This commit is contained in:
parent
9355f678e3
commit
e93083073c
7 changed files with 386 additions and 20 deletions
|
@ -45,7 +45,7 @@
|
|||
static void res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
|
||||
|
||||
/* A simple getter example. Returns the reading from the sensor with a simple etag */
|
||||
RESOURCE(res_htu21dhum,
|
||||
RESOURCE(res_dhtahum,
|
||||
"title=\"Moisture status\";rt=\"Moisture\"",
|
||||
res_get_handler,
|
||||
NULL,
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
static void res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
|
||||
|
||||
/* A simple getter example. Returns the reading from the sensor with a simple etag */
|
||||
RESOURCE(res_htu21dtemp,
|
||||
RESOURCE(res_dhtatemp,
|
||||
"title=\"Temperature status\";rt=\"Temperatur\"",
|
||||
res_get_handler,
|
||||
NULL,
|
||||
|
|
80
examples/osd/arduino-dht/resources/res-dhtbhum.c
Normal file
80
examples/osd/arduino-dht/resources/res-dhtbhum.c
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Moisture resource
|
||||
* \author
|
||||
* Harald Pichler <harald@the-develop.net>
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "rest-engine.h"
|
||||
#include "Arduino.h"
|
||||
|
||||
static void res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
|
||||
|
||||
/* A simple getter example. Returns the reading from the sensor with a simple etag */
|
||||
RESOURCE(res_dhtbhum,
|
||||
"title=\"Moisture status\";rt=\"Moisture\"",
|
||||
res_get_handler,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
extern char dhtb_hum_s[8];
|
||||
|
||||
|
||||
static void
|
||||
res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||
{
|
||||
|
||||
unsigned int accept = -1;
|
||||
REST.get_header_accept(request, &accept);
|
||||
|
||||
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
|
||||
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%s", dhtb_hum_s);
|
||||
|
||||
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
||||
} else if(accept == REST.type.APPLICATION_JSON) {
|
||||
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'moisture':%s}", dhtb_hum_s);
|
||||
|
||||
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
||||
} else {
|
||||
REST.set_response_status(response, REST.status.NOT_ACCEPTABLE);
|
||||
const char *msg = "Supporting content-types text/plain and application/json";
|
||||
REST.set_response_payload(response, msg, strlen(msg));
|
||||
}
|
||||
}
|
79
examples/osd/arduino-dht/resources/res-dhtbtemp.c
Normal file
79
examples/osd/arduino-dht/resources/res-dhtbtemp.c
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Moisture resource
|
||||
* \author
|
||||
* Harald Pichler <harald@the-develop.net>
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "rest-engine.h"
|
||||
#include "Arduino.h"
|
||||
|
||||
static void res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
|
||||
|
||||
/* A simple getter example. Returns the reading from the sensor with a simple etag */
|
||||
RESOURCE(res_dhtbtemp,
|
||||
"title=\"Temperature status\";rt=\"Temperatur\"",
|
||||
res_get_handler,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
extern char dhtb_temp_s[8];
|
||||
|
||||
static void
|
||||
res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||
{
|
||||
|
||||
unsigned int accept = -1;
|
||||
REST.get_header_accept(request, &accept);
|
||||
|
||||
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
|
||||
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%s", dhtb_temp_s);
|
||||
|
||||
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
||||
} else if(accept == REST.type.APPLICATION_JSON) {
|
||||
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'temperature':%s}", dhtb_temp_s);
|
||||
|
||||
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
||||
} else {
|
||||
REST.set_response_status(response, REST.status.NOT_ACCEPTABLE);
|
||||
const char *msg = "Supporting content-types text/plain and application/json";
|
||||
REST.set_response_payload(response, msg, strlen(msg));
|
||||
}
|
||||
}
|
80
examples/osd/arduino-dht/resources/res-dhtchum.c
Normal file
80
examples/osd/arduino-dht/resources/res-dhtchum.c
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Moisture resource
|
||||
* \author
|
||||
* Harald Pichler <harald@the-develop.net>
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "rest-engine.h"
|
||||
#include "Arduino.h"
|
||||
|
||||
static void res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
|
||||
|
||||
/* A simple getter example. Returns the reading from the sensor with a simple etag */
|
||||
RESOURCE(res_dhtchum,
|
||||
"title=\"Moisture status\";rt=\"Moisture\"",
|
||||
res_get_handler,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
extern char dhtc_hum_s[8];
|
||||
|
||||
|
||||
static void
|
||||
res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||
{
|
||||
|
||||
unsigned int accept = -1;
|
||||
REST.get_header_accept(request, &accept);
|
||||
|
||||
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
|
||||
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%s", dhtc_hum_s);
|
||||
|
||||
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
||||
} else if(accept == REST.type.APPLICATION_JSON) {
|
||||
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'moisture':%s}", dhtc_hum_s);
|
||||
|
||||
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
||||
} else {
|
||||
REST.set_response_status(response, REST.status.NOT_ACCEPTABLE);
|
||||
const char *msg = "Supporting content-types text/plain and application/json";
|
||||
REST.set_response_payload(response, msg, strlen(msg));
|
||||
}
|
||||
}
|
79
examples/osd/arduino-dht/resources/res-dhtctemp.c
Normal file
79
examples/osd/arduino-dht/resources/res-dhtctemp.c
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Moisture resource
|
||||
* \author
|
||||
* Harald Pichler <harald@the-develop.net>
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "rest-engine.h"
|
||||
#include "Arduino.h"
|
||||
|
||||
static void res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
|
||||
|
||||
/* A simple getter example. Returns the reading from the sensor with a simple etag */
|
||||
RESOURCE(res_dhtctemp,
|
||||
"title=\"Temperature status\";rt=\"Temperatur\"",
|
||||
res_get_handler,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
extern char dhtc_temp_s[8];
|
||||
|
||||
static void
|
||||
res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||
{
|
||||
|
||||
unsigned int accept = -1;
|
||||
REST.get_header_accept(request, &accept);
|
||||
|
||||
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
|
||||
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%s", dhtc_temp_s);
|
||||
|
||||
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
||||
} else if(accept == REST.type.APPLICATION_JSON) {
|
||||
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'temperature':%s}", dhtc_temp_s);
|
||||
|
||||
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
||||
} else {
|
||||
REST.set_response_status(response, REST.status.NOT_ACCEPTABLE);
|
||||
const char *msg = "Supporting content-types text/plain and application/json";
|
||||
REST.set_response_payload(response, msg, strlen(msg));
|
||||
}
|
||||
}
|
|
@ -17,7 +17,9 @@ extern "C" {
|
|||
#include "arduino-process.h"
|
||||
#include "rest-engine.h"
|
||||
|
||||
extern resource_t res_htu21dtemp, res_htu21dhum, res_battery;
|
||||
extern resource_t res_dhtatemp, res_dhtahum, res_battery;
|
||||
extern resource_t res_dhtbtemp, res_dhtbhum;
|
||||
extern resource_t res_dhtctemp, res_dhtchum;
|
||||
|
||||
#define LED_PIN 4
|
||||
|
||||
|
@ -30,13 +32,29 @@ extern resource_t res_htu21dtemp, res_htu21dhum, res_battery;
|
|||
// Connect pin 2 of the sensor to whatever your DHTPIN is
|
||||
// Connect pin 4 (on the right) of the sensor to GROUND
|
||||
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) o
|
||||
#define DHTPIN 9 // what digital pin we're connected to
|
||||
DHT dht(DHTPIN, DHTTYPE);
|
||||
#define DHTPINA 9 // what digital pin we're connected to
|
||||
DHT dhta(DHTPINA, DHTTYPE);
|
||||
|
||||
float dht_hum;
|
||||
float dht_temp;
|
||||
char dht_hum_s[8];
|
||||
char dht_temp_s[8];
|
||||
#define DHTPINB 8 // what digital pin we're connected to
|
||||
DHT dhtb(DHTPINB, DHTTYPE);
|
||||
|
||||
#define DHTPINC 7 // what digital pin we're connected to
|
||||
DHT dhtc(DHTPINC, DHTTYPE);
|
||||
|
||||
float dhta_hum;
|
||||
float dhta_temp;
|
||||
char dhta_hum_s[8];
|
||||
char dhta_temp_s[8];
|
||||
|
||||
float dhtb_hum;
|
||||
float dhtb_temp;
|
||||
char dhtb_hum_s[8];
|
||||
char dhtb_temp_s[8];
|
||||
|
||||
float dhtc_hum;
|
||||
float dhtc_temp;
|
||||
char dhtc_hum_s[8];
|
||||
char dhtc_temp_s[8];
|
||||
|
||||
}
|
||||
|
||||
|
@ -47,12 +65,18 @@ void setup (void)
|
|||
pinMode(LED_PIN, OUTPUT);
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
// DHT sensor
|
||||
dht.begin();
|
||||
dhta.begin();
|
||||
dhtb.begin();
|
||||
dhtc.begin();
|
||||
// init coap resourcen
|
||||
rest_init_engine ();
|
||||
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
||||
rest_activate_resource (&res_htu21dtemp, "s/temp");
|
||||
rest_activate_resource (&res_htu21dhum, "s/hum");
|
||||
rest_activate_resource (&res_dhtatemp, "s/tempa");
|
||||
rest_activate_resource (&res_dhtahum, "s/huma");
|
||||
rest_activate_resource (&res_dhtbtemp, "s/tempb");
|
||||
rest_activate_resource (&res_dhtbhum, "s/humb");
|
||||
rest_activate_resource (&res_dhtctemp, "s/tempc");
|
||||
rest_activate_resource (&res_dhtchum, "s/humc");
|
||||
rest_activate_resource (&res_battery, "s/battery");
|
||||
#pragma GCC diagnostic pop
|
||||
mcu_sleep_set(128); // Power consumtion 278uA; average over 20 minutes
|
||||
|
@ -64,20 +88,44 @@ void loop (void)
|
|||
{
|
||||
// Reading temperature or humidity takes about 250 milliseconds!
|
||||
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
|
||||
dht_hum = dht.readHumidity();
|
||||
dhta_hum = dhta.readHumidity();
|
||||
dhtb_hum = dhtb.readHumidity();
|
||||
dhtc_hum = dhtc.readHumidity();
|
||||
// Read temperature as Celsius (the default)
|
||||
dht_temp = dht.readTemperature();
|
||||
dhta_temp = dhta.readTemperature();
|
||||
dhtb_temp = dhtb.readTemperature();
|
||||
dhtc_temp = dhtc.readTemperature();
|
||||
|
||||
// Check if any reads failed and exit early (to try again).
|
||||
if (isnan(dht_hum) || isnan(dht_temp)) {
|
||||
printf("Failed to read from DHT sensor!\n");
|
||||
if (isnan(dhta_hum) || isnan(dhta_temp)) {
|
||||
printf("Failed to read from DHTa sensor!\n");
|
||||
return;
|
||||
}
|
||||
if (isnan(dhtb_hum) || isnan(dhtb_temp)) {
|
||||
printf("Failed to read from DHTb sensor!\n");
|
||||
return;
|
||||
}
|
||||
if (isnan(dhtc_hum) || isnan(dhtc_temp)) {
|
||||
printf("Failed to read from DHTc sensor!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
dtostrf(dht_temp , 0, 2, dht_temp_s );
|
||||
dtostrf(dht_hum , 0, 2, dht_hum_s );
|
||||
dtostrf(dhta_temp , 0, 2, dhta_temp_s );
|
||||
dtostrf(dhta_hum , 0, 2, dhta_hum_s );
|
||||
|
||||
dtostrf(dhtb_temp , 0, 2, dhtb_temp_s );
|
||||
dtostrf(dhtb_hum , 0, 2, dhtb_hum_s );
|
||||
|
||||
dtostrf(dhtc_temp , 0, 2, dhtc_temp_s );
|
||||
dtostrf(dhtc_hum , 0, 2, dhtc_hum_s );
|
||||
|
||||
// debug only
|
||||
printf("Temp: '%s'",dht_temp_s);
|
||||
printf("\t\tHum: '%s'\n",dht_hum_s);
|
||||
printf("Tempa: '%s'",dhta_temp_s);
|
||||
printf("\t\tHuma: '%s'\n",dhta_hum_s);
|
||||
|
||||
printf("Tempb: '%s'",dhtb_temp_s);
|
||||
printf("\t\tHumb: '%s'\n",dhtb_hum_s);
|
||||
|
||||
printf("Tempc: '%s'",dhtc_temp_s);
|
||||
printf("\t\tHumc: '%s'\n",dhtc_hum_s);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue