no data at all.
Uno\examples\dht22_test
DHT22 issues
Re: DHT22 issues
I will check it tomorrow. It have to work...
Re: DHT22 issues
thanks!
Re: DHT22 issues
So, I checked it and it works normally on 2.0.8:
DHT22
DHT11
Please check the pinout:
DHT22
Code: Select all
Raw data: { 0 C8 0 F5 BD }
Temperature:24.50
Humidity:20.00
Millis:27290
DHT read result:0
Raw data: { 0 C8 0 F4 BC }
Temperature:24.40
Humidity:20.00
Millis:30322
DHT read result:0
Raw data: { 0 C7 0 F4 BB }
Temperature:24.40
Humidity:19.90
Millis:33354
DHT read result:0
Raw data: { 0 C7 0 F3 BA }
Temperature:24.30
Humidity:19.90
Millis:36386
DHT read result:0
Raw data: { 0 C6 0 F3 B9 }
Temperature:24.30
Humidity:19.80
Millis:39417
DHT read result:0
Raw data: { 0 C6 0 F2 B8 }
Temperature:24.20
Humidity:19.80
Millis:42450
DHT read result:0
Raw data: { 0 C8 0 F2 BA }
Temperature:24.20
Humidity:20.00
Millis:45482
DHT read result:0
Raw data: { 0 CA 0 F1 BB }
Temperature:24.10
Humidity:20.20
Millis:48514
DHT read result:0
Raw data: { 0 CC 0 F1 BD }
Temperature:24.10
Humidity:20.40
Code: Select all
DHT read result:0
Raw data: { 1F 0 1D 0 3C }
Millis:12175
DHT read result:0
Raw data: { 1F 0 1D 0 3C }
Temperature:29.00
Humidity:31.00
Millis:15217
DHT read result:0
Raw data: { 1F 0 1D 0 3C }
Temperature:29.00
Humidity:31.00
Millis:18259
DHT read result:0
Raw data: { 1F 0 1D 0 3C }
Temperature:29.00
Humidity:31.00
Millis:21301
DHT read result:0
Raw data: { 1F 0 1D 0 3C }
Temperature:29.00
Humidity:31.00
Millis:24343
DHT read result:0
Raw data: { 1F 0 1D 0 3C }
Temperature:29.00
Humidity:31.00
Millis:27385
DHT read result:0
Raw data: { 1F 0 1D 0 3C }
Temperature:29.00
Humidity:31.00
Code: Select all
DHT11/DHT22 Z-Uno
1 3v3
2 11
3 x (NC)
4 GND
Last edited by p0lyg0n1 on 10 Mar 2017 12:09, edited 1 time in total.
Re: DHT22 issues
crazy! ok! I'll re-check
Re: DHT22 issues
still not works. now i'll re-check sensor on rpi.
btw, i have patched ZUNO_DHT.cpp ZUNO_DHT.h cuz constructor definition as s_pin
ompiling _dht22_test_sdcpp_.cpp ...Traceback (most recent call last):
File "<string>", line 205, in buildFunc
[....]
KeyError: 'first_sketch_line'
btw, i have patched ZUNO_DHT.cpp ZUNO_DHT.h cuz constructor definition as s_pin
ompiling _dht22_test_sdcpp_.cpp ...Traceback (most recent call last):
File "<string>", line 205, in buildFunc
[....]
KeyError: 'first_sketch_line'
Re: DHT22 issues
You have to use s_pin for this.
See this for details:
http://z-uno.z-wave.me/Reference/s_pin/
You can use any pin from the range 9-16 for DHT.
The original code:
See this for details:
http://z-uno.z-wave.me/Reference/s_pin/
You can use any pin from the range 9-16 for DHT.
The original code:
Code: Select all
/* DHT library
MIT license
written by Adafruit Industries
UPGRADED/Rewriten by Z-Wave>ME for project Z-Uno 2016
*/
#include "ZUNO_DHT.h"
#define MIN_INTERVAL 2000
#define DEBUG_DHT 0
DHT::DHT(uint8_t pin, uint8_t type): _pin(pin)
{
_type = type;
// reading pulses from DHT sensor.
}
void DHT::begin(void) {
// set up the pins!
pinMode(_pin, INPUT_PULLUP);
_lastreadtime = 0;
}
// returns temperature in 10 th of Celsius
int DHT::readTemperatureC10(bool force)
{
if(read(force) > DHT_RESULT_PREVIOUS)
return BAD_DHT_VALUE;
return temperature;
}
// returns humidity in 10 th of percent
int DHT::readHumidityH10(bool force)
{
if(read(force) > DHT_RESULT_PREVIOUS)
return BAD_DHT_VALUE;
return humidity;
}
// Returns temperature in float in Celsius
float DHT::readTemperature(bool force)
{
return readTemperatureC10(force) / 10.0;
}
// Returns humidity in float
float DHT::readHumidity(bool force)
{
return readHumidityH10(force) / 10.0;
}
// DBG
#if DEBUG_DHT
byte dbg_timings_s[80];
#endif
byte DHT::read(bool force) {
byte time_i1, time_i2;
word wi = 0;
byte time_ref;
//s_pin tp = 12;
byte i = 0;
byte ci = 0;
byte cb =0;
//pinMode(tp, OUTPUT);
//digitalWrite(tp, 0);
// Чтобы не опрашивать сенсор слишком часто
uint32_t currenttime = millis();
if (!force && ((currenttime - _lastreadtime) < 2000)) {
return DHT_RESULT_PREVIOUS; // return last correct measurement
}
_lastreadtime = currenttime;
// Посылаем стартовый импульс
// 0 на 1 мс и болльше
//noInterrupts();
pinMode(_pin, OUTPUT);
digitalWrite(_pin, LOW); // Send start signal
switch(_type)
{
case DHT11:
delay(13); // Датчик долго думает
break;
default:
delayMicroseconds(1400); // Гораздо быстрее откликается
break;
}
pinMode(_pin, INPUT_PULLUP);
noInterrupts();
time_i1 = 0;
while(digitalRead(_pin))//digitalRead(_pin))
{
wi++;
if(!wi)
{
interrupts();
return DHT_RESULT_ERROR_NOSYNC;
}
NOPS(8);
}
time_i1 = 0;
while(!digitalRead(_pin))
{
time_i1++;
if(!time_i1)
break;
}
time_i2 = 0;
while(digitalRead(_pin))
{
time_i2++;
if(!time_i2)
break;
}
if(time_i1 < 10 || time_i2 < 10)
{
interrupts();
return DHT_RESULT_ERROR_NOSYNC;
}
// Вычисляем опорное время для "1"
// == Половина среднего времени отклика датчика
// Вычисляется здесь т.к.
// время стартового интервала будет плавать в цикле чтения битов
// особенно это заметно на каждом 8-ом бите
time_ref = time_i1 + time_i2;
time_ref >>= 2;
while(i<80)
{
switch(i&0x01)
{
case 0:
time_i1 = 0;
while(!digitalRead(_pin)) time_i1++;
#if DEBUG_DHT
dbg_timings_s[i] = time_i1;
#endif
break;
case 1:
time_i2 = 0;
while(digitalRead(_pin)) time_i2++;
#if DEBUG_DHT
dbg_timings_s[i] = time_i2;
#endif
cb <<= 1;
cb |= (time_i2 > time_ref);
break;
}
i++;
if((i & 0x0F)==0)
{
data_ptr[ci++] = cb;
cb = 0;
}
}
interrupts();
#if DEBUG_DHT
Serial.print("TIMINGS \n");
for(i=0;i<80;i++)
{
Serial.print("EDGE #");
Serial.print(i);
Serial.print(" ");
Serial.println(dbg_timings_s[i]);
}
Serial.print("RAW ");
for(i=0;i<5;i++)
{
Serial.print((uint16_t)data_ptr[i], HEX);
Serial.print(" ");
}
Serial.println(" ");
#endif
byte sum = data_ptr[0];
sum += data_ptr[1];
sum += data_ptr[2];
sum += data_ptr[3];
if ( sum != data_ptr[4])
{
#if DEBUG_DHT
Serial.print(" Calculated sum: ");
Serial.print(sum, HEX);
Serial.println(" ");
#endif
return DHT_RESULT_ERROR_CRC;
}
if(_type == DHT11)
{
humidity = data_ptr[0];
temperature = data_ptr[2];
humidity *= 10;
temperature *= 10;
}
else
{
humidity = data_ptr[0];
humidity <<= 8;
humidity += data_ptr[1];
temperature = data_ptr[2] & ~(0x80);
temperature <<= 8;
temperature += data_ptr[3];
if ( data_ptr[2] & 0x80)
temperature -= temperature;
}
return DHT_RESULT_OK;
}
Re: DHT22 issues
>9-16
lol!
my fail
lol!
my fail
Re: DHT22 issues
Sir! can you put into the header (for idiots like me) warning about 9-16 pins?
Thank you so much and I apologize for the oversight!
Thank you so much and I apologize for the oversight!
Re: DHT22 issues
Found an issue in the last version of compiler. The previous version checks the s_pin before code generation and throws readable error. The last version skips this check and gives you unreadable trace... We will fix it. So, It's our bug. Thank you for your tests.