Lectura de una celda de Carga HX711.
Hx711 Class Reference
Class for communication with the HX711 24-Bit Analog-to-Digital Converter (ADC) for Weigh Scales by AVIA Semiconductor. More...
#include <Hx711.h>
Public Member Functions | |
| Hx711 (PinName pin_sck, PinName pin_dt, float offset, float scale, uint8_t gain=128) | |
| Create an Hx711 ADC object. | |
| Hx711 (PinName pin_sck, PinName pin_dt, uint8_t gain=128) | |
| Create an Hx711 ADC object with zero offset and unit scaling. | |
| bool | is_ready () |
| Check if the sensor is ready from the datasheet: When output data is not ready for retrieval, digital output pin DOUT is high. | |
| uint32_t | readRaw () |
| Waits for the chip to be ready and returns a raw int reading. | |
| float | read () |
| Obtain offset and scaled sensor output; i.e. | |
| float | convert_to_real (int val) |
| Convert integer value from chip to offset and scaled real value. | |
| void | power_down () |
| Puts the chip into power down mode. | |
| void | power_up () |
| Wakes up the chip after power down mode. | |
| void | set_gain (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 | get_gain () |
| Obtain current gain. | |
| void | set_scale (float scale=1.0f) |
| Set the scale factor. | |
| float | get_scale () |
| Get sensor scale factor. | |
| void | set_offset (float offset=0.0) |
| Set the sensor offset. | |
| float | get_offset () |
| Get current sensor offset. | |
Detailed Description
Class for communication with the HX711 24-Bit Analog-to-Digital Converter (ADC) for Weigh Scales by AVIA Semiconductor.
This library is a port of the Arduino library at https://github.com/bogde/HX711 It works with the FRDM K22F.
Definition at line 11 of file Hx711.h.
Constructor & Destructor Documentation
| Hx711 | ( | PinName | pin_sck, |
| PinName | pin_dt, | ||
| float | offset, | ||
| float | scale, | ||
| uint8_t | gain = 128 |
||
| ) |
Create an Hx711 ADC object.
- Parameters:
-
pin_sck PinName of the clock pin (digital output) pin_dt PinName of the data pin (digital input) offset offset for sensor values scale scale factor to obtain real values gain channel selection is made by passing the appropriate gain: 128 or 64 for channel A, 32 for channel B
| Hx711 | ( | PinName | pin_sck, |
| PinName | pin_dt, | ||
| uint8_t | gain = 128 |
||
| ) |
Create an Hx711 ADC object with zero offset and unit scaling.
- Parameters:
-
pin_sck PinName of the clock pin (digital output) pin_dt PinName of the data pin (digital input) gain channel selection is made by passing the appropriate gain: 128 or 64 for channel A, 32 for channel B TODO: constructor overloading is not allowed?
Member Function Documentation
| float convert_to_real | ( | int | val ) |
Convert integer value from chip to offset and scaled real value.
- Parameters:
-
val integer value
- Returns:
- (val - get_offset()) * get_scale()
| float get_offset | ( | ) |
| bool is_ready | ( | ) |
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 PD_SCK should be low. When DOUT goes to low, it indicates data is ready for retrieval.
- Returns:
- true if dt_.read() == LOW TODO: this is not ideal; the programm will hang if the chip never becomes ready...
| float read | ( | ) |
| uint32_t readRaw | ( | ) |
| void set_gain | ( | 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.
- Parameters:
-
gain 128, 64 or 32
| void set_offset | ( | float | offset = 0.0 ) |
Generated on Tue Jul 26 2022 10:16:33 by
1.7.2