Zoltan Hudak / HX711

Dependents:   HMC1501_Hello

Embed: (wiki syntax)

« Back to documentation index

HX711 Class Reference

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:
avddAnalog power supply voltage [V]
sckPinName of the clock pin (digital output)
doutPinName of the data pin (digital input)
driftChip's input offset drift [V]
gainChannel selection is made by passing the associated gain: 128 or 64 for channel A, 32 for channel B

Definition at line 40 of file HX711.h.


Member Function Documentation

float getAvdd (  )

Get sensor's analog power supply voltage.

Returns:
power supply voltage

Definition at line 99 of file HX711.h.

int getDrift (  )

Gets chip's input offset drift.

Returns:
Chip's input offset drift [mV]

Definition at line 111 of file HX711.h.

uint8_t getGain (  )

Obtain current gain.

Returns:
gain_

Definition at line 93 of file HX711.h.

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

Definition at line 56 of file HX711.h.

void powerDown (  )

Puts the chip into power down mode.

Definition at line 73 of file HX711.h.

void powerUp (  )

Wakes up the chip after power down mode.

Definition at line 78 of file HX711.h.

float read (  )

Obtains input voltage in mV biased by chip's input offset drift.

Obtains HX711's input voltage in mV.

Returns:
float
Note:
Return values:
Measuredvoltage in mV.

Definition at line 110 of file HX711.cpp.

uint32_t readInt (  )

Returns a raw int reading.

Obtains digital value of measured analog input voltage.

Returns:
int sensor output value
Note:
It's a 24-bit two's complement integer.
Return values:
Digitalvalue of measured analog input voltage.

Definition at line 60 of file HX711.cpp.

void setDrift ( float  drift = 0 )

Sets the chip's input offset drift.

Parameters:
driftThe input offset drift [mV]

Definition at line 105 of file HX711.h.

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:
gain128, 64 or 32

Sets gain

Note:
Parameters:
gainSelected gain (128, 64 or 32)
Return values:

Definition at line 34 of file HX711.cpp.