Skip to content

Instantly share code, notes, and snippets.

@AdoHaha
Created December 4, 2024 19:48
Show Gist options
  • Save AdoHaha/adcb691a046516f8f10da7db52fcfa52 to your computer and use it in GitHub Desktop.
Save AdoHaha/adcb691a046516f8f10da7db52fcfa52 to your computer and use it in GitHub Desktop.
for_stretchbox_measurement
//
// FILE: HX_plotter.ino
// AUTHOR: Rob Tillaart
// PURPOSE: HX711 demo with two sensors
// URL: https://github.com/RobTillaart/HX711
#include "HX711.h"
HX711 scale1; // First HX711 instance
HX711 scale2; // Second HX711 instance
// Adjust pins if needed
uint8_t dataPin1 = 18;
uint8_t clockPin1 = 19;
uint8_t dataPin2 = 5;
uint8_t clockPin2 = 17;
float reading1;
float reading2;
void setup()
{
Serial.begin(115200);
Serial.println("reading1,reading2");
// Initialize both scales
scale1.begin(dataPin1, clockPin1);
scale2.begin(dataPin2, clockPin2);
// Set scale factors (you need to calibrate these values)
scale1.set_scale(760); // Replace with your calibration factor for scale1
scale2.set_scale(96); // Replace with your calibration factor for scale2
// Tare both scales to zero
scale1.tare();
scale2.tare();
}
void loop()
{
// Get readings from both scales
reading1 = scale1.get_units(5);
reading2 = scale2.get_units(5);
// Print the readings separated by a comma
Serial.print(reading1);
Serial.print(", ");
Serial.println(reading2);
// Delay for readability
// delay(25);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment