Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
diogo-paula opened this issue Apr 18, 2022 · 0 comments
Open

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

diogo-paula opened this issue Apr 18, 2022 · 0 comments

Comments

@diogo-paula
Copy link

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 <HX711.h>

#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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant