Hi everyone, I have a problem with the arduino's board for a red led blink after a download of a new sketch from IDE.
Has someone had the same problem as me?
I guess it`s just a signal that the arduino is resetting.The same thing happens to me with my ESP32_Dev_Module
I researched this problem and found "set bootloader mode" as a solution.
Buy what is it?
Hi @adtechn. A 4X short, 4X long blink pattern of the red is the signal that the GIGA R1 WiFi board's Mbed OS operating system has crashed.
If you see this blink pattern, it means there is a bug in your code that is crashing the operating system that runs in the background of your sketch program. If you post your code here on the forum, the helpers can take a look at the code and see if we can spot the problem that is causing the crash.
It is not really a solution. Instead it is a way you can recover the board to a state where you can upload a sketch to it. But if the sketch you upload has the same bug, then the crash will just happen again.
This is the code that I writed on Cloud.
It is about usage of a umidity soil sensor for an intelligent agricultural system.
#include "thingProperties.h"
int pin = 13;
void setup() {
Serial.begin(9600);
delay(1500);
initProperties();
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
pinMode (pin, OUTPUT);
}
void loop() {
ArduinoCloud.update();
sensor = analogRead (umidit);
Serial.println (sensor);
delay (100);
if (sensor<300){
digitalWrite (pin, HIGH);
while (sensor<360){
digitalWrite (pin, HIGH);
status = true;
}
}
else {
digitalWrite (pin, LOW);
status = false;
}
percentuale = map(sensor, 0, 1023, 0 ,100);
}
void onStatusChange() {
}
void onPercentualeChange() {
}
With this code I can't see sensor value on serial monitor and on the dashboard and after the blink start.
Thank you very much for the help.
Where is the umidit
variable defined?
Forgive me I made a mistake in copying the code. It’s before :
Include <thingProperties.h>
Please provide the full code.
#define umidit A1
#include "thingProperties.h"
int pin = 13;
void setup() {
Serial.begin(9600);
delay(1500);
initProperties();
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
pinMode (pin, OUTPUT);
}
void loop() {
ArduinoCloud.update();
sensor = analogRead (umidit);
Serial.println (sensor);
delay (100);
if (sensor<300){
digitalWrite (pin, HIGH);
while (sensor<360){
digitalWrite (pin, HIGH);
status = true;
}
}
else {
digitalWrite (pin, LOW);
status = false;
}
percentuale = map(sensor, 0, 1023, 0 ,100);
}
void onStatusChange() {
}
void onPercentualeChange() {
}
Does the red LED blink persistently in a 4X long, 4X short pattern after you upload that sketch to your GIGA R1 WiFi board?
I just gave it a try with my GIGA R1 WiFi and it does not cause the red LED to blink.
I don't know why but it couldn't work before. I will update you on the tests. Thank you very much for your help.
In the moment that I downoload the code on the board and put the sensor in the agricultural land, I can't read on the dashboard the sensor value. The board,
at intervals turns off the relay that I connected to pin 13 in an anomalous way, emitting, if connected to the PC, the sound of disconnection from it and then turning it on again.
Then I download this code from IDE :
int suolo;
int led = 13;
void setup() {
Serial.begin (9600);
pinMode (led, OUTPUT);
}
void loop() {
suolo = analogRead (A1);
Serial.println ( suolo);
delay (100);
if (analogRead(suolo)< 500){
digitalWrite (led, HIGH);
} else{
digitalWrite (led, LOW);
}
}
With this code arduino doesn't disconneted but in the moment that I touch the sensor the blink start.
I see the problem here:
You are passing the value you read from pin A1
as the pin mode argument to the second analogRead
function call.
This means your code is doing things like this:
analogRead(234);
There is no Arduino pin number 234, so this nonsensical code crashes Mbed OS.
I think you meant to write this instead:
In your opinion this has damaged Arduino?
No, there isn't any damage.
Thank you very much, I will update you Afterhours the test .
Is this true for crashes on the M4 as well as M7?
I'm not very knowledgeable in this subject area so maybe someone else will be able to provide a better answer to your question.
I just performed an experiment by uploading this nasty little sketch (which produces the Mbed crash blink pattern on the M7 core) to the M4 core:
void setup() {
volatile byte foo = 1 / 0; // The variable must be volatile to prevent it from being optimized out.
}
void loop() {}
And this standard sketch to the M7 core:
#include <RPC.h>
void setup() {
RPC.begin(); //boots M4
}
void loop() {}
And I don't get any blink pattern. So perhaps it would be limited to a situation where a problem with the program on the M4 core produced conditions that caused Mbed OS to crash on the M7 core.
In my experience M4 crashes do not flash the LEDs, however mbed_die()
is called. I've included this on the M4 to flash the same 4x4 pattern in white (with a reset of the board)
MBED_NORETURN void mbed_die () {
gpio_t led_red, led_grn, led_blu;
gpio_init_out(&led_red, LED_RED);
gpio_init_out(&led_grn, LED_GREEN);
gpio_init_out(&led_blu, LED_BLUE);
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 4; ++j) {
gpio_write(&led_red, 0); gpio_write(&led_grn, 0); gpio_write(&led_blu, 0);
wait_us(150000);
gpio_write(&led_red, 1); gpio_write(&led_grn, 1); gpio_write(&led_blu, 1);
wait_us(150000);
}
for (int j = 0; j < 4; ++j) {
gpio_write(&led_red, 0); gpio_write(&led_grn, 0); gpio_write(&led_blu, 0);
wait_us(400000);
gpio_write(&led_red, 1); gpio_write(&led_grn, 1); gpio_write(&led_blu, 1);
wait_us(400000);
}
}
NVIC_SystemReset();
}
I believe it's because LED1 isn't declared on the M4 as it just includes pins_arduino.h whereas the M7 is patched into mbed and does have LED1 defined. From mbed_board.c
while (1) {
#ifdef LED1
for (int i = 0; i < 4; ++i) {
gpio_write(&led_err, 1);
wait_us(150000);
gpio_write(&led_err, 0);
wait_us(150000);
}
for (int i = 0; i < 4; ++i) {
gpio_write(&led_err, 1);
wait_us(400000);
gpio_write(&led_err, 0);
wait_us(400000);
}
#endif
}
}