Skip to content

Commit

Permalink
update build-CI + badges + readme.md (#10)
Browse files Browse the repository at this point in the history
* update build-CI + badges + readme.md
  • Loading branch information
RobTillaart committed Nov 4, 2021
1 parent b98b728 commit 8b04fa2
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 22 deletions.
10 changes: 7 additions & 3 deletions .arduino-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
- uno
- leonardo
- due
- zero
# - due
# - zero
# - leonardo
- m4
- esp32
# - esp8266
# - mega2560
11 changes: 7 additions & 4 deletions .github/workflows/arduino_test_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ name: Arduino CI
on: [push, pull_request]

jobs:
arduino_ci:
runTest:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
# - uses: Arduino-CI/action@latest
- uses: Arduino-CI/action@master
# Arduino-CI/action@v0.1.1
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: |
gem install arduino_ci
arduino_ci.rb
117 changes: 105 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

[![Arduino CI](https://github.com/RobTillaart/HX711/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/HX711/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/HX711/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/HX711/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/HX711/actions/workflows/jsoncheck.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/HX711/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/HX711.svg?maxAge=3600)](https://github.com/RobTillaart/HX711/releases)

Expand All @@ -11,12 +13,12 @@ Arduino library for HX711 24 bit ADC used for load cells and scales.

## Description

This HX711 library has an interface which is a superset of a library made by bogde.
This HX711 library has an interface which is a superset of a library made by Bogde.
Some missing functions were added to get more info from the lib.

Another important difference is that this library uses floats. The 23 bits mantisse
of the IEE754 float matches the 24 bit ADC very well. Furthermore it gave a smaller
footprint.
Another important difference is that this library uses floats.
The 23 bits mantissa of the IEE754 float matches the 24 bit ADC very well.
Furthermore it gave a smaller footprint.


## Main flow
Expand All @@ -37,22 +39,100 @@ Steps to take for calibration
1. save the offset and scale for later use e.g. EEPROM.


## Pricing
## Interface

Some price functions were added to make it easy to use this library
for pricing goods or for educational purposes. These functions are under discussion
if they will stay. Another set of function to add weights together didn't make it in
the 0.2.0 release, it is on a todo list.

#### Base

- **HX711()** constructor
- **~HX711()**
- **void begin(uint8_t dataPin, uint8_t clockPin)** sets a fixed gain 128 for now.
- **void reset()**
- **bool is_ready()** checks if load-cell is ready to read.
- **void wait_ready(uint32_t ms = 0)** wait until ready, check every ms.
- **bool wait_ready_retry(uint8_t retries = 3, uint32_t ms = 0)** wait max retries.
- **bool wait_ready_timeout(uint32_t timeout = 1000, uint32_t ms = 0)** wait max timeout.
- **float read()** raw read.
- **float read_average(uint8_t times = 10)** get average of times raw reads. times = 1 or more.
- **float read_median(uint8_t times = 7)** get median of multiple raw reads.
times = 3..15 - odd numbers preferred.
- **float read_medavg(uint8_t times = 7)** get average of "middle half" of multiple raw reads.
times = 3..15 - odd numbers preferred.
- **float read_runavg(uint8_t times = 7, float alpha = 0.5)** get running average over times measurements.
The weight alpha can be set to any value between 0 and 1, times >= 1.
- **uint32_t last_read()** returns timestamp in milliseconds.


#### Gain

read datasheet - see also Connections HX711 below
- **void set_gain(uint8_t gain = 128)** values: 128 (default), 64 32 - only 128 tested & verified
- **uint8_t get_gain()** returns set gain.


#### Mode

Get and set the operational mode for get_value() and indirect get_units().
In median and medavg mode only 3..15 samples are allowed.
- **void set_average_mode()**
- **void set_median_mode()**
- **void set_medavg_mode()**
- **void set_runavg_mode()** default alpha = 0.5.
- **uint8_t get_mode()**


#### GET VALUES

get values corrected for offset and scale

- **float get_value(uint8_t times = 1)** read value, corrected for offset.
- **float get_units(uint8_t times = 1)** read value, converted to proper units.
- **void set_scale(float scale = 1.0)** set scale factor; scale > 0.
- **float get_scale()** returns set scale factor.
- **void set_offset(long offset = 0)** idem.
- **long get_offset()** idem.


#### TARE & CALIBRATION

Steps to take for calibration
1. clear the scale
1. call tare() to set the zero offset
1. put a known weight on the scale
1. call calibrate_scale(weight)
1. scale is calculated.
1. save the offset and scale for later use e.g. EEPROM.

- **void tare(uint8_t times = 10)** call tare to calibrate zero level
- **float get_tare()** idem.
- **bool tare_set()** checks if a tare has been set.
- **void calibrate_scale(uint16_t weight, uint8_t times = 10)** idem.


#### POWER MANAGEMENT

- **void power_down()** idem.
- **void power_up()** idem.


#### Pricing

Some price functions were added to make it easy to use this library
for pricing goods or for educational purposes.
These functions are under discussion if they will stay.
For weight conversion functions see https://github.com/RobTillaart/weight

- **float get_price(uint8_t times = 1)** idem.
- **void set_unit_price(float price = 1.0)** idem.
- **float get_unit_price()** idem.


## Notes


### Scale values for loadcells

These scale values worked pretty well with a set of loadcells,
These scale values worked pretty well with a set of load-cells,
Use calibrate to find your values.

- 5 KG loadcell scale.set_scale(420.52);
Expand Down Expand Up @@ -89,9 +169,9 @@ Use calibrate to find your values.

### Temperature

Loadcells do have a temperature related error.
Load-cells do have a temperature related error. (check datasheet)
This can be reduced by doing the calibration and take the tare
at the temperature one also does the measurements.
at the temperature one also uses for the measurements.

Another way to handle this is to add a good temperature sensor
(e.g. DS18B20, SHT85) and compensate for the temperature
Expand All @@ -101,3 +181,16 @@ differences in your code.
## Operation

See examples


## Future

- update documentation
- add examples
- test different load-cells


#### the adding scale

- void weight_clr(), void weight_add(), float weight_get() - adding scale

11 changes: 8 additions & 3 deletions keywords.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Syntax Coloring Map For HX711
# Syntax Colouring Map For HX711

# Datatypes (KEYWORD1)
# Data types (KEYWORD1)
HX711 KEYWORD1

# Methods and Functions (KEYWORD2)
Expand All @@ -16,6 +16,7 @@ read KEYWORD2
read_average KEYWORD2
read_median KEYWORD2
read_medavg KEYWORD2
read_runavg KEYWORD2

set_average_mode KEYWORD2
set_median_mode KEYWORD2
Expand Down Expand Up @@ -51,6 +52,10 @@ get_unit_price KEYWORD2

# Instances (KEYWORD2)


# Constants (LITERAL1)
HX711_LIB_VERSION LITERAL1

HX711_AVERAGE_MODE LITERAL1
HX711_MEDIAN_MODE LITERAL1
HX711_MEDAVG_MODE LITERAL1
HX711_RUNAVG_MODE LITERAL1

0 comments on commit 8b04fa2

Please sign in to comment.