ZotBins Core
Loading...
Searching...
No Matches
hx711

Data Structures

struct  hx711_t
 

Enumerations

enum  hx711_gain_t { HX711_GAIN_A_128 = 0 , HX711_GAIN_B_32 , HX711_GAIN_A_64 }
 

Functions

esp_err_t hx711_init (hx711_t *dev)
 Initialize device.
 
esp_err_t hx711_power_down (hx711_t *dev, bool down)
 Set device power up/down.
 
esp_err_t hx711_set_gain (hx711_t *dev, hx711_gain_t gain)
 Set device gain and channel.
 
esp_err_t hx711_is_ready (hx711_t *dev, bool *ready)
 Check if device ready to send data.
 
esp_err_t hx711_wait (hx711_t *dev, size_t timeout_ms)
 Wait for device to become ready.
 
esp_err_t hx711_read_data (hx711_t *dev, int32_t *data)
 Read raw data from device.
 
esp_err_t hx711_read_average (hx711_t *dev, size_t times, int32_t *data)
 Read average data.
 

Detailed Description

ESP-IDF driver for HX711 24-bit ADC for weigh scales

Copyright (c) 2019 Ruslan V. Uss uncle.nosp@m.rus@.nosp@m.gmail.nosp@m..com

BSD Licensed as described in the file LICENSE

Enumeration Type Documentation

◆ hx711_gain_t

Gain/channel

Enumerator
HX711_GAIN_A_128 

Channel A, gain factor 128.

HX711_GAIN_B_32 

Channel B, gain factor 32.

HX711_GAIN_A_64 

Channel A, gain factor 64.

Function Documentation

◆ hx711_init()

esp_err_t hx711_init ( hx711_t * dev)

Initialize device.

Prepare GPIO pins, power up device and set gain

Parameters
devDevice descriptor
Returns
ESP_OK on success, ESP_ERR_TIMEOUT if device not found

◆ hx711_is_ready()

esp_err_t hx711_is_ready ( hx711_t * dev,
bool * ready )

Check if device ready to send data.

Parameters
devDevice descriptor
[out]readytrue if data ready
Returns
ESP_OK on success

◆ hx711_power_down()

esp_err_t hx711_power_down ( hx711_t * dev,
bool down )

Set device power up/down.

Parameters
devDevice descriptor
downSet device power down if true, power up otherwise
Returns
ESP_OK on success

◆ hx711_read_average()

esp_err_t hx711_read_average ( hx711_t * dev,
size_t times,
int32_t * data )

Read average data.

Parameters
devDevice descriptor
timesCount of samples to read
[out]dataAverage ADC data
Returns
ESP_OK on success

◆ hx711_read_data()

esp_err_t hx711_read_data ( hx711_t * dev,
int32_t * data )

Read raw data from device.

Please call this function only when device is ready, otherwise communication errors may occur

Parameters
devDevice descriptor
[out]dataRaw ADC data
Returns
ESP_OK on success

◆ hx711_set_gain()

esp_err_t hx711_set_gain ( hx711_t * dev,
hx711_gain_t gain )

Set device gain and channel.

Parameters
devDevice descriptor
gainGain + channel value
Returns
ESP_OK on success, ESP_ERR_TIMEOUT if device not found

◆ hx711_wait()

esp_err_t hx711_wait ( hx711_t * dev,
size_t timeout_ms )

Wait for device to become ready.

Parameters
devDevice descriptor
timeout_msMaximum time to wait, milliseconds
Returns
ESP_OK on success