Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: AM2321_Example mbed_vfd_thermometer
AM2321 Class Reference
AM2321 (Aosong Guangzhou Electronics) Temperature and Humidity Sensor mbed library. More...
#include <AM2321.h>
Public Member Functions | |
| AM2321 (PinName sda, PinName scl) | |
| Constructor. | |
| bool | poll () |
| Read current temperature and humidity from AM2321. | |
| float | getTemperature (void) const |
| Get last read temperature value. | |
| float | getHumidity (void) const |
| Get last read humidity value. | |
Detailed Description
AM2321 (Aosong Guangzhou Electronics) Temperature and Humidity Sensor mbed library.
Example:
#include "mbed.h" #include "AM2321.h" Serial pc(USBTX, USBRX); // Tx, Rx AM2321 am2321(p28, p27); // SDA, SCL int main() { while(1) { if(am2321.poll()) { pc.printf(":%05u,%.1f,%.1f\n" , count++ , am2321.getTemperature() , am2321.getHumidity() ); } wait(0.5); } }
Definition at line 39 of file AM2321.h.
Constructor & Destructor Documentation
| AM2321 | ( | PinName | sda, |
| PinName | scl | ||
| ) |
Constructor.
- Parameters:
-
sda [in] I2C Pin name (SDA) scl [in] I2C Pin name (SCL)
Definition at line 18 of file AM2321.cpp.
Member Function Documentation
| float getHumidity | ( | void | ) | const |
Get last read humidity value.
- Returns:
- humidity value (RH)
Definition at line 113 of file AM2321.cpp.
| float getTemperature | ( | void | ) | const |
Get last read temperature value.
- Returns:
- temperature value (degress)
Definition at line 108 of file AM2321.cpp.
| bool poll | ( | void | ) |
Read current temperature and humidity from AM2321.
- Returns:
- result (true=success)
Definition at line 63 of file AM2321.cpp.
Generated on Tue Jul 12 2022 19:43:48 by
1.7.2
AM2321