DHT22 through MCP23017

Hi guys,

Can someone point me how to address DHT to an MCP23017 pin?
I am using this IO expander in some project, and try to use one of its pins with a DHT22.

#include <Wire.h>
#include "Adafruit_MCP23017.h"
#include <DHT.h>

Adafruit_MCP23017 mcp;

#define dhtPin 11//pin on MCP23017

#define DHTTYPE DHT22
DHT dht(dhtPin, DHTTYPE); //this way it will go to Unos pin

void setup() {


void loop() {
  float h = dht.readHumidity();


With this setup, DHT will check Unos pin, not MCP.
Thanks in advance.

You'd have to rewrite the DHT library. That is, even if it's possible to maintain the I/O timing required by DHT while doing it over I2C. I have my doubts that it is, but you could try.

The other words, I can use this chip to turn LEDs, relays, etc. But not for sensors? No matter it is an IO expander?

It can not be done with the DHT library as written. You'll need to do your own research into the device's timing requirements to determine if it can be done at all. Start with the DHT datasheet.

You'd need the MCP23017 to act as a pass-thru device for the digital datastream from the DHT.
I don't think it was intended to work that way.

Any suggested hardware for such tasks? To act as expander?