espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.51k stars 7.39k forks source link

How can I turn off the radio on ESP32? #1077

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hi, I need, in order to save battery, turn off the radio and the BLE. How can I do that on Arduino IDE?

CelliesProjects commented 6 years ago

I turn off BLE with btStop() https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-bt.c

ghost commented 6 years ago

Thank you very much! But that works on Arduino IDE?? I included . How must I call that function?

CelliesProjects commented 6 years ago

For wifi you can use:

WiFi.mode( WIFI_MODE_NULL );

should work in Arduino IDE.

ghost commented 6 years ago

Thank you!

ghost commented 6 years ago

With "WiFi.mode( WIFI_MODE_NULL);" The current compsuntion is the same. I teste with and without that line and I dont see current variation. Is there another way to turn off the radio part on the ESP32??

CelliesProjects commented 6 years ago

I am not sure, the above info came from issue https://github.com/espressif/arduino-esp32/issues/75.

CelliesProjects commented 6 years ago

Maybe turn of both radios? They may be implemented as a single radio that is multiplexed.

copercini commented 6 years ago

There is an example for this: https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/examples/WiFiBlueToothSwitch/WiFiBlueToothSwitch.ino

to turn wifi and Bluetooth off:

WiFi.mode(WIFI_OFF);
btStop();
ghost commented 6 years ago

Thank you very much, friends!

daton89 commented 5 years ago

Stopping bluetooth with btStop(); will save energy?

mrdazhuk commented 3 years ago

btStop doesn't work. It freezes the app. esp_bt_controller_disable doesn't return anything. Just blocks the app

me-no-dev commented 3 years ago

@mrdazhuk should be fixed in the latest master

mrdazhuk commented 3 years ago

@me-no-dev the problem still exists.

me-no-dev commented 3 years ago

This works for me in Master and I can no longer reproduce your problem. Did you uninstall the core from the board manager first?

  SerialBT.begin("ESP32test");
  delay(1000);
  SerialBT.end();//calls btStop();
mrdazhuk commented 3 years ago

Let me check. Thank you

mrdazhuk commented 3 years ago

@me-no-dev could you please share your configuration from platformio.ini. seems to me i'm doing something wrong, because BluetoothSerial.cpp is little different. I've removed everything, but still different

me-no-dev commented 3 years ago

@mrdazhuk sorry, I do not use PIO