Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/peff74/esp_aht20_bmp280
ESP32/ESP8266 arduino script for an AHT20 + BMP280 only with Wire.h
https://github.com/peff74/esp_aht20_bmp280
aht20 arduino beginner-friendly bmp280 esp32 esp8266 humidity i2c iot non-blocking pressure sensor temperature weather
Last synced: about 2 months ago
JSON representation
ESP32/ESP8266 arduino script for an AHT20 + BMP280 only with Wire.h
- Host: GitHub
- URL: https://github.com/peff74/esp_aht20_bmp280
- Owner: peff74
- License: mit
- Created: 2024-01-11T10:52:41.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-10-24T23:08:23.000Z (2 months ago)
- Last Synced: 2024-10-25T01:41:55.952Z (2 months ago)
- Topics: aht20, arduino, beginner-friendly, bmp280, esp32, esp8266, humidity, i2c, iot, non-blocking, pressure, sensor, temperature, weather
- Language: HTML
- Homepage:
- Size: 7.8 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AHT20 / BMP280 sensor script for Arduino
- This is an AHT20 / BMP280 temperature/pressure/humidity sensor script
for Arduino.
- AHT20 + BMP280 chips are sold for less than a dollar
on Ali.
- This script only uses the Wire.h library, nothing else.
- Works with ESP8266, ESP32 and similar![AHT20_BMP280 logo](https://github.com/peff74/ESP_AHT20_BMP280/blob/main/AHT20_BMP280.jpg)
## Arduino script features
- Read temperature / humidity from AHT20
- Read temperature / pressure from BMP280
- No long loop times when reading the AHT20
- Non blocking
- Simple and clearly written
- So that even beginners (like me) can understand how it works
## How does it work
**AHT20**The ATH20 can be reached via the address 0x38
So every query must begin with:Wire.beginTransmission(0x38);
To initiate the AHT20, 0xBE must be sent.
*void AHT20_begin()*
Wire.write(0xBE);To start the measurement 0xAC, 0x33, 0x00 must be sent.
*void startMeasurementAHT20()*Wire.write(0xAC);
Wire.write(0x33);
Wire.write(0x00);
Now you have to wait until the data is available.
ARAIR specifies a waiting time of 80ms. At the same time, the “Busy indication” bit must be monitored; if this is “0”, the measurement is finished.
*void checkbusyAHT20()*if (sensor_started && sensor_busy && ((millis() - measurementDelayAHT20 >= 80))) {
Wire.requestFrom(0x38, 1);
.
.
.
The 8 bytes of data can now be called up.
*void getDataAHT20()*Wire.requestFrom(0x38, 7);
The bytes read in can now be processed as shown below
+------------------+
| Byte 0: 00011000 |
| Byte 1: 10010011 |
| Byte 2: 10101100 |
| Byte 3: 10010101 |
| Byte 4: 00101010 |
| Byte 5: 11000101 |
| Byte 6: 10110011 |
+------------------+
+----------------------------+----------------------------+
| Humidity (raw) | Temperature (raw) |
+----------------------------+----------------------------+
| 10010011 10101100 1001 | 0101 00101010 11000101 |
| (B1) (B2) (B3) | (B3) (B4) (B5) |
+----------------------------+----------------------------+
+----------------------------------+
| Berechnung Humi |
| 10010011101011001001 = 604873 |
| 604873 / 1048576 * 100 = 57.69 |
+----------------------------------+
+-------------------------------------------+
| Berechnung Temp |
| 01010010101011000101 = 338629 |
| 338629 / 1048576 * 200.0 - 50.0 = 14.59 |
+-------------------------------------------+
Humidity: 57.69%. Temperature: 14.59[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fpeff74%2FESP_AHT20_BMP280&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://hits.seeyoufarm.com)