2
\$\begingroup\$

If I connect my ESP32 board to my PC via USB and upload any code via the Arduino IDE, all works fine.

Even if I disconnect the USB cable, when I reconnect it, the ESP32 board restarts and works perfectly.

If I disconnect the USB cable and power the ESP32 board by means a reliable power source (https://www.tek.com/en/products/keithley/dc-power-supplies/2220-2230-2231-series) either from Vin (5V) or 3.3 V, the ESP32 board doesn't work in any way even though the onboard LED is ON.

In detail:

The ESP32 acts as a BLE server to which a BLE client is connected configured on another ESP32 board running under Home Assistant.

Powering via USB, the BLE server sends data to the BLE client on Home Assistant. When I disconnect the USB cable from the PC and connect the ESP32 to an external power source it stops sending data in any way.

Any idea?

    void setup() 
{
  Serial.begin(115200);
  pinMode(25,OUTPUT);

  Serial.println("Visualizza quanto trasmesso dal BLE Client a questo BLE Server: ");
 
  BLEDevice::init("MyESP32-Cosimo");
  BLEServer *pServer = BLEDevice::createServer();

  BLEService *pService = pServer->createService(SERVICE_UUID);

  BLECharacteristic *pCharacteristic = pService->createCharacteristic(
                                         CHARACTERISTIC_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );

  pCharacteristic->setCallbacks(new MyCallbacks());

  //pCharacteristic->setValue("Hello World");
  std::string value = "Hello World";
  pCharacteristic->setValue(value);
  pService->start();

  BLEAdvertising *pAdvertising = pServer->getAdvertising();
  pAdvertising->start();
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(2000);
}

enter image description here

enter image description here

\$\endgroup\$
13
  • \$\begingroup\$ More information is needed. Assuming you are using an ESP32 devboard, which one is it ? What is the Vin that you are referring to ? \$\endgroup\$
    – mpetitjean
    Feb 8, 2022 at 10:53
  • \$\begingroup\$ @mpetitjean You're right. I've just added a photo... \$\endgroup\$
    – M4Biz
    Feb 8, 2022 at 11:03
  • 1
    \$\begingroup\$ What does "it doesn't work" mean? The lights are on as you expect, so what behavior indicates to you a problem? Please describe in detail the expected and observed behaviors. \$\endgroup\$
    – TypeIA
    Feb 8, 2022 at 11:23
  • 2
    \$\begingroup\$ Do you by any chance have something like while (!Serial) ; in your setup or loop? \$\endgroup\$
    – DamienD
    Feb 8, 2022 at 11:30
  • 1
    \$\begingroup\$ To debug things further I would blink the LED in the loop function, so you know if it's actually running. \$\endgroup\$
    – DamienD
    Feb 8, 2022 at 15:17

1 Answer 1

1
\$\begingroup\$

Problem solved.

It was only a bad ESP32 board .

It works when powered by USB and don't in anyway if powered by external source. Replacing it with a new, identical, board, it works fine even if is powered by 5V than 3,3 V.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.