hello,
is it possible to access DHT22 values through PCF8574 pins?
I don't have enough free digital pins on board to use the DHT lib e.g. by Adafruit GitHub - adafruit/DHT-sensor-library: Arduino library for DHT11, DHT22, etc Temperature & Humidity Sensors (at least I don't see how to utilize it through PCF8574 pins)
Having read the library (not sure if it was the Adafruit one; there are others) I think it is possible. It's pretty much bitbanging without the use of interrupts or an external clock signal. I didn't see anything that makes me believe it can't be done, even though I've never seen a library for it.
The main problem may be slowness of reading the port expander's pins as you have to do that over I2C. So you have to study it's data sheet to see reaction times. Maybe other port expanders, like the newer but also more expensive MCP23008, can give better results.
I also have an MCP23017, but AFAIK the PCF8574 is supposed to work fine at 400kHz i2c clock, just like the MCP.
Nonetheless, I need either a new DHT22 lib or an expansion to the Adafruit DHT lib, ready to use.
Does someone know one?
It's not just the I2C clock, it's the whole chain - also how fast the reply comes from the PCF resp MCP chip.
ok, what ever it requires to work with -
but it must work with either i2c expander reliably.
That's why I wrote:
I need either a new DHT22 lib or an expansion to the Adafruit DHT lib, ready to use.
Does someone know one?
don't know - wouldn't it be easier to move something else to your port expander?
I didn't ask who doesn't know a DHT lib for i2c expanders, I asked: who knows it
so, again:
I need either a new DHT22 lib or an expansion to the Adafruit DHT lib, ready to use.
Does someone know one?
Please do only reply if you know a lib which is already published or which can be published!
If Google doesn't know, maybe you should start hacking yourself! It's a pretty straightforward protocol.
as stated,
I didn't ask who doesn't know it, I asked: who knows it.
I need either a new DHT22 lib or an expansion to the Adafruit DHT lib, ready to use.
Does someone know one?
Please do only reply if you know a lib which is already published or which can be published!
I will use the library TroykaDHT.h
I had to rewrite it completely, or rather put it into the code.
Instead
pinMode (_pin, OUTPUT); -> PCF8574.pinMode (0, OUTPUT);
digitalWrite (_pin, LOW); -> PCF8574.digitalWrite (0, LOW);
pinMode (_pin, INPUT_PULLUP); -> PCF8574.pinMode (0, INPUT_PULLUP);
digitalRead (pin); -> PCF8574.digitalRead (0);
In general, take out of the library! and completely rewrite. :
Hi
I have same problem with dht22, Adafruit library seems to not support pcf8574 functionality ,
Is there any working way for this ?
No.
I2C is likely too slow for the required timing accuracy to begin with. Just a simple pin read can take as long as 1-2 milliseconds - where you need to be in the microsecond kind of speeds for that sensor.
wvmarle:
No.
I2C is likely too slow for the required timing accuracy to begin with. Just a simple pin read can take as long as 1-2 milliseconds - where you need to be in the microsecond kind of speeds for that sensor.
Thanks for your response, then how @LordNicon1987 said that he could did this matter ?
I only see LordNicon1987 mentioning an attempt at rewriting the library. I don't see any reports of actual success in that post.
LordNicon1987:
I will use the library TroykaDHT.hI had to rewrite it completely, or rather put it into the code.
Instead
pinMode (_pin, OUTPUT); -> PCF8574.pinMode (0, OUTPUT);
digitalWrite (_pin, LOW); -> PCF8574.digitalWrite (0, LOW);
pinMode (_pin, INPUT_PULLUP); -> PCF8574.pinMode (0, INPUT_PULLUP);
digitalRead (pin); -> PCF8574.digitalRead (0);In general, take out of the library! and completely rewrite. :
Hi, any luck ?
wvmarle:
No.
I2C is likely too slow for the required timing accuracy to begin with. Just a simple pin read can take as long as 1-2 milliseconds - where you need to be in the microsecond kind of speeds for that sensor.
I searched this mater that you said, for mcp23017 and pcf8574, and nowhere tells that dht not worked with port extenders,
In this article Learn How to Use the DHT22 with an Arduino; Full code examples included tell that we can use dht22 with mcp23017 !
They say so indeed - but do not provide (a link to) working code, and I have yet to see such code.
then what ? buy another module with another port or ?
Put something else on your port extender. Something that's now on one of the other 18 I/O pins of an Uno. Most peripherals can be interfaced that way just fine, the DHT22 is one of the few exceptions. Just remember that the PCF8574 can't source any significant current, only sink.
thanks, I use esp01 in my project and need to use one port extender!
can you explain more or send me references about sink that you said?
wvmarle:
Put something else on your port extender. Something that's now on one of the other 18 I/O pins of an Uno. Most peripherals can be interfaced that way just fine, the DHT22 is one of the few exceptions. Just remember that the PCF8574 can't source any significant current, only sink.
thanks, I use esp01 in my project and need to use one port extender!
can you explain more or send me references about sink that you said?