-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f87b1ea
Showing
8 changed files
with
724 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
stuff/ | ||
build/ | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Set minimum required version of CMake | ||
cmake_minimum_required(VERSION 3.12) | ||
|
||
# Include build functions from Pico SDK | ||
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake) | ||
|
||
# Set name of project (as PROJECT_NAME) and C/C++ standards | ||
project(ahtxx C CXX ASM) | ||
set(CMAKE_C_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
# Creates a pico-sdk subdirectory in our project for the libraries | ||
pico_sdk_init() | ||
|
||
# Tell CMake where to find the executable source file | ||
add_executable(${PROJECT_NAME} | ||
src/main.cpp | ||
) | ||
|
||
# Create map/bin/hex/uf2 files | ||
pico_add_extra_outputs(${PROJECT_NAME}) | ||
|
||
add_library(pico_ahtxx INTERFACE) | ||
|
||
target_sources(pico_ahtxx INTERFACE | ||
${CMAKE_CURRENT_LIST_DIR}/src/ahtxx/ahtxx.cpp | ||
) | ||
|
||
target_include_directories(pico_ahtxx INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) | ||
|
||
# Pull in pico libraries that we need | ||
target_link_libraries(${PROJECT_NAME} pico_stdlib hardware_i2c pico_ahtxx ) | ||
|
||
|
||
# Enable usb output, disable uart output | ||
pico_enable_stdio_usb(${PROJECT_NAME} 1) | ||
pico_enable_stdio_uart(${PROJECT_NAME} 0) | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
[![Website](https://img.shields.io/badge/Website-Link-blue.svg)](https://gavinlyonsrepo.github.io/) [![Rss](https://img.shields.io/badge/Subscribe-RSS-yellow.svg)](https://gavinlyonsrepo.github.io//feed.xml) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/paypalme/whitelight976) | ||
|
||
Overview | ||
-------------------------------------------- | ||
* Name: AHTXX | ||
* Description: | ||
Library for Aosong ASAIR AHT10, AHT15 & AHT20 Digital Humidity & Temperature Sensor I2C. | ||
Only tested on AHT10. | ||
* Developed on | ||
1. Raspberry pi PICO RP2040 | ||
2. SDK C++ compiler G++ for arm-none-eabi | ||
3. CMAKE , VScode | ||
|
||
Features | ||
---------------------- | ||
|
||
![o](https://github.com/gavinlyonsrepo/STM32_projects/blob/master/extra/images/aht10.jpg) | ||
|
||
|
||
Library for Aosong ASAIR AHT10, AHT15 & AHT20 Digital Humidity & Temperature Sensor I2C. | ||
|
||
1. Supply voltage: 1.8v - 3.6v for AHT10, AHT15 & 2.0v - 5.5v for AHT20 | ||
2. Temperature range: -40°C..+85°C | ||
3. Temperature resolution: 0.01°C | ||
4. Temperature accuracy: ±0.3°C | ||
5. Relative humidity range: 0%..100% | ||
6. Relative humidity resolution: 0.024% | ||
7. Relative humidity accuracy: ±2%** | ||
8. I²C bus speed: 0Hz - 400KHz | ||
9. Recommended polling frequency: 8sec - 30sec | ||
|
||
Supports sensors features: | ||
|
||
1. Read humidity | ||
2. Read temperature | ||
3. Soft reset with sensor initialisation | ||
4. The library returns an errors if a communication error occurs or if the calibration coefficient is off. | ||
|
||
**Connections** | ||
|
||
The Sensor uses I2C for communication's. Data is outputted (eg to a PC) via a USB. | ||
Can be set up for any I2C interface and speed. By default I2C0, GPIO16(SDATA) and GPIO17(SCLK) & 100kHz. | ||
|
||
**Files** | ||
|
||
The main.cpp contains tests showing library functions | ||
There is also an library (ahtxx.cpp and ahtxx.h), | ||
|
||
**Output** | ||
|
||
Data is outputted (eg to a PC) via a USB . | ||
![o1](https://github.com/gavinlyonsrepo/STM32_projects/blob/master/extra/images/aht10output.jpg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Changelog | ||
|
||
* version 1.0.0 November 2022 | ||
* first release | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Project Name: library for Aosong ASAIR AHT10, | ||
AHT15 AHT20 Digital Humidity & Temperature Sensor | ||
* File: ahtxx.hpp | ||
* Description: library header file | ||
* See URL for full details. | ||
* URL: https://github.com/gavinlyonsrepo/AHTXX_PICO | ||
*/ | ||
|
||
#ifndef _AHT10_h | ||
#define _AHT10_h | ||
|
||
#include <stdint.h> | ||
#include <stdbool.h> | ||
#include "pico/stdlib.h" | ||
#include "hardware/i2c.h" | ||
|
||
#define AHT10_ADDRESS_0X38 0x38 // I2C address no.1 for AHT10/AHT15/AHT20, adres pin connect to GND | ||
#define AHT10_ADDRESS_0X39 0x39 // I2C address no.2 for AHT10 only, adres pin connect to Vcc | ||
#define AHT10_MY_I2C_DELAY 50 // Timeout for I2C comms, mS, | ||
|
||
#define AHT10_INIT_CMD 0xE1 // init command for AHT10/AHT15 | ||
#define AHT20_INIT_CMD 0xBE // init command for AHT20 | ||
#define AHT10_START_MEASURMENT_CMD 0xAC // start measurement command | ||
#define AHT10_NORMAL_CMD 0xA8 // normal cycle mode command, no info in datasheet!!! | ||
#define AHT10_SOFT_RESET_CMD 0xBA // soft reset command | ||
|
||
#define AHT10_INIT_NORMAL_MODE 0x00 // enable normal mode | ||
#define AHT10_INIT_CYCLE_MODE 0x20 // enable cycle mode | ||
#define AHT10_INIT_CMD_MODE 0x40 // enable command mode | ||
#define AHT10_INIT_CAL_ENABLE 0x08 // load factory calibration coeff | ||
|
||
#define AHT10_DATA_MEASURMENT_CMD 0x33 | ||
#define AHT10_DATA_NOP 0x00 | ||
|
||
#define AHT10_MEASURMENT_DELAY 80 // > 75 milliseconds | ||
#define AHT10_POWER_ON_DELAY 40 // 20-40 milliseconds | ||
#define AHT10_CMD_DELAY 350 // > 300 milliseconds | ||
#define AHT10_SOFT_RESET_DELAY 20 // < 20 milliseconds | ||
|
||
#define AHT10_FORCE_READ_DATA true // force to read data | ||
#define AHT10_USE_READ_DATA false // force to use data from previous read | ||
#define AHT10_ERROR 0xFF // returns 255, if communication error is occurred | ||
|
||
|
||
typedef enum ASAIR_I2C_SENSOR_e{ | ||
AHT10_SENSOR = 0x00, | ||
AHT15_SENSOR = 0x01, | ||
AHT20_SENSOR = 0x02 | ||
}ASAIR_I2C_SENSOR_e; | ||
|
||
class LIB_AHTXX | ||
{ | ||
private: | ||
i2c_inst_t *i2c = i2c0; | ||
uint8_t _address; | ||
ASAIR_I2C_SENSOR_e _sensorName; | ||
uint8_t _rawDataBuffer[6] = {AHT10_ERROR, 0, 0, 0, 0, 0}; | ||
int16_t returnValue = 0; | ||
|
||
public: | ||
// Constructor | ||
LIB_AHTXX(uint8_t , ASAIR_I2C_SENSOR_e); | ||
|
||
void AHT10_InitI2C(i2c_inst_t* i2c_type, uint8_t sdata , uint8_t sclk ,uint16_t clockspeed); | ||
void AHT10_DeInit(i2c_inst_t* i2c_type); | ||
bool AHT10_begin(); | ||
uint8_t AHT10_readRawData(); | ||
float AHT10_readTemperature(bool); | ||
float AHT10_readHumidity(bool); | ||
bool AHT10_softReset(); | ||
bool AHT10_setNormalMode(); | ||
bool AHT10_setCycleMode(); | ||
|
||
uint8_t AHT10_readStatusByte(); | ||
uint8_t AHT10_getCalibrationBit(bool); | ||
bool AHT10_enableFactoryCalCoeff(); | ||
uint8_t AHT10_getBusyBit(bool); | ||
}; | ||
#endif | ||
|
Oops, something went wrong.