Skip to content

File syn_scale.h

FileList > sensor > syn_scale.h

Go to the source code of this file

Generic Weight Scale & Load Cell Driver (HX711 24-bit ADC, NAU7802).

  • #include "../common/syn_defs.h"
  • #include "../port/syn_port_gpio.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_Scale
Generic Weight Scale Instance Context.

Public Types

Type Name
enum SYN_ScaleType
Load Cell ADC IC Type.

Public Functions

Type Name
void syn_scale_feed_adc (SYN_Scale * scale, int32_t raw_adc24)
Feed raw 24-bit ADC reading from load cell chip.
float syn_scale_get_grams (const SYN_Scale * scale)
Get calculated weight in grams.
float syn_scale_get_kg (const SYN_Scale * scale)
Get calculated weight in kilograms.
SYN_Status syn_scale_init (SYN_Scale * scale, SYN_GPIO_Pin dout_pin, SYN_GPIO_Pin sck_pin, SYN_ScaleType type)
Initialize Weight Scale context.
void syn_scale_set_calibration_factor (SYN_Scale * scale, float factor)
Set calibration scale factor (counts per gram).
void syn_scale_tare (SYN_Scale * scale, int32_t tare_offset)
Set zero-point Tare offset.

Public Types Documentation

enum SYN_ScaleType

Load Cell ADC IC Type.

enum SYN_ScaleType {
    SYN_SCALE_HX711 = 0,
    SYN_SCALE_NAU7802 = 1
};


Public Functions Documentation

function syn_scale_feed_adc

Feed raw 24-bit ADC reading from load cell chip.

void syn_scale_feed_adc (
    SYN_Scale * scale,
    int32_t raw_adc24
) 

Parameters:

  • scale Scale context.
  • raw_adc24 Signed 24-bit raw ADC reading.

function syn_scale_get_grams

Get calculated weight in grams.

float syn_scale_get_grams (
    const SYN_Scale * scale
) 

Parameters:

  • scale Scale context.

Returns:

Weight in grams.


function syn_scale_get_kg

Get calculated weight in kilograms.

float syn_scale_get_kg (
    const SYN_Scale * scale
) 

Parameters:

  • scale Scale context.

Returns:

Weight in kg.


function syn_scale_init

Initialize Weight Scale context.

SYN_Status syn_scale_init (
    SYN_Scale * scale,
    SYN_GPIO_Pin dout_pin,
    SYN_GPIO_Pin sck_pin,
    SYN_ScaleType type
) 

Parameters:

  • scale Scale context.
  • dout_pin Data GPIO pin (or SDA for I2C).
  • sck_pin Clock GPIO pin (or SCL for I2C).
  • type Scale ADC type (HX711 or NAU7802).

Returns:

SYN_OK on success.


function syn_scale_set_calibration_factor

Set calibration scale factor (counts per gram).

void syn_scale_set_calibration_factor (
    SYN_Scale * scale,
    float factor
) 

Parameters:

  • scale Scale context.
  • factor Calibration factor (e.g. 420.0f counts/gram).

function syn_scale_tare

Set zero-point Tare offset.

void syn_scale_tare (
    SYN_Scale * scale,
    int32_t tare_offset
) 

Parameters:

  • scale Scale context.
  • tare_offset Zero reading value.


The documentation for this class was generated from the following file src/syntropic/sensor/syn_scale.h