HX711 Library 1.0.0
This is a library for the HX711 Module
Loading...
Searching...
No Matches
HX711 Class Reference

#include <HX711-SOLDERED.h>

Inherits EasyC.

Public Member Functions

 HX711 ()
 HX711 easyC constructor.
 
virtual ~HX711 ()
 HX711 default destructor.
 
 HX711 (uint8_t pin_dout, uint8_t pin_sck)
 HX711 native constructor.
 
void waitUntilReady ()
 Wait until the sensor is ready, this is a blocking function.
 
long getRawReading ()
 Get raw reading from the HX711. Works for both native and easyC.
 
long getAveragedReading (uint8_t numReadings=1)
 Make a number of readings and get the average of them.
 
double getOffsettedReading (uint8_t numReadings=1)
 Get an averaged reading minus the offset (set by setOffset)
 
double getReadingInUnits (uint8_t numReadings=1)
 Get the reading in set units. See readInUnits.ino example for more info.
 
void setZero ()
 Set the 'Zero' value (offset) of the load cell, used for calibration. While calling this function, don't put any weight on the load cell!
 
void setGain (uint8_t gain)
 Set the gain of the sensor. For both native and easyC.
 
float getGain ()
 Get the set gain value, in case you need it.
 
void setScale (float scale)
 Set the scale applied to getReadingInUnits. See readInUnits.ino for more info!
 
float getScale ()
 Get the set scale value, in case you need it.
 
void setOffset (float offset)
 Set the offset applied to getOffsettedReading.
 
float getOffset ()
 Get the set offset value, in case you need it.
 
void setDeepSleep (bool sleep)
 Put the HX711 in deep sleep (turn it off). Works for both easyC and native.
 
- Public Member Functions inherited from EasyC
 EasyC ()
 Main constructor for easyC version.
 
void begin ()
 Initializes sensors on native or easyC on default address.
 
void begin (uint8_t _address)
 Initializes sensors on supplied i2c address.
 
virtual void initializeNative ()=0
 
int sendAddress (char regAddr)
 Private function to send a single byte to sensor.
 
int readData (char a[], int n)
 Private function to read n bytes over i2c.
 
int readRegister (char regAddr, char a[], size_t n)
 Private function to send over i2c and then read n bytes.
 
int sendData (const uint8_t *a, int n)
 Private function to write n bytes over i2c.
 

Protected Member Functions

void initializeNative ()
 HX711 native initialization.
 

Private Member Functions

uint8_t readRegister ()
 Read a data on the HX711 by pulsing the clock, used for getRawReading.
 

Private Attributes

int _pin_dout
 
int _pin_sck
 
uint8_t _gain = GAIN_128
 
float _scale = 1.0
 
float _offset = 0.0
 
uint32_t _zeroConstant = 0
 

Additional Inherited Members

- Public Attributes inherited from EasyC
int native = 0
 
bool beginDone = 0
 
int err
 
char address
 
const char defaultAddress = 0x30
 

Constructor & Destructor Documentation

◆ HX711() [1/2]

HX711::HX711 ( )

HX711 easyC constructor.

◆ ~HX711()

HX711::~HX711 ( )
virtual

HX711 default destructor.

◆ HX711() [2/2]

HX711::HX711 ( uint8_t  pin_dout,
uint8_t  pin_sck 
)

HX711 native constructor.

Parameters
intdout pin connected to hx711 dout pin
intpd_sck pin connected to hx711 pd_sck pin

Member Function Documentation

◆ getAveragedReading()

long HX711::getAveragedReading ( uint8_t  numReadings = 1)

Make a number of readings and get the average of them.

Parameters
uint8_tnumReadings The number of readings to be done to average from
Returns
long of the averaged raw reading

◆ getGain()

float HX711::getGain ( )

Get the set gain value, in case you need it.

Returns
float of the set gain

◆ getOffset()

float HX711::getOffset ( )

Get the set offset value, in case you need it.

Returns
float of the set offset

◆ getOffsettedReading()

double HX711::getOffsettedReading ( uint8_t  numReadings = 1)

Get an averaged reading minus the offset (set by setOffset)

Parameters
uint8_tnumReadings The number of readings to be done to average from
Returns
double of the averaged and offsetted raw reading

◆ getRawReading()

long HX711::getRawReading ( )

Get raw reading from the HX711. Works for both native and easyC.

Note
Disables interrupts for a very short period of time
Returns
long of the raw reading

◆ getReadingInUnits()

double HX711::getReadingInUnits ( uint8_t  numReadings = 1)

Get the reading in set units. See readInUnits.ino example for more info.

Parameters
uint8_tnumReadings The number of readings to be done to average from
Returns
double of the reading in set units

◆ getScale()

float HX711::getScale ( )

Get the set scale value, in case you need it.

Returns
float of the set scale

◆ initializeNative()

void HX711::initializeNative ( )
protectedvirtual

HX711 native initialization.

Implements EasyC.

◆ readRegister()

uint8_t HX711::readRegister ( )
private

Read a data on the HX711 by pulsing the clock, used for getRawReading.

Returns
uint8_t of the value read from HX711

◆ setDeepSleep()

void HX711::setDeepSleep ( bool  sleep)

Put the HX711 in deep sleep (turn it off). Works for both easyC and native.

Parameters
boolsleep 'True' puts the device to sleep, 'False' turns it off.
Returns
none

◆ setGain()

void HX711::setGain ( uint8_t  gain)

Set the gain of the sensor. For both native and easyC.

Parameters
uint8_tgain Can either be GAIN_128, GAIN_64, GAIN_32
Returns
none

◆ setOffset()

void HX711::setOffset ( float  offset)

Set the offset applied to getOffsettedReading.

Parameters
floatoffset The offset to set
Returns
none

◆ setScale()

void HX711::setScale ( float  scale)

Set the scale applied to getReadingInUnits. See readInUnits.ino for more info!

Parameters
floatscale The scale to set
Returns
none

◆ setZero()

void HX711::setZero ( )

Set the 'Zero' value (offset) of the load cell, used for calibration. While calling this function, don't put any weight on the load cell!

Returns
none

◆ waitUntilReady()

void HX711::waitUntilReady ( )

Wait until the sensor is ready, this is a blocking function.

Returns
none

Member Data Documentation

◆ _gain

uint8_t HX711::_gain = GAIN_128
private

◆ _offset

float HX711::_offset = 0.0
private

◆ _pin_dout

int HX711::_pin_dout
private

◆ _pin_sck

int HX711::_pin_sck
private

◆ _scale

float HX711::_scale = 1.0
private

◆ _zeroConstant

uint32_t HX711::_zeroConstant = 0
private

The documentation for this class was generated from the following files: