bogde / HX711

An Arduino library to interface the Avia Semiconductor HX711 24-Bit Analog-to-Digital Converter (ADC) for Weight Scales.
MIT License
876 stars 535 forks source link

Why does my arduino reboot after placing a function "delay()"? #235

Open diogo-paula opened 2 years ago

diogo-paula commented 2 years ago

I've been trying for days to make the arduino not restart by itself while it does multiple weighing, always a few minutes after I initialize the arduino, it ends up restarting by itself for no reason.

I already checked if my code is leaking memory, I changed the load cells, I changed the power supply of my arduino, I tested it on multiple computers to see if the USB was the problem, I even tried to turn off whatdog, but without success.

The closest I came to reproducing the problem was with this code, it literally restarts my arduino by itself after run 4 times inside loop() function.

I using arduino-cli/vim for development and stty/cat for view serial output.

--------------- CODE ----------------------------

`#include

define MIN_WEIGHT 1 // 0.001 Kg

define LOADCELL_DT 2

define LOADCELL_SNK 3

define LOADCELL_SCALE 480.1

define LOADCELL_GAIN 128

define LOADCELL_TARE 600

define SERIAL_RATE 9600

HX711 loadcell;

void setup_loadcell(){ loadcell.begin(LOADCELL_DT, LOADCELL_SNK); Serial.print(F("Tare...\n")); loadcell.tare(LOADCELL_TARE); loadcell.set_scale(LOADCELL_SCALE); loadcell.set_gain(LOADCELL_GAIN); }

void setup() { Serial.begin(SERIAL_RATE); setup_loadcell(); Serial.print(F("Setup ok!\n")); }

void loop(){ delay(100); if(loadcell.get_units() > MIN_WEIGHT){ // REMOVE < 0 GRAMS SAMPLES Serial.print(F("Starting!\n")); } }`

---------- OUTPUT TERMINAL ----------

terminal