Home Circuitpython Adafruit Feather M0 and DHT11 humidity & temperature sensor circuitpython example

Adafruit Feather M0 and DHT11 humidity & temperature sensor circuitpython example

by shedboy71

In this example we connect a DHT11 humidity & temperature sensor to an Adafruit Feather M0 running Circuitpython

First lets look at some information about the chip from the manufacturer

DHT11 output calibrated digital signal. It utilizes exclusive digital-signal-collecting-technique and humidity sensing technology, assuring its reliability and stability.

Its sensing elements is connected with 8-bit single-chip computer.Every sensor of this model is temperature compensated and calibrated in accurate calibration chamber and the calibration-coefficient is saved in OTP memory.

Small size & low consumption & long transmission distance(20m) enable DHT11 to be suited in all kinds of harsh application occasions. Single-row packaged with four pins, making the connection very convenient.


Full range temperature compensated
Relative humidity and temperature measurement
Calibrated digital signal
Outstanding long-term stability
Extra components not needed
Long transmission distance
Low power consumption


Model : DHT11
Power supply : 3-5.5V DC
Output signal : digital signal via single-bus
Sensing element : Polymer resistor
Measuring range humidity 20-90%RH temperature 0 – 50 Celsius
Accuracy : humidity +-4%RH(Max +-5%RH); temperature +-2.0Celsius
Resolution or sensitivity humidity : 1%RH temperature 0.1 Celsius
Repeatability : humidity +-1%RH; temperature +-1Celsius
Humidity hysteresis : +-1%RH
Long-term Stability : +-0.5%RH/year
Sensing period : Average: 2s

This is an example of the sensor/module, there are many different options.

Parts Required


Name Link
Adafruit Feather M0 Express Adafruit (PID 3403) Feather M0 Express – Designed for CircuitPython – ATSAMD21 Cortex M0
DHT11 DHT11 Temperature and Relative Humidity Sensor Module
Connecting cables Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire



This is not the exact same module but the wiring is the same

feather and DHT11 layout

feather and DHT11 layout

Code Example

I used Mu for development

The following is based on a library , I copied the adafruit_dht library for this device to the lib folder on my Feather M0 Express – https://circuitpython.org/libraries

This is the basic example which comes with the library – a little bit tweaked

[codesyntax lang=”python”]

import time
import adafruit_dht
import board
dht = adafruit_dht.DHT11(board.D6)
while True:
        temperature = dht.temperature
        humidity = dht.humidity
        # Print what we got to the REPL
        print("Temp: {:.1f} *C \t Humidity: {}%".format(temperature, humidity))
    except RuntimeError as e:
        # Reading doesn't always work! Just print error and we'll try again
        print("Reading from DHT failure: ", e.args)



Here is what I saw in Mu REPL window

Temp: 31.0 *C Humidity: 53%
Temp: 31.0 *C Humidity: 61%
Temp: 31.0 *C Humidity: 61%
Temp: 32.0 *C Humidity: 64%
Temp: 32.0 *C Humidity: 64%



You may also like

Leave a Comment