@manitou and @el_supremo So, still not working.
The Adafruit DHT-sensor-library reports a temperature of -3272.4C.
An impressive and stunning repudiation of the third law of thermodynamics.
(Temperatures above 0C seem to be correct to reasonable accuracy).
Here are the relevant lines from the code:
Code:
#include "DHT.h
// DHT sensor
#define DHTPIN 7
#define DHTPWR 8
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
/* I/O support
*/
int sendbuffer( void *p, size_t nlen ) {
size_t written = 0;
while( written != nlen ) {
written += Serial.write( (char *)p+written, nlen-written);
}
return written;
}
int sendprintf( char *fmt, ... ) {
va_list ap;
char sbuf[128];
int nlen;
va_start(ap, fmt);
nlen = vsnprintf(sbuf, sizeof(sbuf), fmt, ap);
va_end(ap);
sendbuffer(sbuf,nlen+1);
return nlen;
}
void setup() {
// ...
pinMode(DHTPWR,OUTPUT);
digitalWrite(DHTPWR,HIGH); // +Vcc for DHT
dht.begin();
// ...
}
void loop() {
// other stuff
if ( commandmatch( command, 'temperature' ) ) {
float h, t;
h = dht.readHumidity();
t = dht.readTemperature();
if ( isnan(h) || isnan(t) ) {
sendstring( (char *)"Error: Failed to read from DHT sensor");
}
else {
sendprintf( (char *)"Temperature %.1f Humidity %.1f ", t, h );
}
sendstring( (char *)"done" );
}
// more other stuff
}