├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── githubci.yml ├── .gitignore ├── Adafruit_AHTX0.cpp ├── Adafruit_AHTX0.h ├── README.md ├── assets └── board.png ├── code-of-conduct.md ├── examples ├── adafruit_aht_test │ └── adafruit_aht_test.ino ├── adafruit_aht_unifiedsensors │ └── adafruit_aht_unifiedsensors.ino └── aht20_oleddemo │ └── aht20_oleddemo.ino ├── library.properties └── license.txt /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for opening an issue on an Adafruit Arduino library repository. To 2 | improve the speed of resolution please review the following guidelines and 3 | common troubleshooting steps below before creating the issue: 4 | 5 | - **Do not use GitHub issues for troubleshooting projects and issues.** Instead use 6 | the forums at http://forums.adafruit.com to ask questions and troubleshoot why 7 | something isn't working as expected. In many cases the problem is a common issue 8 | that you will more quickly receive help from the forum community. GitHub issues 9 | are meant for known defects in the code. If you don't know if there is a defect 10 | in the code then start with troubleshooting on the forum first. 11 | 12 | - **If following a tutorial or guide be sure you didn't miss a step.** Carefully 13 | check all of the steps and commands to run have been followed. Consult the 14 | forum if you're unsure or have questions about steps in a guide/tutorial. 15 | 16 | - **For Arduino projects check these very common issues to ensure they don't apply**: 17 | 18 | - For uploading sketches or communicating with the board make sure you're using 19 | a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes 20 | very hard to tell the difference between a data and charge cable! Try using the 21 | cable with other devices or swapping to another cable to confirm it is not 22 | the problem. 23 | 24 | - **Be sure you are supplying adequate power to the board.** Check the specs of 25 | your board and plug in an external power supply. In many cases just 26 | plugging a board into your computer is not enough to power it and other 27 | peripherals. 28 | 29 | - **Double check all soldering joints and connections.** Flakey connections 30 | cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints. 31 | 32 | - **Ensure you are using an official Arduino or Adafruit board.** We can't 33 | guarantee a clone board will have the same functionality and work as expected 34 | with this code and don't support them. 35 | 36 | If you're sure this issue is a defect in the code and checked the steps above 37 | please fill in the following fields to provide enough troubleshooting information. 38 | You may delete the guideline and text above to just leave the following details: 39 | 40 | - Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE** 41 | 42 | - Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO 43 | VERSION HERE** 44 | 45 | - List the steps to reproduce the problem below (if possible attach a sketch or 46 | copy the sketch code in too): **LIST REPRO STEPS BELOW** 47 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for creating a pull request to contribute to Adafruit's GitHub code! 2 | Before you open the request please review the following guidelines and tips to 3 | help it be more easily integrated: 4 | 5 | - **Describe the scope of your change--i.e. what the change does and what parts 6 | of the code were modified.** This will help us understand any risks of integrating 7 | the code. 8 | 9 | - **Describe any known limitations with your change.** For example if the change 10 | doesn't apply to a supported platform of the library please mention it. 11 | 12 | - **Please run any tests or examples that can exercise your modified code.** We 13 | strive to not break users of the code and running tests/examples helps with this 14 | process. 15 | 16 | Thank you again for contributing! We will try to test and integrate the change 17 | as soon as we can, but be aware we have many GitHub repositories to manage and 18 | can't immediately respond to every request. There is no need to bump or check in 19 | on a pull request (it will clutter the discussion of the request). 20 | 21 | Also don't be worried if the request is closed or not integrated--sometimes the 22 | priorities of Adafruit's GitHub code (education, ease of use) might not match the 23 | priorities of the pull request. Don't fret, the open source community thrives on 24 | forks and GitHub makes it easy to keep your changes in a forked repo. 25 | 26 | After reviewing the guidelines above you can delete this text from the pull request. 27 | -------------------------------------------------------------------------------- /.github/workflows/githubci.yml: -------------------------------------------------------------------------------- 1 | name: Arduino Library CI 2 | 3 | on: [pull_request, push, repository_dispatch] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/setup-python@v4 11 | with: 12 | python-version: '3.x' 13 | - uses: actions/checkout@v3 14 | - uses: actions/checkout@v3 15 | with: 16 | repository: adafruit/ci-arduino 17 | path: ci 18 | 19 | - name: pre-install 20 | run: bash ci/actions_install.sh 21 | 22 | - name: test platforms 23 | run: python3 ci/build_platform.py main_platforms 24 | 25 | - name: clang 26 | run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r . 27 | 28 | - name: doxygen 29 | env: 30 | GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }} 31 | PRETTYNAME : "Adafruit AHT10 Library" 32 | run: bash ci/doxy_gen_and_deploy.sh 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | html/ 2 | Doxyfile 3 | .vscode/ 4 | -------------------------------------------------------------------------------- /Adafruit_AHTX0.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_AHTX0.cpp 3 | * 4 | * @mainpage Adafruit AHTX0 Humidity and Temperature Sensor library 5 | * 6 | * @section intro_sec Introduction 7 | * 8 | * I2C Driver for the Adafruit AHTX0 Humidity and Temperature Sensor 9 | * library 10 | * 11 | * This is a library for the Adafruit AHT20 breakout: 12 | * https://www.adafruit.com/product/4566 13 | * 14 | * Adafruit invests time and resources providing this open source code, 15 | * please support Adafruit and open-source hardware by purchasing products from 16 | * Adafruit! 17 | * 18 | * @section dependencies Dependencies 19 | * This library depends on the Adafruit BusIO library 20 | * 21 | * This library depends on the Adafruit Unified Sensor library 22 | * 23 | * @section author Author 24 | * 25 | * Limor Fried (Adafruit Industries) 26 | * 27 | * @section license License 28 | * 29 | * BSD (see license.txt) 30 | * 31 | * @section HISTORY 32 | * 33 | * v1.0 - First release 34 | */ 35 | 36 | #include "Arduino.h" 37 | 38 | #include "Adafruit_AHTX0.h" 39 | 40 | /*! 41 | * @brief Instantiates a new AHTX0 class 42 | */ 43 | Adafruit_AHTX0::Adafruit_AHTX0(void) {} 44 | 45 | Adafruit_AHTX0::~Adafruit_AHTX0(void) { 46 | if (temp_sensor) { 47 | delete temp_sensor; 48 | } 49 | if (humidity_sensor) { 50 | delete humidity_sensor; 51 | } 52 | } 53 | 54 | /*! 55 | * @brief Sets up the hardware and initializes I2C 56 | * @param wire 57 | * The Wire object to be used for I2C connections. 58 | * @param sensor_id 59 | * The unique ID to differentiate the sensors from others 60 | * @param i2c_address 61 | * The I2C address used to communicate with the sensor 62 | * @return True if initialization was successful, otherwise false. 63 | */ 64 | bool Adafruit_AHTX0::begin(TwoWire *wire, int32_t sensor_id, 65 | uint8_t i2c_address) { 66 | delay(20); // 20 ms to power up 67 | 68 | if (i2c_dev) { 69 | delete i2c_dev; // remove old interface 70 | } 71 | 72 | i2c_dev = new Adafruit_I2CDevice(i2c_address, wire); 73 | 74 | if (!i2c_dev->begin()) { 75 | return false; 76 | } 77 | 78 | uint8_t cmd[3]; 79 | 80 | cmd[0] = AHTX0_CMD_SOFTRESET; 81 | if (!i2c_dev->write(cmd, 1)) { 82 | return false; 83 | } 84 | delay(20); 85 | 86 | while (getStatus() & AHTX0_STATUS_BUSY) { 87 | delay(10); 88 | } 89 | 90 | cmd[0] = AHTX0_CMD_CALIBRATE; 91 | cmd[1] = 0x08; 92 | cmd[2] = 0x00; 93 | i2c_dev->write(cmd, 3); // may not 'succeed' on newer AHT20s 94 | 95 | while (getStatus() & AHTX0_STATUS_BUSY) { 96 | delay(10); 97 | } 98 | if (!(getStatus() & AHTX0_STATUS_CALIBRATED)) { 99 | return false; 100 | } 101 | 102 | delete humidity_sensor; 103 | delete temp_sensor; 104 | humidity_sensor = new Adafruit_AHTX0_Humidity(this); 105 | temp_sensor = new Adafruit_AHTX0_Temp(this); 106 | return true; 107 | } 108 | 109 | /** 110 | * @brief Gets the status (first byte) from AHT10/AHT20 111 | * 112 | * @returns 8 bits of status data, or 0xFF if failed 113 | */ 114 | uint8_t Adafruit_AHTX0::getStatus(void) { 115 | uint8_t ret; 116 | if (!i2c_dev->read(&ret, 1)) { 117 | return 0xFF; 118 | } 119 | return ret; 120 | } 121 | 122 | /**************************************************************************/ 123 | /*! 124 | @brief Gets the humidity sensor and temperature values as sensor events 125 | @param humidity Sensor event object that will be populated with humidity 126 | data 127 | @param temp Sensor event object that will be populated with temp data 128 | @returns true if the event data was read successfully 129 | */ 130 | /**************************************************************************/ 131 | bool Adafruit_AHTX0::getEvent(sensors_event_t *humidity, 132 | sensors_event_t *temp) { 133 | uint32_t t = millis(); 134 | 135 | // read the data and store it! 136 | uint8_t cmd[3] = {AHTX0_CMD_TRIGGER, 0x33, 0}; 137 | if (!i2c_dev->write(cmd, 3)) { 138 | return false; 139 | } 140 | 141 | while (getStatus() & AHTX0_STATUS_BUSY) { 142 | delay(10); 143 | } 144 | 145 | uint8_t data[6]; 146 | if (!i2c_dev->read(data, 6)) { 147 | return false; 148 | } 149 | uint32_t h = data[1]; 150 | h <<= 8; 151 | h |= data[2]; 152 | h <<= 4; 153 | h |= data[3] >> 4; 154 | _humidity = ((float)h * 100) / 0x100000; 155 | 156 | uint32_t tdata = data[3] & 0x0F; 157 | tdata <<= 8; 158 | tdata |= data[4]; 159 | tdata <<= 8; 160 | tdata |= data[5]; 161 | _temperature = ((float)tdata * 200 / 0x100000) - 50; 162 | 163 | // use helpers to fill in the events 164 | if (temp) 165 | fillTempEvent(temp, t); 166 | if (humidity) 167 | fillHumidityEvent(humidity, t); 168 | return true; 169 | } 170 | 171 | void Adafruit_AHTX0::fillTempEvent(sensors_event_t *temp, uint32_t timestamp) { 172 | memset(temp, 0, sizeof(sensors_event_t)); 173 | temp->version = sizeof(sensors_event_t); 174 | temp->sensor_id = _sensorid_temp; 175 | temp->type = SENSOR_TYPE_AMBIENT_TEMPERATURE; 176 | temp->timestamp = timestamp; 177 | temp->temperature = _temperature; 178 | } 179 | 180 | void Adafruit_AHTX0::fillHumidityEvent(sensors_event_t *humidity, 181 | uint32_t timestamp) { 182 | memset(humidity, 0, sizeof(sensors_event_t)); 183 | humidity->version = sizeof(sensors_event_t); 184 | humidity->sensor_id = _sensorid_humidity; 185 | humidity->type = SENSOR_TYPE_AMBIENT_TEMPERATURE; 186 | humidity->timestamp = timestamp; 187 | humidity->relative_humidity = _humidity; 188 | } 189 | 190 | /** 191 | * @brief Gets the Adafruit_Sensor object for the AHTx0's humidity sensor 192 | * 193 | * @return Adafruit_Sensor* 194 | */ 195 | Adafruit_Sensor *Adafruit_AHTX0::getHumiditySensor(void) { 196 | return humidity_sensor; 197 | } 198 | 199 | /** 200 | * @brief Gets the Adafruit_Sensor object for the AHTx0's humidity sensor 201 | * 202 | * @return Adafruit_Sensor* 203 | */ 204 | Adafruit_Sensor *Adafruit_AHTX0::getTemperatureSensor(void) { 205 | return temp_sensor; 206 | } 207 | /** 208 | * @brief Gets the sensor_t object describing the AHTx0's humidity sensor 209 | * 210 | * @param sensor The sensor_t object to be populated 211 | */ 212 | void Adafruit_AHTX0_Humidity::getSensor(sensor_t *sensor) { 213 | /* Clear the sensor_t object */ 214 | memset(sensor, 0, sizeof(sensor_t)); 215 | 216 | /* Insert the sensor name in the fixed length char array */ 217 | strncpy(sensor->name, "AHTx0_H", sizeof(sensor->name) - 1); 218 | sensor->name[sizeof(sensor->name) - 1] = 0; 219 | sensor->version = 1; 220 | sensor->sensor_id = _sensorID; 221 | sensor->type = SENSOR_TYPE_RELATIVE_HUMIDITY; 222 | sensor->min_delay = 0; 223 | sensor->min_value = 0; 224 | sensor->max_value = 100; 225 | sensor->resolution = 2; 226 | } 227 | /** 228 | @brief Gets the humidity as a standard sensor event 229 | @param event Sensor event object that will be populated 230 | @returns True 231 | */ 232 | bool Adafruit_AHTX0_Humidity::getEvent(sensors_event_t *event) { 233 | _theAHTX0->getEvent(event, NULL); 234 | 235 | return true; 236 | } 237 | /** 238 | * @brief Gets the sensor_t object describing the AHTx0's tenperature sensor 239 | * 240 | * @param sensor The sensor_t object to be populated 241 | */ 242 | void Adafruit_AHTX0_Temp::getSensor(sensor_t *sensor) { 243 | /* Clear the sensor_t object */ 244 | memset(sensor, 0, sizeof(sensor_t)); 245 | 246 | /* Insert the sensor name in the fixed length char array */ 247 | strncpy(sensor->name, "AHTx0_T", sizeof(sensor->name) - 1); 248 | sensor->name[sizeof(sensor->name) - 1] = 0; 249 | sensor->version = 1; 250 | sensor->sensor_id = _sensorID; 251 | sensor->type = SENSOR_TYPE_AMBIENT_TEMPERATURE; 252 | sensor->min_delay = 0; 253 | sensor->min_value = -40; 254 | sensor->max_value = 85; 255 | sensor->resolution = 0.3; // depends on calibration data? 256 | } 257 | /*! 258 | @brief Gets the temperature as a standard sensor event 259 | @param event Sensor event object that will be populated 260 | @returns true 261 | */ 262 | bool Adafruit_AHTX0_Temp::getEvent(sensors_event_t *event) { 263 | _theAHTX0->getEvent(NULL, event); 264 | 265 | return true; 266 | } 267 | -------------------------------------------------------------------------------- /Adafruit_AHTX0.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_AHTX0.h 3 | * 4 | * I2C Driver for the Adafruit AHT10 / AHT20 Humidity and Temperature 5 | *Sensor library 6 | * 7 | * This is a library for the Adafruit AHT20 breakout: 8 | * https://www.adafruit.com/products/4566 9 | * 10 | * Adafruit invests time and resources providing this open source code, 11 | * please support Adafruit and open-source hardware by purchasing products from 12 | * Adafruit! 13 | * 14 | * 15 | * BSD license (see license.txt) 16 | */ 17 | 18 | #ifndef _ADAFRUIT_AHTX0_H 19 | #define _ADAFRUIT_AHTX0_H 20 | 21 | #include "Arduino.h" 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #define AHTX0_I2CADDR_DEFAULT 0x38 ///< AHT default i2c address 28 | #define AHTX0_I2CADDR_ALTERNATE 0x39 ///< AHT alternate i2c address 29 | #define AHTX0_CMD_CALIBRATE 0xE1 ///< Calibration command 30 | #define AHTX0_CMD_TRIGGER 0xAC ///< Trigger reading command 31 | #define AHTX0_CMD_SOFTRESET 0xBA ///< Soft reset command 32 | #define AHTX0_STATUS_BUSY 0x80 ///< Status bit for busy 33 | #define AHTX0_STATUS_CALIBRATED 0x08 ///< Status bit for calibrated 34 | 35 | class Adafruit_AHTX0; 36 | 37 | /** 38 | * @brief Adafruit Unified Sensor interface for the humidity sensor component 39 | * of AHT10/AHT20 40 | * 41 | */ 42 | class Adafruit_AHTX0_Humidity : public Adafruit_Sensor { 43 | public: 44 | /** @brief Create an Adafruit_Sensor compatible object for the humidity sensor 45 | @param parent A pointer to the AHTX0 class */ 46 | Adafruit_AHTX0_Humidity(Adafruit_AHTX0 *parent) { _theAHTX0 = parent; } 47 | bool getEvent(sensors_event_t *); 48 | void getSensor(sensor_t *); 49 | 50 | private: 51 | int _sensorID = 0x1020; 52 | Adafruit_AHTX0 *_theAHTX0 = NULL; 53 | }; 54 | 55 | /** 56 | * @brief Adafruit Unified Sensor interface for the temperature sensor component 57 | * of AHT10/AHT20 58 | * 59 | */ 60 | class Adafruit_AHTX0_Temp : public Adafruit_Sensor { 61 | public: 62 | /** @brief Create an Adafruit_Sensor compatible object for the temp sensor 63 | @param parent A pointer to the AHTX0 class */ 64 | Adafruit_AHTX0_Temp(Adafruit_AHTX0 *parent) { _theAHTX0 = parent; } 65 | 66 | bool getEvent(sensors_event_t *); 67 | void getSensor(sensor_t *); 68 | 69 | private: 70 | int _sensorID = 0x1021; 71 | Adafruit_AHTX0 *_theAHTX0 = NULL; 72 | }; 73 | 74 | /*! 75 | * @brief Class that stores state and functions for interacting with 76 | * the AHT10/AHT20 I2C Temperature/Humidity sensor 77 | */ 78 | class Adafruit_AHTX0 { 79 | public: 80 | Adafruit_AHTX0(); 81 | ~Adafruit_AHTX0(); 82 | 83 | bool begin(TwoWire *wire = &Wire, int32_t sensor_id = 0, 84 | uint8_t i2c_address = AHTX0_I2CADDR_DEFAULT); 85 | 86 | bool getEvent(sensors_event_t *humidity, sensors_event_t *temp); 87 | uint8_t getStatus(void); 88 | Adafruit_Sensor *getTemperatureSensor(void); 89 | Adafruit_Sensor *getHumiditySensor(void); 90 | 91 | protected: 92 | float _temperature, ///< Last reading's temperature (C) 93 | _humidity; ///< Last reading's humidity (percent) 94 | 95 | uint16_t _sensorid_humidity; ///< ID number for humidity 96 | uint16_t _sensorid_temp; ///< ID number for temperature 97 | 98 | Adafruit_I2CDevice *i2c_dev = NULL; ///< Pointer to I2C bus interface 99 | 100 | Adafruit_AHTX0_Temp *temp_sensor = NULL; ///< Temp sensor data object 101 | Adafruit_AHTX0_Humidity *humidity_sensor = 102 | NULL; ///< Humidity sensor data object 103 | 104 | private: 105 | void _fetchTempCalibrationValues(void); 106 | void _fetchHumidityCalibrationValues(void); 107 | friend class Adafruit_AHTX0_Temp; ///< Gives access to private members to 108 | ///< Temp data object 109 | friend class Adafruit_AHTX0_Humidity; ///< Gives access to private members to 110 | ///< Humidity data object 111 | 112 | void fillTempEvent(sensors_event_t *temp, uint32_t timestamp); 113 | void fillHumidityEvent(sensors_event_t *humidity, uint32_t timestamp); 114 | }; 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Adafruit AHTX0 (AHT10 & AHT20) [![Build Status](https://github.com/adafruit/Adafruit_AHTX0/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/Adafruit_AHTX0/actions) 2 | 3 | This is the Adafruit AHT10+AHT20 Humidity and Temperature Sensor library for Arduino 4 | 5 | Tested and works great with the Adafruit AHT20 Breakout Board 6 | [](https://www.adafruit.com/products/) 7 | 8 | 9 | This chip uses I2C to communicate, 2 pins are required to interface 10 | 11 | Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! 12 | 13 | # Dependencies 14 | * [Adafruit_BusIO](https://github.com/adafruit/Adafruit_BusIO) 15 | * [Adafruit_Sensor](https://github.com/adafruit/Adafruit_Sensor) 16 | 17 | # Contributing 18 | 19 | Contributions are welcome! Please read our [Code of Conduct](https://github.com/adafruit/Adafruit_AHT10/blob/master/CODE_OF_CONDUCT.md>) 20 | before contributing to help this project stay welcoming. 21 | 22 | ## Documentation and doxygen 23 | Documentation is produced by doxygen. Contributions should include documentation for any new code added. 24 | 25 | Some examples of how to use doxygen can be found in these guide pages: 26 | 27 | https://learn.adafruit.com/the-well-automated-arduino-library/doxygen 28 | 29 | https://learn.adafruit.com/the-well-automated-arduino-library/doxygen-tips 30 | 31 | Written by ladyada for Adafruit Industries. 32 | BSD license, check license.txt for more information 33 | All text above must be included in any redistribution 34 | 35 | To install, use the Arduino Library Manager and search for "Adafruit AHTX0" and install the library. 36 | -------------------------------------------------------------------------------- /assets/board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_AHTX0/805eab7199366ae647f122864db4780b05129e5f/assets/board.png -------------------------------------------------------------------------------- /code-of-conduct.md: -------------------------------------------------------------------------------- 1 | # Adafruit Community Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and leaders pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level or type of 9 | experience, education, socio-economic status, nationality, personal appearance, 10 | race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | We are committed to providing a friendly, safe and welcoming environment for 15 | all. 16 | 17 | Examples of behavior that contributes to creating a positive environment 18 | include: 19 | 20 | * Be kind and courteous to others 21 | * Using welcoming and inclusive language 22 | * Being respectful of differing viewpoints and experiences 23 | * Collaborating with other community members 24 | * Gracefully accepting constructive criticism 25 | * Focusing on what is best for the community 26 | * Showing empathy towards other community members 27 | 28 | Examples of unacceptable behavior by participants include: 29 | 30 | * The use of sexualized language or imagery and sexual attention or advances 31 | * The use of inappropriate images, including in a community member's avatar 32 | * The use of inappropriate language, including in a community member's nickname 33 | * Any spamming, flaming, baiting or other attention-stealing behavior 34 | * Excessive or unwelcome helping; answering outside the scope of the question 35 | asked 36 | * Trolling, insulting/derogatory comments, and personal or political attacks 37 | * Public or private harassment 38 | * Publishing others' private information, such as a physical or electronic 39 | address, without explicit permission 40 | * Other conduct which could reasonably be considered inappropriate 41 | 42 | The goal of the standards and moderation guidelines outlined here is to build 43 | and maintain a respectful community. We ask that you don’t just aim to be 44 | "technically unimpeachable", but rather try to be your best self. 45 | 46 | We value many things beyond technical expertise, including collaboration and 47 | supporting others within our community. Providing a positive experience for 48 | other community members can have a much more significant impact than simply 49 | providing the correct answer. 50 | 51 | ## Our Responsibilities 52 | 53 | Project leaders are responsible for clarifying the standards of acceptable 54 | behavior and are expected to take appropriate and fair corrective action in 55 | response to any instances of unacceptable behavior. 56 | 57 | Project leaders have the right and responsibility to remove, edit, or 58 | reject messages, comments, commits, code, issues, and other contributions 59 | that are not aligned to this Code of Conduct, or to ban temporarily or 60 | permanently any community member for other behaviors that they deem 61 | inappropriate, threatening, offensive, or harmful. 62 | 63 | ## Moderation 64 | 65 | Instances of behaviors that violate the Adafruit Community Code of Conduct 66 | may be reported by any member of the community. Community members are 67 | encouraged to report these situations, including situations they witness 68 | involving other community members. 69 | 70 | You may report in the following ways: 71 | 72 | In any situation, you may send an email to . 73 | 74 | On the Adafruit Discord, you may send an open message from any channel 75 | to all Community Helpers by tagging @community helpers. You may also send an 76 | open message from any channel, or a direct message to @kattni#1507, 77 | @tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or 78 | @Andon#8175. 79 | 80 | Email and direct message reports will be kept confidential. 81 | 82 | In situations on Discord where the issue is particularly egregious, possibly 83 | illegal, requires immediate action, or violates the Discord terms of service, 84 | you should also report the message directly to Discord. 85 | 86 | These are the steps for upholding our community’s standards of conduct. 87 | 88 | 1. Any member of the community may report any situation that violates the 89 | Adafruit Community Code of Conduct. All reports will be reviewed and 90 | investigated. 91 | 2. If the behavior is an egregious violation, the community member who 92 | committed the violation may be banned immediately, without warning. 93 | 3. Otherwise, moderators will first respond to such behavior with a warning. 94 | 4. Moderators follow a soft "three strikes" policy - the community member may 95 | be given another chance, if they are receptive to the warning and change their 96 | behavior. 97 | 5. If the community member is unreceptive or unreasonable when warned by a 98 | moderator, or the warning goes unheeded, they may be banned for a first or 99 | second offense. Repeated offenses will result in the community member being 100 | banned. 101 | 102 | ## Scope 103 | 104 | This Code of Conduct and the enforcement policies listed above apply to all 105 | Adafruit Community venues. This includes but is not limited to any community 106 | spaces (both public and private), the entire Adafruit Discord server, and 107 | Adafruit GitHub repositories. Examples of Adafruit Community spaces include 108 | but are not limited to meet-ups, audio chats on the Adafruit Discord, or 109 | interaction at a conference. 110 | 111 | This Code of Conduct applies both within project spaces and in public spaces 112 | when an individual is representing the project or its community. As a community 113 | member, you are representing our community, and are expected to behave 114 | accordingly. 115 | 116 | ## Attribution 117 | 118 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 119 | version 1.4, available at 120 | , 121 | and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html). 122 | 123 | For other projects adopting the Adafruit Community Code of 124 | Conduct, please contact the maintainers of those projects for enforcement. 125 | If you wish to use this code of conduct for your own project, consider 126 | explicitly mentioning your moderation policy or making a copy with your 127 | own moderation policy so as to avoid confusion. 128 | -------------------------------------------------------------------------------- /examples/adafruit_aht_test/adafruit_aht_test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | Adafruit_AHTX0 aht; 4 | 5 | void setup() { 6 | Serial.begin(115200); 7 | Serial.println("Adafruit AHT10/AHT20 demo!"); 8 | 9 | if (! aht.begin()) { 10 | Serial.println("Could not find AHT? Check wiring"); 11 | while (1) delay(10); 12 | } 13 | Serial.println("AHT10 or AHT20 found"); 14 | } 15 | 16 | void loop() { 17 | sensors_event_t humidity, temp; 18 | aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data 19 | Serial.print("Temperature: "); Serial.print(temp.temperature); Serial.println(" degrees C"); 20 | Serial.print("Humidity: "); Serial.print(humidity.relative_humidity); Serial.println("% rH"); 21 | 22 | delay(500); 23 | } -------------------------------------------------------------------------------- /examples/adafruit_aht_unifiedsensors/adafruit_aht_unifiedsensors.ino: -------------------------------------------------------------------------------- 1 | // Demo for getting individual unified sensor data from the AHT Humidity and Temperature sensor 2 | 3 | #include 4 | 5 | Adafruit_AHTX0 aht; 6 | 7 | Adafruit_Sensor *aht_humidity, *aht_temp; 8 | 9 | void setup(void) { 10 | Serial.begin(115200); 11 | while (!Serial) 12 | delay(10); // will pause Zero, Leonardo, etc until serial console opens 13 | 14 | Serial.println("Adafruit AHT10/AHT20 test!"); 15 | 16 | if (!aht.begin()) { 17 | Serial.println("Failed to find AHT10/AHT20 chip"); 18 | while (1) { 19 | delay(10); 20 | } 21 | } 22 | 23 | Serial.println("AHT10/AHT20 Found!"); 24 | aht_temp = aht.getTemperatureSensor(); 25 | aht_temp->printSensorDetails(); 26 | 27 | aht_humidity = aht.getHumiditySensor(); 28 | aht_humidity->printSensorDetails(); 29 | } 30 | 31 | void loop() { 32 | // /* Get a new normalized sensor event */ 33 | sensors_event_t humidity; 34 | sensors_event_t temp; 35 | aht_humidity->getEvent(&humidity); 36 | aht_temp->getEvent(&temp); 37 | 38 | Serial.print("\t\tTemperature "); 39 | Serial.print(temp.temperature); 40 | Serial.println(" deg C"); 41 | 42 | /* Display the results (humidity is measured in % relative humidity (% rH) */ 43 | Serial.print("\t\tHumidity: "); 44 | Serial.print(humidity.relative_humidity); 45 | Serial.println(" % rH"); 46 | Serial.print("\t\tTemperature: "); 47 | Serial.print(temp.temperature); 48 | Serial.println(" degrees C"); 49 | 50 | 51 | delay(100); 52 | 53 | /*// serial plotter friendly format 54 | Serial.print(temp.temperature); 55 | Serial.print(","); 56 | 57 | Serial.print(humidity.relative_humidity); 58 | 59 | Serial.println(); 60 | delay(10); 61 | */ 62 | } 63 | -------------------------------------------------------------------------------- /examples/aht20_oleddemo/aht20_oleddemo.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | Adafruit_SH1107 display = Adafruit_SH1107(64, 128, &Wire); 10 | 11 | Adafruit_AHTX0 aht; 12 | 13 | void setup() { 14 | Serial.begin(115200); 15 | //while (!Serial); 16 | 17 | Serial.println("128x64 OLED FeatherWing test"); 18 | display.begin(0x3C, true); // Address 0x3C default 19 | 20 | Serial.println("OLED begun"); 21 | 22 | // Show image buffer on the display hardware. 23 | // Since the buffer is intialized with an Adafruit splashscreen 24 | // internally, this will display the splashscreen. 25 | display.display(); 26 | delay(3000); 27 | 28 | // Clear the buffer. 29 | display.clearDisplay(); 30 | display.display(); 31 | 32 | display.setRotation(1); 33 | display.setFont(&FreeSans9pt7b); 34 | if (aht.begin()) { 35 | Serial.println("Found AHT20"); 36 | } else { 37 | Serial.println("Didn't find AHT20"); 38 | } 39 | 40 | display.setTextSize(1); 41 | display.setTextColor(SH110X_WHITE); 42 | } 43 | 44 | void loop() { 45 | display.clearDisplay(); 46 | sensors_event_t humidity, temp; 47 | 48 | aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data 49 | display.setCursor(0,20); 50 | display.print("AHT20 Demo"); 51 | display.setCursor(0,40); 52 | display.print("Temp: "); display.print(temp.temperature); display.println(" C"); 53 | display.setCursor(0,60); 54 | display.print("Hum: "); display.print(humidity.relative_humidity); display.println(" %"); 55 | Serial.print("Temperature: ");Serial.print(temp.temperature);Serial.println(" degrees C"); 56 | Serial.print("Pressure: ");Serial.print(humidity.relative_humidity);Serial.println(" RH %"); 57 | 58 | yield(); 59 | display.display(); 60 | delay(100); 61 | } 62 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit AHTX0 2 | version=2.0.5 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Arduino library for the AHT10 and AHT20 sensors in the Adafruit shop 6 | paragraph=Arduino library for the AHT10 and AHT20 sensors in the Adafruit shop 7 | category=Sensors 8 | url=https://github.com/adafruit/Adafruit_AHTX0 9 | architectures=* 10 | depends=Adafruit Unified Sensor, Adafruit BusIO, Adafruit SH110X 11 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2019 Limor Fried (Adafruit Industries) 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. Neither the name of the copyright holders nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | --------------------------------------------------------------------------------