I am working on the PietteTech_DHT library with DHT22 sensors, and example is working well in pin 2 and pin 3, however when I am connecting the DHT22 sensors with pin 5 or pin 6, the output will get stuck for no reason.
I am using the PietteTech_DHT example, and only change the pin declarations in this
#define DHTTYPEA DHT22 // Sensor type DHT11/21/22/AM2301/AM2302
#define DHTPINA 6 // Digital pin for comunications
#define DHTTYPEB DHT22 // Sensor type DHT11/21/22/AM2301/AM2302
#define DHTPINB 5 // Digital pin for comunications
normally it should be ok, but the serial output will get stuck in
0:00s : retrieving information from sensor : Read sensor A.
and seems the sensor reading keep loops in while (DHTA.acquiring()) ;
I too, would expect that to work. Hmm, we could always try asking @mtnscott who wrote the library. @peekay123 and/or @bko might also be able to chime in.
@helxsz, are you using a Photon or a Core? Also, if I can suggest using the full pin designation in your code (D5, D6 instead of 5,6). I can’t remember my own tests but D5, D6 and D7 are pins designated for JTAG debugging so I’m not sure what, if any, impact that may have. @BDub, any ideas?
If you can give me some library code and an example, I’ll give it a try and see what the difference is on my oscilloscope. Once you take over a pin’s mode with pinMode() the state of the pins from boot will not be the default JTAG pull up/ pull down inputs. In fact, they should be defaulted as input/no pull up once user code runs (i.e., once you leave the bootloader).
the DHT22 is pretty quirky… I stopped using it after trying a few different libraries and it still gets stuck and it always get’s stuck. I think the issue may be with the sensor… I should try it with an arduino and see if it hangs… It is good for starters, but I would recommend finding a different sensor from production. Honeywell and silicon labs both make an i2c sensor that is rock solid. They work with the wire library
There is a lot going on with this pin in this library... I wonder if there is a subtle difference that's preventing interrupts from working the same way on D6 as it does on the rest of the pins:
/*
* Toggle the digital output to trigger the DHT device
* to send us temperature and humidity data
*/
pinMode(_sigPin, OUTPUT);
digitalWrite(_sigPin, LOW);
if (_type == DHT11)
delay(18); // DHT11 Spec: 18ms min
else
delayMicroseconds(1500); // DHT22 Spec: 0.8-20ms, 1ms typ
pinMode(_sigPin, INPUT); // Note Hi-Z mode with pullup resistor
// will keep this high until the DHT responds.
/*
* Attach the interrupt handler to receive the data once the DHT
* starts to send us data
*/
_us = micros();
attachInterrupt(_sigPin, isrCallback_wrapper, FALLING);
AHA... attachInterrupt() is not supported on the Core for pins D5~D7 or A2