#include "HX711.h" // ---------- Pin Definitions ---------- #define HX711_DT A1 // D1 #define HX711_SCK A0 // D0 // ---------- HX711 Setup ---------- HX711 scale; float calibration_factor = 2280.0f; // ---------- Timing ---------- unsigned long lastRead = 0; const unsigned long READ_INTERVAL = 200; // ms // Turn this ON for debug text in Serial Monitor. // Turn OFF for clean Plotter-only output. #define DEBUG 0 void setup() { Serial.begin(115200); delay(300); #if DEBUG Serial.println("Initializing HX711..."); #endif scale.begin(HX711_DT, HX711_SCK); scale.set_scale(calibration_factor); scale.tare(); #if DEBUG Serial.println("HX711 ready. Reading continuously...\n"); #endif } void loop() { unsigned long now = millis(); if (now - lastRead >= READ_INTERVAL) { lastRead = now; if (scale.is_ready()) { float weight = scale.get_units(4); #if DEBUG Serial.print("Weight (grams): "); Serial.println(weight); #endif // ----- SERIAL PLOTTER SAFE ----- // ONLY print the number — nothing else Serial.println(weight); } else { #if DEBUG Serial.println("HX711 not ready"); #endif // Output zero so plotter line continues Serial.println(0); } } }