Did I brick my Ard Nano ESP32?

Andre123
Posts: 2
Joined: Tue Feb 27, 2024 2:47 pm

Did I brick my Ard Nano ESP32?

Postby Andre123 » Tue Feb 27, 2024 3:13 pm

Hi everyone,

my project is a location tracker which is supposed to be in deepsleep most of the time and wake up when moved. To do so I connected my Arduino Nano ESP32 to an MPU6050. The sketch is based on the magic push button (basically a wake-on-motion interrupt with a certain threshold) in this article:

https://wolles-elektronikkiste.de/en/mp ... ope#anker5

and modified with ChatGPT to include a deepsleep / wake-up routine:

Code: Select all

#include "Wire.h" 

#define MPU6050_ADDR              0x68
#define MPU6050_PWR_MGT_1         0x6B 
#define MPU6050_INT_ENABLE        0x38
#define MPU6050_WOM_EN            0x06 
#define MPU6050_WOM_THR           0x1F 

byte interruptPin = 2;

void setup() {
  Serial.begin(9600);
  
  Wire.begin();
  writeRegister(MPU6050_PWR_MGT_1, 0);
  setInterrupt(1); // Set Wake-on-Motion Interrupt Threshold
  
  pinMode(interruptPin, INPUT);
  attachInterrupt(digitalPinToInterrupt(interruptPin), motionInterrupt, RISING);
  
  // Set timer to go back into deep sleep after 10 seconds
  esp_sleep_enable_timer_wakeup(10 * 1000000); // 10 seconds converted to microseconds
  esp_deep_sleep_start();
}

void loop() {
  // This code won't be executed after waking up
}

void setInterrupt(byte threshold){
  writeRegister(MPU6050_WOM_THR, threshold); // Set Wake-on-Motion Threshold
  writeRegister(MPU6050_INT_ENABLE, 1 << MPU6050_WOM_EN); // Enable the interrupt
}

void writeRegister(uint16_t reg, byte value){
  Wire.beginTransmission(MPU6050_ADDR);
  Wire.write(reg);
  Wire.write(value);
  Wire.endTransmission();
}

void motionInterrupt() {
  Serial.println("ESP32 has been woken up!");
  delay(100); // Short delay to ensure the serial print completes
}

In short the code sets a sensitivity threshold (1-255) in the registry of the MPU6050 and then sends the Arduino to deep sleep. When the threshold is exceeded, the interrupt is triggered and the function motionInterrupt() executed. 10 seconds later, the Nano is going back to sleep.
I uploaded the code and the Nano seems to turn on every 10 sec, which is what I expected (sensi = 1).

Problem now is that my Windows PC doesnt recognize the Arduino anymore and I cant upload new code to it.
I tried all the available ports put always get the error message:

No DFU capable USB device available.
exit status 74

When connecting a different Nano ESP32 everything works and Port COM9 is automativally chosen. With the "broken" one, Port COM9 is not even an option in the list.

Is there a way to solve this?

Thanks in advance! Let me know if you need any more info.

ESP_Sprite
Posts: 9052
Joined: Thu Nov 26, 2015 4:08 am

Re: Did I brick my Ard Nano ESP32?

Postby ESP_Sprite » Wed Feb 28, 2024 2:17 am

You put your chip into deep sleep mode almost immediately, and that will kill the USB-serial-JTAG converter functionality, so you won't get an USB connection anymore. The way around it is by forcing the ESP32 into download mode: if you make GPIO0 low and reset the board, you should be able to program it again. Note that after programming, you need to manually reset the board (with GPIO0 high or floating) to run your sketch.

Andre123
Posts: 2
Joined: Tue Feb 27, 2024 2:47 pm

Re: Did I brick my Ard Nano ESP32?

Postby Andre123 » Wed Feb 28, 2024 9:40 am

Thanks for the help!

Just so I get this right, because I'm a rookie:

I bring GPIO0 low by shorting it to ground with a resistor (10k?),
then press the reset button
then upload some blink sketch
then remove the short to ground at GPIO0, so it is high/floating (or even connect directly to 3.3V?)
Then reset again.

Is that correct?

Follow up question: Is 10 seconds not enough time before going into sleep mode? Can you give an estimate how much time would be sufficient?

ESP_Sprite
Posts: 9052
Joined: Thu Nov 26, 2015 4:08 am

Re: Did I brick my Ard Nano ESP32?

Postby ESP_Sprite » Fri Mar 01, 2024 5:47 am

Andre123 wrote:
Wed Feb 28, 2024 9:40 am
Follow up question: Is 10 seconds not enough time before going into sleep mode? Can you give an estimate how much time would be sufficient?
That is not what your code is doing. Your code sets a timer to wake the ESP up 10 seconds after it has gone to sleep, and then it goes to sleep immediately.

Who is online

Users browsing this forum: No registered users and 98 guests