I have a project that uses a GY-53 BMP180
and ESP32
.
Each time I connect ESP32
to USB after uploading, I get this error:
22:27:27.352 -> rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
22:27:27.394 -> configsip: 0, SPIWP:0xee
22:27:27.394 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
22:27:27.394 -> mode:DIO, clock div:1
22:27:27.394 -> load:0x3fff0030,len:4688
22:27:27.394 -> load:0x40078000,len:15460
22:27:27.394 -> ho 0 tail 12 room 4
22:27:27.394 -> load:0x40080400,len:4
22:27:27.394 -> load:0x40080404,len:3196
22:27:27.394 -> entry 0x400805a4
This is my code:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085_U.h>
#define pwm 2
#define ledPin 5
#define buttonPin 4
#define ledPin3 8
int dastresi = 0;
int buttonState = 0;
int def = 0;
float distance = 0;
float a = 0;
int wap = 0;
int rap = 0;
int vaz = 0;
int vaz2 = 0;
int ekhtelaf = 0;
int b = 0;
int cy = 1;
int c = 0;
int r = 0;
int w = 0;
int d = 0;
int value = 0;
int rate_p = 0;
int vaz_rate = 0;
float rate = 0;
int comp = 0;
Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);
void setup() {
pinMode(pwm, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(buttonPin, INPUT);
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin, LOW);
Serial.begin(115200);
bmp.begin();
}
void loop() {
sensors_event_t event;
bmp.getEvent(&event);
distance = pulseIn(pwm, HIGH) / 10;
ekhtelaf = def - distance;
if (ekhtelaf >= 3) {
comp++;
//dastresi = 1;
}/* else if(ekhtelaf*-1>=3) {
}*/
buttonState = digitalRead(buttonPin);
while (Serial.available()) {
value = Serial.read();
if (value == '1') {
w = r = rap = wap = comp = dastresi = 0;
}
}
if (b == 0) {
a = event.pressure;
b = 1;
}
String output = "";
if (buttonState == HIGH) {
output += "A";
} else {
output += "a";
}
output += "I";
if (distance <= 120 && distance > 95) {
output += "B";
if (c == 1) {
r++;
c = 0;
}
} else {
output += "b";
}
output += "I";
if (distance <= 90) {
output += "C";
if (d == 1) {
w++;
d = 0;
}
} else {
output += "c";
}
output += "I";
if (distance > 130) {
c = 1;
d = 1;
}
if (event.pressure < a + 1) {
vaz = vaz2 = 0;
}
if (event.pressure > a + 2) {
if (event.pressure < a + 5.5) {
output += "D";
if (vaz == 0) {
rap++;
vaz = 1;
}
} else {
output += "d";
}
}else {
output += "d";
}
output += "I";
if (event.pressure > a + 5.5) {
output += "E";
if (vaz2 == 0) {
wap++;
vaz2 = 1;
}
} else {
output += "e";}
output += "I";
output += String(int(r*1.12))+ "I";
output += String(w) + "I";
output += String(rap - wap) + "I";
output += String(wap) + "I";
output += String(distance) + "I";
output += String(event.pressure - a) + "I";
output += String(int(comp*1.2)) + "I";
Serial.println(output);
def = distance;
delay(50);
}
-
1what is your specific question?jsotola– jsotola2025年02月25日 20:08:11 +00:00Commented Feb 25 at 20:08
-
What makes you think this is an error? Looks like the expected output to me.InBedded16– InBedded162025年02月25日 20:17:34 +00:00Commented Feb 25 at 20:17
-
it seems like in loop function there is blocking code which is delaying the refresh of WDT timer. From my understanding while(Serial.available()) is causing this problem.Vaibhav– Vaibhav2025年02月26日 12:06:56 +00:00Commented Feb 26 at 12:06
1 Answer 1
From your code, this was sufficient to cause rst:0x8 (TG1WDT_SYS_RESET)
#define ledPin3 8
void setup() {
pinMode(ledPin3, OUTPUT);
}
void loop() {}
The GPIO documentation shows:
GPIO | Analog Function | RTC GPIO | Comments |
---|---|---|---|
GPIO8 | SPI0/1 |
below which (emphasis added by me):
SPI0/1: GPIO6-11 and GPIO16-17 are usually connected to the SPI flash and PSRAM integrated on the module and therefore should not be used for other purposes.
You need to chose some other pin, avoiding these SPI0/1 pins and maybe the strapping pins as well. These are all mentioned in the link above. Read the table comments and the notes below the table.
TG1WDT_SYS_RESET
is telling you the reset was caused by watchdog timeout. In short, messing with the flash interface IO pin prevented the chip from running code that should and would have tended to the watchdog.