#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <HX711_ADC.h> // https://github.com/olkal/HX711_ADC
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define SCREEN_I2C_ADDRESS 0X3C
#define OLED_RESET_PIN -1
Adafruit_SSD1306 lcd(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET_PIN);
HX711_ADC LoadCell1(3, 2); // dt pin, sck pin
HX711_ADC LoadCell2(4, 2);
HX711_ADC LoadCell3(5, 2);
// HX711_ADC LoadCell4(6, 2);
// HX711_ADC LoadCell5(7, 2);
// HX711_ADC LoadCell6(8, 2);
// HX711_ADC LoadCell7(9, 2);
int taree = 13;
int a = 0;
float b = 0;
void setup() {
lcd.begin(SSD1306_SWITCHCAPVCC, SCREEN_I2C_ADDRESS);
lcd.clearDisplay();
lcd.setTextColor(WHITE, BLACK);
lcd.setTextSize(1);
pinMode (taree, INPUT_PULLUP);
LoadCell1.begin(); // start connection to HX711
LoadCell2.begin();
LoadCell3.begin();
// LoadCell4.begin();
// LoadCell5.begin();
// LoadCell6.begin();
// LoadCell7.begin();
LoadCell1.start(1000); // load cells gets 1000ms of time to stabilize - move to loop
LoadCell2.start(1000);
LoadCell3.start(1000);
// LoadCell4.start(1000);
// LoadCell5.start(1000);
// LoadCell6.start(1000);
// LoadCell7.start(1000);
///////////////////////////////////// Load Cell Sequence 1-n from the bottom
LoadCell1.setCalFactor(-2200);
LoadCell2.setCalFactor(-2257);
LoadCell3.setCalFactor(-2110);
// LoadCell4.setCalFactor(-2265);
// LoadCell5.setCalFactor(-2411);
// LoadCell6.setCalFactor(-2257);
// LoadCell7.setCalFactor(-2200);
/////////////////////////////////////
}
void loop() {
LoadCell1.update(); // retrieves data from the load cell
float w1 = LoadCell1.getData();
GetScale(LoadCell1, w1, 1, 5, 15);
LoadCell2.update();
float w2 = LoadCell2.getData();
GetScale(LoadCell2, w2, 2, 5, 25);
LoadCell3.update();
float w3 = LoadCell3.getData();
GetScale(LoadCell3, w3, 3, 5, 35);
// LoadCell4.update();
// float w4 = LoadCell4.getData();
// GetScale(LoadCell4, w4, 4, 5, 45);
// LoadCell5.update();
// float w5 = LoadCell5.getData();
// GetScale(LoadCell5, w5, 5, 5, 55);
// LoadCell6.update();
// float w6 = LoadCell6.getData();
// GetScale(LoadCell6, w6, 6, 5, 45);
// LoadCell7.update();
// float w7 = LoadCell7.getData();
// GetScale(LoadCell7, w7, 7, 5, 55);
}
void GetScale(HX711_ADC LoadCell, float weight, int sensorNum, int x, int y){
// Make weight positive for display
if (weight < 0) {
weight = -weight;
}
// lcd weight in grams
lcd.setCursor(x, y);
lcd.print(weight, 1);
lcd.print("g");
// Tare (zeroing)
if (digitalRead (taree) == LOW)
}
20 cms standard male-male jumper wires running through a breadboard so Vcc, Gnd & Clk can be shared to save pins on the board.