Please... how do you ground an ESP properly?

simontpellier
Posts: 2
Joined: Thu May 25, 2023 10:32 am

Please... how do you ground an ESP properly?

Postby simontpellier » Fri Jun 09, 2023 5:15 pm

Hello all,
I've often had stability problems with EPS but this time it's catastrophic and I'm looking for a cute trick....

The new, today, is the use of the deep sleep mode. So, depending how the ESP is powered, the code works perfectly, or sometimes, or... not at all!
Here's as an example a little sketch combining interrupt and deep sleep (with wake-up by ext1 because in real life (mine), three GPIOs are involved - here only one with its external pulldown)

The three cases:
- like a charm : USB-powered ESP + battery-powered PC (=> only wakes up via pushbutton, as expected).
- a few unexpected wake-ups : USB-powered and PC on charger. Wakes up particularly when GND connections are teased.
- continuous resets arghhh.... ESP powered by a 220AC->24DC converter (https://fr.aliexpress.com/item/10050048 ... pt=glo2fra)
then a 5V buck.
In fact, the sketch sometimes manages to complete the setup and to fall asleep, but then you just have TO MOVE YOUR HAND CLOSER to the wiring to get the awakening !

Does anyone know a cure for this diabolical grounding issue?
(I tried the advice I read in the forum to put a 100uF capa between EN and GND, but no difference).
My project is completely blocked at the moment (well, not quite, because with an Arduino Nano, its sleep_cpu function wake-ups by interrupts... there's no problem whatsoever !) so many thanks in advance for any recipes !

Philippe

Code: Select all

const uint16_t PUSHER = 2;
volatile unsigned long timer;
bool setRequired = false;
bool settingDone = false;
const uint16_t SETTING_DELAY = 2500;
RTC_DATA_ATTR uint8_t variable = 50; /* initiated here then saved during deep-sleep */ 

#define BUTTON_PIN_BITMASK 0x000000004

void setup() {
  Serial.begin(115200);
  delay(300);
  Serial.println("Serial is OK");

  attachInterrupt(digitalPinToInterrupt(PUSHER), settingAction, RISING);

  esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK, ESP_EXT1_WAKEUP_ANY_HIGH);
  uint64_t GPIO_actuated = esp_sleep_get_ext1_wakeup_status();
  GPIO_actuated = log(GPIO_actuated)/log(2);
      switch (GPIO_actuated) {
        case PUSHER :
            Serial.println("! A pusher press asked for a new setting !... press anew to set or wait");
            settings();
        default : break;
      }
  
  settings();
}

void settingAction() { /* INTERRUPT pin2 - during setting phase only */
  if (!timer) /*=>*/ timer = millis();
  setRequired = true;
}

void settings() {
  timer = millis();  

  while (!settingDone) {
    if (millis()-timer<SETTING_DELAY) {
      if (setRequired) {
        variable +=10;
        if (variable==110) /*=>*/ variable = 0;
        delay(250); // (debounce)
        timer = millis();
        setRequired = false;
        Serial.printf("new_set %u\n", variable);
      }
    }
    else /*=>*/ settingDone = true;
  }

  detachInterrupt(digitalPinToInterrupt(PUSHER));
  Serial.println("pusher pressed => new setup, else READY FOR USE"); Serial.flush();
  esp_deep_sleep_start(); /* goes now to deep sleep */  
}

void loop() {}
Attachments
CameraZOOM-20230609182347295.jpg
not complicated is'nt it!
CameraZOOM-20230609182347295.jpg (565.38 KiB) Viewed 1720 times

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

Re: Please... how do you ground an ESP properly?

Postby ESP_Sprite » Sun Jun 11, 2023 2:59 am

Are you sure that pulldown is actually connected? What value is it, and if it's high, can you use a lower value, e.g. 1K or so?

Who is online

Users browsing this forum: Google [Bot] and 91 guests