ESP32 Dev V1 stops running program after unplugging USB

The Program below works perfectly with a good wifi connection and operating through a Blynk Device with a couple of sliders and an LED.
The ESP is powered externally.
I also have a larger project that is much more complex, that works perfectly, as long as the USB cable is plugged in.
As soon as the Cable is disconnected from the DevKit, The program stops executing!
According to the Blynk App, the WiFi Is still connected.
I am really stuck trying to figure this one out. Anybody ever run in to this problem?

#include <Arduino.h>
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>

#define BLYNK_TEMPLATE_ID "TMPLm9Jxxxxx"
#define BLYNK_TEMPLATE_NAME "ESP8266TRUCKBLYNK"
#define BLYNK_AUTH_TOKEN "xxx_xxx"
#define BLYNK_PRINT Serial
#define RAINING 2

int rainLed = 0;
int tempset = 50; //Temp Threshold Value
int humidset = 55; // Humidity Threshold Value
int tempValue; // Temp Slider Value returned by Blynk
int humidValue;  // Humidity Slider Value

char auth[] = BLYNK_AUTH_TOKEN;
//char ssid[] = "NETGEAR44-pro";  // type your wifi name
char ssid[] = "NETGEAR44";  // type your wifi name
char pass[] = "xxxxxxx";  // type your wifi password

// This function creates the timer object. It's part of Blynk library 
BlynkTimer timer; 

void myTimer() 
{
  // This function describes what will happen with each timer tick
  // e.g. writing sensor value to datastream V5
  //VENTED=venteD;
   
  Blynk.virtualWrite(V2, tempset);
  Blynk.virtualWrite(V3, humidset);
  Blynk.virtualWrite(V6, rainLed);
 

}

BLYNK_WRITE(V0)
{   
  tempValue = param.asInt(); // Get value as integer
}
 
BLYNK_WRITE(V1)
{   
  humidValue = param.asInt(); // Get value as integer
 ;
}

void setup() {
  
  pinMode(RAINING,OUTPUT); //onboard Led

  Serial.begin(115200);
  Serial.println("");
  Blynk.begin(auth, ssid, pass);
  Serial.println(F("Connected to Host!"));
  timer.setInterval(500L, myTimer);
  delay(1000);
}

void loop() {
  Blynk.run();
  timer.run();

  rainLed = digitalRead(RAINING);
 
  if (humidValue >= humidset) {
    digitalWrite(RAINING,HIGH);
  }
  else
  {
    digitalWrite(RAINING,LOW);
  }

  Serial.print("Rain LED = ");
  Serial.println(rainLed);
  Serial.println("");
  Serial.print("Humidity Slider Value = ");
  Serial.println(humidValue);
  Serial.println("");

/* 
Code for Temp Comparison
*/
  delay(300);

}


This is definitely a power supply issue. Are you sure that your PS is capable of supplying the power your esp demands? If there are sensors, LED, etc connected to your esp then they demand lot of power.

While you plug in your USB cable, both external PS and USB will be working together to supply power. When you disconnect USB is demands more power and brownout may get triggered.

Also read this :point_down:t2:

Https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean

1 Like

How?
Via the 5v pin, 3.3v pin or via a battery connector on the board?

What type of PSU are you using, and what voltage/current is it supposed to be supplying?

Have you measured exactly what it is actually supplying?

Pete.

I am using a 3.3V 1A Buck Converter.
The voltage on the 3.3v pin of the ESP remains steady at 3.2v when disconnected from the USB cable.
Unless I’m missing something, It does not look like it is a supply issue.

So you’re applying the external power to the 3.3v pin?

Pete.

Yes, But if I just found that if I increase the voltage to 3.7V, It works off the Cable??

You need to have an 0.1uf ceramic cap along with 10uf tantalum capacitor close to vcc and gnd pin to have an steady voltage.

Else you will face erratic reboots and behaviour.

I don’t understand this part of your comment.

Pete.

USB Cable

I will try that. Thank You.

Edited to remove unwanted advice

Pete.

I have tried it both ways 3.3 and 5V.
Your understanding might be enhanced if you read the Title of my post.
I really don’t know how else to say it.

I have read the topic title, and asked numerous questions to try to obtain the real details behind that title.

But, I’ll butt-out and leave you to resolve your issue yourself.

Pete.

If anyone else is having trouble understanding my problem, please let me know.
Thanks.

I think you were right about the Brownout being triggered. I separated the Peripheral 3.3V from the 3.3V pin of the ESP and powered the peripherals with my 3.3V Supply and the processor with 5V through vin.
Working fine now.
Thank you everyone.

1 Like