# Adafruit AHT20 Temperature & Humidity Sensor

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/139/087/medium800/temperature___humidity_a.png?1755549776 Rec C of the board, shown above, has a small trace in the upper left for disabling the "on" LED. Revisions A and B do not have this feature.)

The AHT20 is a nice but inexpensive temperature and humidity sensor&nbsp;[from the same folks that brought us the DHT22](https://www.adafruit.com/product/385). You can take sensor readings as often as you like, and it uses standard I2C so its super easy to use with any Arduino or Linux/Raspberry Pi board.  
  
This sensor has a typical accuracy of +- 2% relative humidity, and +-0.3 °C. There is only one I2C address so its not a good option when you need multiple humidity sensors.

![](https://cdn-learn.adafruit.com/assets/assets/000/139/088/medium800/temperature___humidity_b.png?1755549598)

As with all Adafruit breakouts, we've done the work to make this handy temperature-and-humidity super easy to use. We've put it on a breakout board with the required support circuitry and connectors to make it easy to work with and is now a trend we've added&nbsp;[SparkFun Qwiic](https://www.sparkfun.com/qwiic)&nbsp;compatible&nbsp;[**STEMMA QT**](https://learn.adafruit.com/introducing-adafruit-stemma-qt)&nbsp;JST SH connectors that allow you to get going&nbsp; **without needing to solder.** &nbsp;Just use a&nbsp;[STEMMA QT adapter cable](https://www.adafruit.com/product/4209), plug it into your favorite microcontroller or Blinka supported SBC and you're ready to rock!

![](https://cdn-learn.adafruit.com/assets/assets/000/091/687/medium800/temperature___humidity_AHT20_-_prod_P4566FrontHeader.jpg?1755549790 Rev B does not have the small jumper on the front for disabling the "on" LED.)

# Adafruit AHT20 Temperature & Humidity Sensor

## Pinouts

![](https://cdn-learn.adafruit.com/assets/assets/000/091/688/medium800/temperature___humidity_AHT20_-pinouts.jpg?1755549830 Rev B board with no jumper to disable the "on" LED)

The default I2C address is **0x38**. It cannot be changed.

# Power Pins

The sensor on the breakout requires between a 2.7V and 5.5V, and can be easily used with most microcontrollers from an Arduino to a Feather or something else.

- **VIN** - this is the power pin.&nbsp; To power the board, give it the same power as the logic level of your microcontroller - e.g. for a 5V micro like Arduino, use 5V
- **GND** - common ground for power and logic

# I2C Logic Pins

- **SCL** - I2C clock pin, connect to your microcontrollers I2C clock line. The logic level is the same as **VIN** and it has a 10K pullup already on it.
- **SDA** - I2C data pin, connect to your microcontrollers I2C data line. The logic level is the same as **VIN**. and it has a 10K pullup already on it.
- **[STEMMA QT](https://learn.adafruit.com/introducing-adafruit-stemma-qt)&nbsp;-** These connectors allow you to connect to dev boards with **STEMMA QT** connectors or to other things with&nbsp;[various associated accessories](https://www.adafruit.com/?q=JST%20SH%204)

## The "on" LED

There is a small LED next to the left STEMMA QT connector for telling when the breakout is on. On Rev A and B boards (denoted in a circled letter in the center back of the board). this LED cannot be disabled (unless the user removes or covers up the LED).

Rev C, below, has a small jumper near the LED. Uncut, the LED is on when the board is on. If the LED is not wanted, cut the small trace between the gold pads to completely disable the LED. To reenable, solder bridge the two gold pads.

![](https://cdn-learn.adafruit.com/assets/assets/000/139/089/medium800/temperature___humidity_a.png?1755550057)

# Adafruit AHT20 Temperature & Humidity Sensor

## Arduino

## Wiring

Connecting the AHT20 to your Feather or Arduino is easy:

- If you are running a Feather (3.3V), connect&nbsp; **Feather**  **3V** to **board**  **VIN**
- If you are running a 5V Arduino (Uno, etc.), connect **Arduino**  **5V** to&nbsp; **board**  **VIN**
- Connect **Feather or Arduino**  **GND** to **board**  **GND**
- Connect **Feather or Arduino**  **SCL** to **board SCL**
- Connect **Feather or Arduino**  **SDA** to **board SDA**

![temperature___humidity_AHT20_Arduino_breadboard_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/091/729/medium640/temperature___humidity_AHT20_Arduino_breadboard_bb.jpg?1591206261)

![temperature___humidity_AHT20_Arduino_STEMMA_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/091/730/medium640/temperature___humidity_AHT20_Arduino_STEMMA_bb.jpg?1591206288)

The final results should resemble the illustration above, showing an Adafruit Metro development board.

# Installation

You can install the **Adafruit AHTx0 Library** for Arduino using the Library Manager in the Arduino IDE:

![](https://cdn-learn.adafruit.com/assets/assets/000/091/731/medium800/temperature___humidity_Arduino_Manage_Libraries.png?1591206795)

Click the&nbsp; **Manage Libraries ...** menu item, search for **Adafruit AHTx0** ,&nbsp;and select the&nbsp; **Adafruit AHTx0** library:

![](https://cdn-learn.adafruit.com/assets/assets/000/091/732/medium800/temperature___humidity_Arduino_AHTx0_lib_install.png?1591206980)

Then follow the same process for the **Adafruit BusIO** library.

![](https://cdn-learn.adafruit.com/assets/assets/000/091/733/medium800/temperature___humidity_Arduino_BusIO_Lib_Install.png?1591207019)

# Load Example

Open up&nbsp; **File -\> Examples -\> Adafruit AHTx0**  **-\>&nbsp;adafruit\_aht\_test** and upload to your Arduino wired up to the sensor.

Upload the sketch to your board and open up the Serial Monitor ( **Tools-\>Serial Monitor** ). You should see the the values for temperature and humidity.

# Example Code

The following example code is part of the standard library, but illustrates how you can retrieve sensor data from the AHT20 for the temperature and humidity values:

https://github.com/adafruit/Adafruit_AHTX0/blob/master/examples/adafruit_aht_test/adafruit_aht_test.ino

You should get something resembling the following output when you open the Serial Monitor at 115200 baud:

![](https://cdn-learn.adafruit.com/assets/assets/000/091/735/medium800/temperature___humidity_AHT20_Arduino_serial_output.png?1591207535)

# Adafruit AHT20 Temperature & Humidity Sensor

## Arduino Docs

# Adafruit AHT20 Temperature & Humidity Sensor

## Python & CircuitPython

It's easy to use the AHT20 sensor with CircuitPython and the [Adafruit CircuitPython AHT20](https://github.com/adafruit/Adafruit_CircuitPython_AHTx0) module.&nbsp; This module allows you to easily write Python code that reads the temperature and humidity from the sensor.

You can use this sensor with any CircuitPython microcontroller board or with a computer that has GPIO and Python&nbsp;[thanks to Adafruit\_Blinka, our CircuitPython-for-Python compatibility library](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).

## CircuitPython Microcontroller Wiring

First wire up a AHT20 to your board exactly as follows. Here is an example of the AHT20 wired to a Feather using I2C:

- **Board 3V** &nbsp;to&nbsp; **sensor VIN**
- **Board GND** &nbsp;to&nbsp; **sensor GND**
- **Board SCL** &nbsp;to&nbsp; **sensor SCL**
- **Board SDA** &nbsp;to&nbsp; **sensor SDA**

![temperature___humidity_AHT20_Feather_M4_breadboard_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/091/725/medium640/temperature___humidity_AHT20_Feather_M4_breadboard_bb.jpg?1591206110)

## Python Computer Wiring

Since there's&nbsp;_dozens_&nbsp;of Linux computers/boards you can use we will show wiring for Raspberry Pi. For other platforms,&nbsp;[please visit the guide for CircuitPython on Linux to see whether your platform is supported](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).&nbsp;

Here's the Raspberry Pi wired with I2C:

- **Pi 3V3** &nbsp;to&nbsp; **sensor VIN**
- **Pi GND** &nbsp;to&nbsp; **sensor GND**
- **Pi SCL** &nbsp;to&nbsp; **sensor SCL**
- **Pi SDA** &nbsp;to&nbsp; **sensor SDA**

![temperature___humidity_AHT20_raspi_breadboard_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/091/727/medium640/temperature___humidity_AHT20_raspi_breadboard_bb.jpg?1591206171)

![temperature___humidity_AHT20_raspi_STEMMA_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/091/728/medium640/temperature___humidity_AHT20_raspi_STEMMA_bb.jpg?1591206191)

## CircuitPython Installation of AHT20 Library

You'll need to install the [Adafruit CircuitPython AHT20](https://github.com/adafruit/Adafruit_CircuitPython_AHTx0) library on your CircuitPython board.

First make sure you are running the&nbsp;[latest version of Adafruit CircuitPython](https://learn.adafruit.com/welcome-to-circuitpython/installing-circuitpython)&nbsp;for your board.

Next you'll need to install the necessary libraries&nbsp;to use the hardware--carefully follow the steps to find and install these libraries from&nbsp;[Adafruit's CircuitPython library bundle](https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases).&nbsp; Our CircuitPython starter guide has [a great page on how to install the library bundle](https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries).

Copy the following files from the bundle to the **lib** folder on your **CIRCUITPY** drive:

- **adafruit\_ahtx0.mpy**
- **adafruit\_bus\_device**

Before continuing make sure your board's **lib** folder or root filesystem has the&nbsp; **adafruit\_ahtx0.mpy,** and **adafruit\_bus\_device** file and folder copied over.

Next&nbsp;[connect to the board's serial REPL&nbsp;](https://learn.adafruit.com/welcome-to-circuitpython/the-repl)so you are at the CircuitPython&nbsp; **\>\>\>** &nbsp;prompt.

## Python Installation of AHT20 Library

You'll need to install the **Adafruit\_Blinka** library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3.&nbsp;[Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux)!

Once that's done, from your command line run the following command:

- `pip3 install adafruit-circuitpython-ahtx0`

If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

## CircuitPython & Python Usage

To demonstrate the usage of the sensor we'll initialize it and read the temperature and humidity from the board's Python REPL.

Run the following code to import the necessary modules and initialize the I2C connection with the sensor:

```python
import board
import adafruit_ahtx0

sensor = adafruit_ahtx0.AHTx0(board.I2C())
```

Now you're ready to read values from the sensor using these properties:

- **temperature** - The temperature in Celsius.
- **relative\_humidity** - The relative humidity in percent.

For example to print temperature and relative humidity values:

```python
print("\nTemperature: %0.1f C" % sensor.temperature)
print("Humidity: %0.1f %%" % sensor.relative_humidity)
```

That's all there is to using the AHT20 sensor with CircuitPython!

# Full Example Code
https://github.com/adafruit/Adafruit_CircuitPython_AHTx0/blob/main/examples/ahtx0_simpletest.py

# Adafruit AHT20 Temperature & Humidity Sensor

## Python Docs

# Adafruit AHT20 Temperature & Humidity Sensor

## WipperSnapper

![](https://cdn-learn.adafruit.com/assets/assets/000/128/226/medium800/temperature___humidity_adafruit_products_01_DeviceList.png?1709153542)

## What is WipperSnapper

WipperSnapper is a firmware designed to turn any WiFi-capable board into an Internet-of-Things device without programming a single line of code. WipperSnapper connects to [Adafruit IO](https://io.adafruit.com/), a web&nbsp;platform designed ([by Adafruit!](https://www.adafruit.com/about)) to&nbsp;_display_,&nbsp;_respond_, and&nbsp;_interact_&nbsp;with your project's data.

Simply load the WipperSnapper firmware onto your board, add credentials, and plug it into power. Your board will automatically register itself with your Adafruit IO account.

From there, you can add&nbsp;_components_&nbsp;to your board such as buttons, switches, potentiometers, sensors, and more! Components are&nbsp;_dynamically&nbsp;_added to hardware, so you can&nbsp;immediately start interacting, logging, and streaming the data your projects produce without writing code.

If you've never used WipperSnapper, click below to read through the quick start guide before continuing.

[Quickstart: Adafruit IO WipperSnapper](https://learn.adafruit.com/quickstart-adafruit-io-wippersnapper)
## Wiring
First, wire up an AHT20 to your board exactly as follows. Here is an example of the AHT20 wired to an [Adafruit ESP32 Feather V2](https://www.adafruit.com/product/5400) using I2C [with a STEMMA QT cable (no soldering required)](https://www.adafruit.com/product/4210)

- **Board 3V** &nbsp;to&nbsp;**sensor VIN (red wire on STEMMA QT)**  
- **Board GND** &nbsp;to&nbsp;**sensor GND (black wire on STEMMA QT)**  
- **Board SCL** &nbsp;to&nbsp;**sensor SCL (yellow wire on STEMMA QT)**  
- **Board SDA** &nbsp;to&nbsp;**sensor SDA (blue wire on STEMMA QT)**

![temperature___humidity_aht-stemma-only_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/109/704/medium640/temperature___humidity_aht-stemma-only_bb.png?1647366732)

![temperature___humidity_aht-bb-only_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/109/705/medium640/temperature___humidity_aht-bb-only_bb.png?1647366830)

## Usage

Connect your board to Adafruit IO Wippersnapper and **[navigate to the WipperSnapper board list](https://io.adafruit.com/wippersnapper).**

On this page, **select the WipperSnapper board you're using** to be brought to the board's interface page.

![](https://cdn-learn.adafruit.com/assets/assets/000/117/379/medium800/temperature___humidity_ksnip_20230106-140345.png?1673034661)

If you do not see your board listed here - you need [to connect your board to Adafruit IO](https://learn.adafruit.com/quickstart-adafruit-io-wippersnapper) first.

On the device page, quickly&nbsp; **check that you're running the latest version of the WipperSnapper firmware**.

The device tile on the left indicates the version number of the firmware running on the connected board.

- **If the firmware version is green with a checkmark -** &nbsp;continue with this guide.
- **If the firmware version is red with an "X" -** &nbsp;[update to the latest WipperSnapper firmware](https://learn.adafruit.com/quickstart-adafruit-io-wippersnapper)&nbsp;on your board before continuing.

![temperature___humidity_adafruit_products_04_LatestVersion.png](https://cdn-learn.adafruit.com/assets/assets/000/128/236/medium640/temperature___humidity_adafruit_products_04_LatestVersion.png?1709158251)

![temperature___humidity_adafruit_products_04_UpdateRequired.png](https://cdn-learn.adafruit.com/assets/assets/000/128/237/medium640/temperature___humidity_adafruit_products_04_UpdateRequired.png?1709158292)

Next, make sure the sensor is plugged into your board and click the **&nbsp;I2C Scan&nbsp;** button.

![](https://cdn-learn.adafruit.com/assets/assets/000/113/177/medium800/sensor_page_crop_scan.png?1657724520)

You should see the AHT20's default I2C address of&nbsp;`0x38`&nbsp;pop-up in the I2C scan list.

![](https://cdn-learn.adafruit.com/assets/assets/000/109/771/medium800/temperature___humidity_i2c-scan-aht20-complete.png?1647465261)

###  I don't see the sensor's I2C address listed! 


First, double-check the connection and/or wiring between the sensor and the board.

Then, reset the board and let it re-connect to Adafruit IO WipperSnapper.

With the sensor detected in an I2C scan, you're ready to add the sensor to your board.

**Click the New Component button or the + button** to bring up the component picker.

![](https://cdn-learn.adafruit.com/assets/assets/000/127/931/medium800/sensor_page_temperature___humidity_06_AddComponent.png?1708631009)

Adafruit IO supports a large amount of components. To quickly find your sensor, type `AHT20`&nbsp;into the search bar, then select the&nbsp; **AHT20** &nbsp;component.

![](https://cdn-learn.adafruit.com/assets/assets/000/127/932/medium800/temperature___humidity_kMGYRZvMQT.png?1708631425)

On the component configuration page, the **AHT20's** sensor address should be listed along with the sensor's settings.

The&nbsp; **Send Every** &nbsp;option is specific to each sensor's measurements. This option will tell the Feather how often it should read from the **AHT20** &nbsp;sensor and send the data to Adafruit IO. Measurements can range from every 30 seconds to every 24 hours.

For this example, set the&nbsp; **Send Every&nbsp;** interval to every 30 seconds. When you've configured your AHT20 sensor, click&nbsp; **Create Component**.

![](https://cdn-learn.adafruit.com/assets/assets/000/127/933/medium800/temperature___humidity_Screenshot_2024-02-22_203013.png?1708633906)

Your device interface should now show the sensor components you created. After the interval you configured elapses, WipperSnapper will automatically read values from the sensor(s) and send them to Adafruit IO.

![](https://cdn-learn.adafruit.com/assets/assets/000/127/935/medium800/temperature___humidity_Screenshot_2024-02-22_203353.png?1708634046)

To view the data that has been logged from the sensor, click on the graph next to the sensor name.

![](https://cdn-learn.adafruit.com/assets/assets/000/127/936/medium800/temperature___humidity_LdlHveH4D5.png?1708634136)

Here you can see the feed history and edit things about the feed such as the name, privacy, webhooks associated with the feed and more. If you want to learn more about how feeds work, [check out this page](https://learn.adafruit.com/all-the-internet-of-things-episode-four-adafruit-io/advanced-feeds).

![](https://cdn-learn.adafruit.com/assets/assets/000/127/937/medium800/temperature___humidity_lOoarpdMH7.png?1708634200)

# Adafruit AHT20 Temperature & Humidity Sensor

## Downloads

## Files

- [AHT20 Datasheet](https://cdn-learn.adafruit.com/assets/assets/000/123/394/original/Data_Sheet_AHT20.pdf?1691532479)
- [Fritzing object in the Adafruit Fritzing Library](https://github.com/adafruit/Fritzing-Library/blob/master/parts/Adafruit%20AHT20%20Temperature%20and%20Humidity%20Sensor.fzpz)
- [EagleCAD PCB files on GitHub](https://github.com/adafruit/Adafruit-AHT20-PCB)

## Schematic
![](https://cdn-learn.adafruit.com/assets/assets/000/091/674/medium800/temperature___humidity_AHT20_sch.png?1591047851)

## Fab Print
![](https://cdn-learn.adafruit.com/assets/assets/000/091/675/medium800/temperature___humidity_AHT20_fab_print.png?1591047859)


## Primary Products

### Adafruit AHT20 - Temperature & Humidity Sensor Breakout Board

[Adafruit AHT20 - Temperature & Humidity Sensor Breakout Board](https://www.adafruit.com/product/4566)
The AHT20 is a nice but inexpensive temperature and humidity sensor [from the same folks that brought us the DHT22](https://www.adafruit.com/product/385). You can take sensor readings as often as you like, and it uses standard I2C so its super easy to use with any Arduino or...

In Stock
[Buy Now](https://www.adafruit.com/product/4566)
[Related Guides to the Product](https://learn.adafruit.com/products/4566/guides)

## Related Guides

- [Modern Replacements for DHT11 and DHT22 Sensors](https://learn.adafruit.com/modern-replacements-for-dht11-dht22-sensors.md)
- [Adafruit LTC4316 I2C Address Translator](https://learn.adafruit.com/adafruit-ltc4316-i2c-address-translator.md)
- [Quick Start: Pico W / 2W with WipperSnapper](https://learn.adafruit.com/quick-start-the-pico-w-with-wippersnapper.md)
- [Pico W PiCowBell Case](https://learn.adafruit.com/pico-w-picowbell-case.md)
- [Adafruit RP2040 Prop-Maker Feather](https://learn.adafruit.com/adafruit-rp2040-prop-maker-feather.md)
- [No-Code IoT Humidity and Temperature Sensor with Adafruit IO WipperSnapper](https://learn.adafruit.com/no-code-humidity-and-temp-tracker.md)
- [Adafruit CH552 QT Py](https://learn.adafruit.com/adafruit-ch552-qt-py.md)
- [Adafruit Pi Stemma QT Breakout](https://learn.adafruit.com/adafruit-pi-stemma-qt-breakout.md)
- [Quick-Start the Pico W WiFi with CircuitPython](https://learn.adafruit.com/pico-w-wifi-with-circuitpython.md)
- [Adafruit Fruit Jam](https://learn.adafruit.com/adafruit-fruit-jam.md)
- [IoT Food Scale with Azure and CircuitPython](https://learn.adafruit.com/iot-food-scale-with-azure-and-circuitpython.md)
- [Infinity Mirror Collar](https://learn.adafruit.com/infinity-mirror-collar.md)
- [Adafruit MCP9601 I2C Thermocouple Amplifier](https://learn.adafruit.com/adafruit-mcp9601.md)
- [Program CircuitPython USB Devices with iPhone & iPad](https://learn.adafruit.com/use-circuitpython-devices-with-iphone-ipad.md)
- [PyPortal Winamp MP3 Player](https://learn.adafruit.com/pyportal-winamp-mp3-player.md)
