Home Circuitpython Adafruit Feather M0 and AHT20 Temperature & Humidity Sensor circuitpython example

Adafruit Feather M0 and AHT20 Temperature & Humidity Sensor circuitpython example

by shedboy71

In this article we connect a AHT20 Temperature & Humidity Sensor to an Adafruit Feather M0 running Circuitpython

Sensor Information

AHT20, as a new generation of temperature and humidity sensors, has established a new standard in size and intelligence. It is embedded in a double row flat no-lead package suitable for reflow soldering, with a bottom of 3 x 3 mm and a height of 1.0 mm.

The sensor outputs calibrated digital signals in standard IAHT20, as a new generation of temperature and humidity sensors, has established a new standard in size and intelligence.

It is embedded in a double row flat no-lead package suitable for reflow soldering, with a bottom of 3 x 3 mm and a height of 1.0 mm.

The sensor outputs calibrated digital signals in standard I2C format.AHT20 is equipped with a newly designed ASIC chip, an improved MEMS semiconductor capacitive humidity sensing element and a standard on-chip temperature sensing element.

Supply voltage DC : 2.0 – 5.5V
Measuring range (humidity) 0 ~ 100% RH
Measuring range (temperature) -40 ~ + 85 ℃
Humidity accuracy ± 2 % RH ( 25 ℃ )
Temperature accuracy ± 0.3 ℃
Resolution temperature: 0.01℃ Humidity: 0.024%RH
Response time temperature: 5s humidity: 8s 1/e (63%)
Output signal I2C signal

This is the sensor that I bought

 

Parts Required

The sensor you can pick up in the $6 price range – you can connect to the sensor using a standard header the classic dupont style jumper wire.

I used a Qwiic cable – since a few sensors seem to use these but this is optional

Name Link
Adafruit Feather M0 Express Amazon link

Ebay link

AHT20 AHT20 Temperature and Humidity Sensor Module High-precision Humidity Sensor

https://shop.pimoroni.com/products/adafruit-sensirion-sht40-temperature-humidity-sensor-stemma-qt-qwiic

Connecting cables Aliexpress product link

Lysee 3D Printer Parts & Accessories – AHT20 Temperature and Humidity Sensor Module DHT11 Upgrade I2C XD Humidity Sensor Probe – (Color: Green)

Ebay link

 

Schematic/Connection

I used the Adafruit AHT20 sensor and in this case used the Stemma connection

For the STEMMA QT cables, it uses the Qwiic convention:

Black for GND
Red for V+
Blue for SDA
Yellow for SCL

So color coded for ease of use, this layout shows a connection to the module

feather and aht20

feather and aht20

Code Example

I used Mu for development

The following is based on a library , I copied the adafruit_sht4x.mpy 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

[codesyntax lang=”python”]

"""
Basic `AHTx0` example test
"""

import time
import board
import adafruit_ahtx0

# Create sensor object, communicating over the board's default I2C bus
i2c = board.I2C()  # uses board.SCL and board.SDA
sensor = adafruit_ahtx0.AHTx0(i2c)

while True:
    print("\nTemperature: %0.1f C" % sensor.temperature)
    print("Humidity: %0.1f %%" % sensor.relative_humidity)
    time.sleep(2)

[/codesyntax]

Output

Here is what I saw in Mu REPL window

Temperature: 26.4 C
Humidity: 41.6 %

Temperature: 26.0 C
Humidity: 40.3 %

Temperature: 27.7 C
Humidity: 40.2 %

Temperature: 27.9 C
Humidity: 41.0 %

Temperature: 26.8 C
Humidity: 39.2 %

Links

Product download pdf

 

 

You may also like

Leave a Comment