hx711/arduino_strain.ino
2025-11-12 20:27:54 +01:00

59 lines
1.1 KiB
C++

//
// FILE: HX_plotter.ino
// AUTHOR: Rob Tillaart
// PURPOSE: HX711 demo
// URL: https://github.com/RobTillaart/HX711
#include "HX711.h"
#include "TM1637.h"
HX711 scale;
const int tm_clk = 2;
const int tm_dio = 3;
const uint8_t hx_dataPin = A1;
const uint8_t hx_clockPin = A0;
TM1637 tm1637(tm_clk, tm_dio);
float strain;
void setup()
{
// setup display
tm1637.init();
tm1637.set(BRIGHT_TYPICAL);//BRIGHT_TYPICAL = 2,BRIGHT_DARKEST = 0,BRIGHTEST = 7;
tm1637.displayStr((char *)"HI");
delay(1000);
// setup strain gauge amp
Serial.begin(115200);
// Serial.println();
// Serial.println(__FILE__);
// Serial.print("HX711_LIB_VERSION: ");
// Serial.println(HX711_LIB_VERSION);
// Serial.println();
scale.begin(hx_dataPin, hx_clockPin);
scale.set_scale(100); // TODO you need to calibrate this yourself.
tm1637.displayStr((char *)"tArE");
Serial.println("TARE");
scale.tare();
}
void loop()
{
strain = scale.get_units(1);
Serial.println(strain);
tm1637.displayNum(strain);
delay(250);
}
// -- END OF FILE --