Connecting the Adafruit AM2302 sensor to the PiMuxClock

My notes on how I got working the Adafruit AM2302 temperature-humidity sensor with the PiMuxClock on a Raspberry Pi

Posted on August 03, 2015

WARNING: Please note that this article was published a long time ago. The information contained might be outdated.

WARNING: Please note that this article describes my experience and the results you might get reproducing what I did will surely be different. Please understand that I am not responsible for the results you might get reproducing what I did. If you choose to follow my notes and anything bad happens, don't blame me, you are responsible for what you do. In doubt, my advice is to go and read some news on https://news.google.com/.

Update 2020: Instead of the Adafruit sensor, you can also use the Grove temperature and humidity module. The Grove brand provides multiple interesting sensors and I'm thinking about expand this project to use an air quality and a dust sensor:
More Grove modules can be found on seeedstudio.com

These last days I've been doing some experiments with a couple Raspberry Pi peripherals: the PiMuxClock and the AM2302 (wired DHT22) temperature-humidity sensor (I use a slighly different version but it's i.

Hardware

The version of the PiMuxClock I'm using is the "Enhanced" version. It has a built-in DS18B20 temperature sensor, a connector for a real time clock, and some extra GPIO connectors. The problem with the temperature sensor is that it's located in a hot place, where the temperature is always higher than the room temperature.

PiMuxClock temperature sensor PiMuxClock temperature sensor

The solution to the temperature monitoring problem the is the Adafruit AM2302. This device has pretty long wires so it can be placed far from the Raspberry Pi, and provides also a humidity sensor.

Adafruit AM2302 Adafruit AM2302
The Adafruit AM2302 (wired DHT22) temperature-humidity sensor

I found a good tutorial on how to setup the Adafruit AM3202 on Instructables. On step six, the post describes how the WiringPi library maps the GPIO connectors of the Raspberry Pi.

WiringPi GPIO mapping schema WiringPi GPIO mapping schema
WiringPi GPIO mapping schema from Instructables

This mapping schema is very important because, rather than connecting the Adafruit AM3202 directly to the GPIO pins of the Raspberry Pi, I used the extra GPIO connectors located on the PiMuxClock.

The Enhanced PiMuxClock provides 6 extra GPIO connectors (refer to the PiMuxClock pdf manual on pages 18 and 19). Merging the information available on Instructables with the ones from the pdf manual, I got the following summary:

Pin on the PiMuxClockFunction definitionGPIO Number (BCM)GPIO Number (Physical)WiringPi Pin NumberAdafruit AM2302 Cable
1 (top)GroundBlack
2+5 VoltsRed
3gp1414815-
4gp15151016
5gp2424185-
6 (bottom)gp2525226Yellow
Detail of the Adafruit AM2302 connected to the PiMuxClock extra GPIO Detail of the Adafruit AM2302 connected to the PiMuxClock extra GPIO
Detail of the Adafruit AM2302 connected to the PiMuxClock extra GPIO
Detail of the Adafruit AM2302 connected to the Raspberry Pi Detail of the Adafruit AM2302 connected to the Raspberry Pi
Detail of the Adafruit AM2302 connected to the Raspberry Pi

Software

As described on the Instructable website, I used the wiringPi GPIO Interface library. I followed the inscructions on how to download and compile the library:

git clone git://git.drogon.net/wiringPi
cd wiringPi
./build

In the examples directory there are some demo files. I used the rht03.c file and on line 30 I had to change the RHT03_PIN constant value from zero to six.

#define RHT03_PIN 6

Why six? Because the last pin on the PiMuxClock, the one at the bottom, having physical GPIO number 22, is pin number 6 for the WiringPi library.

After changing the rht03.c code, I compiled the rht03 executable:

make rht03

Running ./rht03 I was able to get the first temperature and humidity values:

Temp:  31.2, RH:  53.9%
Temp:  31.9, RH:  51.5%
Temp:  31.8, RH:  51.4%

Final notes

I'm still experimenting with the PiMuxClock and I'm very pleased with the device. I've added a real time clock and changed the muxprotemp example to show hour, temperature and humidiy. This is what it looks like today:

Since I'm not really good with Python, I'll experiment with the PHP implementation of the WiringPi library, not to drive the screen leds, but to read the values of temperature and humitidy and send the data to initialstate.com.

During my researches I read a lot of posts and guides on this topic. The best ones are listed below: