title: How to get a DHT22/AM2302 sensor to work with MCP23017 I2C Port Expander
body: <p>I am building out a monitoring and automation system for my various greenhouses in the garden. Due to the number of devices that need to be controlled and monitored rather than purchasing additional Raspberry PIs I decided to go with a GPIO port expander and make use of the existing Raspberry PI hardware.</p>
  
  <p>I have however managed to hit a "wall" when it comes to reading the DHT22 Temperature and Humidity sensor when I connect it up via the MCP23017. I know I have the MCP23017 connected correctly as I am able make LEDs flash and relay switches turn on and off. </p>
  
  <p>None of these require reading data from the device connected though and this where I am running into the problem and would really appreciate any help or advice.</p>
  
  <p>I am running a Revison 2 Raspberry PI A, sudo i2cdetect -y 1 shows MCP23017 connected to 0X20.</p>
  
  <p>I am using Python 2.7 for the coding, using the Adafruit_DHT module and for addressing the MCP23017 I am using the wiringpi2 module. Although I am open to other suggestions here with regards to using wiringpi2.</p>
  
  <p>The Adafruit_DHT uses the following syntax to connect to and retrieve information from the sensor:</p>
  
  <pre><code>import Adafruit_DHT    
  sensor = Adafruit_DHT.DHT22
  pin = 7   
  humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
  </code></pre>
  
  <p>The above works fine when connecting directly to one of the "standard" GPIO ports. However I have not worked out how to address the additional new GPIO ports in this same manner i.e.</p>
  
  <p>I have tried the following with no success:</p>
  
  <pre><code>import Adafruit_DHT
  import wiringpi2
  wiringpi2.wiringPiSetupGpio()
  wiringpi2.mcp23017Setup(65,0x20)
  
  for n in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16):
    humidity, temperature = Adafruit_DHT.read_retry(sensor22, wiringpi2.digitalRead(n+64))
    print n, humidity, temperature
  </code></pre>
  
  <p>So the above cycles through each new port, however I don't get any results back, as I say if I connect the device directly the GPIOs on the PI is works fine. I suspect the issue with how I am telling the driver which PIN to use. </p>
  
  <p>I would really appreciate any advice or help on this issue. As I said I am open to other ideas on how to use this DHT22 with the MCP23017.</p>