asukiaaa / arduino-hx711 Goto Github PK
View Code? Open in Web Editor NEWA library for Arduino to read value from HX711 amplifier module for load cell.
License: MIT License
A library for Arduino to read value from HX711 amplifier module for load cell.
License: MIT License
#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include <HX711_asukiaaa.h>
int pinsDout[] = {5, 6, 7, 8};
const int numPins = sizeof(pinsDout) / sizeof(pinsDout[0]);
int pinSlk = 4;
HX711_asukiaaa::Reader reader(pinsDout, numPins, pinSlk);
//---------------------------------------------------//
// Load cell SC133 20kg
// https://akizukidenshi.com/catalog/g/gP-12034/
//---------------------------------------------------//
#define LOAD_CELL_RATED_VOLT_20FLKG 0.0019f
#define LOAD_CELL_RATED_GRAM_20FLKG 20000.0f
#define LOAD_CELL_RATED_VOLT_20FRKG 0.002f
#define LOAD_CELL_RATED_GRAM_20FRKG 20000.0f
#define LOAD_CELL_RATED_VOLT_20RLKG 0.002f
#define LOAD_CELL_RATED_GRAM_20RLKG 20000.0f
#define LOAD_CELL_RATED_VOLT_20RRKG 0.002f
#define LOAD_CELL_RATED_GRAM_20RRKG 20000.0f
#define HX711_R1 20000.0
#define HX711_R2 8200.0
HX711_asukiaaa::Parser parser20FLkg(LOAD_CELL_RATED_VOLT_20FLKG,
LOAD_CELL_RATED_GRAM_20FLKG, HX711_R1,
HX711_R2);
HX711_asukiaaa::Parser parser20FRkg(LOAD_CELL_RATED_VOLT_20FRKG,
LOAD_CELL_RATED_GRAM_20FRKG, HX711_R1, HX711_R2);
HX711_asukiaaa::Parser parser20RLkg(LOAD_CELL_RATED_VOLT_20RLKG,
LOAD_CELL_RATED_GRAM_20RLKG, HX711_R1, HX711_R2);
HX711_asukiaaa::Parser parser20RRkg(LOAD_CELL_RATED_VOLT_20RRKG,
LOAD_CELL_RATED_GRAM_20RRKG, HX711_R1, HX711_R2);
HX711_asukiaaa::Parser* parsers[numPins] = {
&parser20FLkg, &parser20FRkg,
&parser20RLkg, &parser20RRkg,
};
float offsetGrams[numPins];
float Grams[numPins];
void setup() {
Serial.begin(9600);
Serial.println("start");
reader.begin();
for (int i = 0; i < reader.doutLen; ++i) {
offsetGrams[i] = parsers[i]->parseToGram(reader.values[i]);
}
{
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("benvenuti in ");
lcd.setCursor(0, 1);
lcd.print("Italia");
delay (3000);
String BLANK = " ";
lcd.setCursor(0, 0);
lcd.print( BLANK );
lcd.setCursor(0, 1);
lcd.print( BLANK );
}
}
void loop() {
auto readState = reader.read();
Serial.println("ReadState: " + HX711_asukiaaa::getStrOfReadState(readState));
if (readState == HX711_asukiaaa::ReadState::Success) {
for (int i = 0; i < reader.doutLen; ++i) {
auto parser = *parsers[i];
float gram = parser.parseToGram(reader.values[i]) - offsetGrams[i];
Serial.print("sensor" + String(i) + ": " + String(gram ) + " g ");
Serial.print("offset: " + String(offsetGrams[i]) + " g ");
Serial.print("voltage: " +
String(parser.parseToGram(reader.values[i])) + " uV ");
Serial.print(String(parser.parseToGram(reader.values[i]) / 1000) +
" mV ");
Serial.println("");
}
Serial.println("at " + String(millis()));
Serial.println("");
}
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("FL" "g");
lcd.setCursor(8, 0);
lcd.print("FR" "g");
lcd.setCursor(0, 1);
lcd.print("RL" "g");
lcd.setCursor(8, 1);
lcd.print("RR" "g");
}
とても親切に回答ありがとうございます
現時点ではこのような状態です
forの中でgrams[i]に解釈した重さ情報を代入してとはどうしたらいいのですか
Hi,
I'm trying to use an Adafruit Feather ESP32, with 8 HX711.
My Pinsetup is like this:
int pinsDout[] = {18,5,4,36,21,17,16,19};
const int numPins = sizeof(pinsDout) / sizeof(pinsDout[0]);
int pinSlk = 14;
It works quite well, thank you for this library :)
however, i get some weird peaks from time to time:
Do you have an explanation for this? How can I get rid of them?
Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.