hx711 - Driver for HX711 24-bit ADC for weigh scales

group hx711

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

Copyright (C) 2019 Ruslan V. Uss unclerus@gmail.com

BSD Licensed as described in the file LICENSE

Enums

enum hx711_gain_t

Gain/channel.

Values:

enumerator HX711_GAIN_A_128

Channel A, gain factor 128.

enumerator HX711_GAIN_B_32

Channel B, gain factor 32.

enumerator HX711_GAIN_A_64

Channel A, gain factor 64.

Functions

esp_err_t hx711_init(hx711_t *dev)

Initialize device.

Prepare GPIO pins, power up device and set gain

Return

ESP_OK on success, ESP_ERR_TIMEOUT if device not found

Parameters
  • dev: Device descriptor

esp_err_t hx711_power_down(hx711_t *dev, bool down)

Set device power up/down.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • down: Set device power down if true, power up otherwise

esp_err_t hx711_set_gain(hx711_t *dev, hx711_gain_t gain)

Set device gain + channel.

Return

ESP_OK on success, ESP_ERR_TIMEOUT if device not found

Parameters
  • dev: Device descriptor

  • gain: Gain + channel value

esp_err_t hx711_is_ready(hx711_t *dev, bool *ready)

Check if device ready to send data.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • ready: true if data ready

esp_err_t hx711_wait(hx711_t *dev, size_t timeout_ms)

Wait for device to become ready.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • timeout_ms: Maximum time to wait, milliseconds

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

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • data: Raw ADC data

struct hx711_t
#include <hx711.h>

Device descriptor.