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.
HX711 Class Reference
Class for communication with the HX711 24-Bit Analog-to-Digital converter (ADC) (Developed for Weigh Scales by AVIA Semiconductor.) This library is based on the library at https://github.com/bogde/HX711. More...
#include <HX711.h>
Public Member Functions | |
| HX711 (float avdd, PinName sck, PinName dout, uint8_t gain, float drift=0) | |
| Creates an HX711 object. | |
| bool | isReady () |
| Check if the sensor is ready. | |
| uint32_t | readInt () |
| Returns a raw int reading. | |
| float | read () |
| Obtains input voltage in mV biased by chip's input offset drift. | |
| void | powerDown () |
| Puts the chip into power down mode. | |
| void | powerUp () |
| Wakes up the chip after power down mode. | |
| void | setGain (uint8_t gain=128) |
| Set the gain factor; takes effect only after a call to read() channel A can be set for a 128 or 64 gain; channel B has a fixed 32 gain depending on the parameter, the channel is also set to either A or B Ensures that gain_ = 128, 64 or 32. | |
| uint8_t | getGain () |
| Obtain current gain. | |
| float | getAvdd () |
| Get sensor's analog power supply voltage. | |
| void | setDrift (float drift=0) |
| Sets the chip's input offset drift. | |
| int | getDrift () |
| Gets chip's input offset drift. | |
Detailed Description
Class for communication with the HX711 24-Bit Analog-to-Digital converter (ADC) (Developed for Weigh Scales by AVIA Semiconductor.) This library is based on the library at https://github.com/bogde/HX711.
Definition at line 28 of file HX711.h.
Constructor & Destructor Documentation
| HX711 | ( | float | avdd, |
| PinName | sck, | ||
| PinName | dout, | ||
| uint8_t | gain, | ||
| float | drift = 0 |
||
| ) |
Creates an HX711 object.
- Parameters:
-
avdd Analog power supply voltage [V] sck PinName of the clock pin (digital output) dout PinName of the data pin (digital input) drift Chip's input offset drift [V] gain Channel selection is made by passing the associated gain: 128 or 64 for channel A, 32 for channel B
Member Function Documentation
| float getAvdd | ( | ) |
| int getDrift | ( | ) |
| bool isReady | ( | ) |
Check if the sensor is ready.
From the datasheet: When output data is not ready for retrieval, digital output pin _dout is high. Serial clock input _sck should be low. When _dout goes low, it indicates data is ready for retrieval.
- Returns:
- true if _dout.read() == 0
| float read | ( | ) |
| uint32_t readInt | ( | ) |
| void setDrift | ( | float | drift = 0 ) |
| void setGain | ( | uint8_t | gain = 128 ) |
Set the gain factor; takes effect only after a call to read() channel A can be set for a 128 or 64 gain; channel B has a fixed 32 gain depending on the parameter, the channel is also set to either A or B Ensures that gain_ = 128, 64 or 32.
Class for communication with the HX711 24-Bit Analog-to-Digital converter (ADC) (Developed for Weigh Scales by AVIA Semiconductor but can be used generally.) This library is based on the library at https://github.com/bogde/HX711.
- Parameters:
-
gain 128, 64 or 32
Sets gain
- Note:
- Parameters:
-
gain Selected gain (128, 64 or 32)
- Return values:
-
Generated on Tue Jul 12 2022 16:32:48 by
1.7.2