ESP32 WiFi setup over BLE (ESP32 code)

Most small applications that we write have the WiFi credentials integrated in the code. But sometimes you do not want to have your WiFi credentials in the source code, specially if it is open source and maybe accessible as a repository on Github or Bitbucket. Having the WiFi credentials in the code is as well not practical if you sell your devices to others that need to setup the WiFi credentials according to their local network.

There are several solutions available like Espressifs Smartconfig or WiFiManager.

My approach is not to use WiFi to configure the WiFi credentials of an ESP32 module, but to do it over Bluetooth Low Energy (BLE).

To achieve this, the code includes a BLE server that is advertising a custom service. An Android phone or tablet (sorry, I cannot write apps for Iphones) then can connect to this BLE server and the user can setup the WiFi configuration of the phone.

So we need beside the code for the ESP32 as well an application for Android that can connect over BLE to the module. I wrote this small Android application and it is available for download from

  • Google Play for automatic installation
  • APKfiles if you do not have Google Play on your device
  • from here for manual installation
  • or you can build the Android app by yourself from the sources in my Bitbucket repo.

How does it work?

When the ESP32 is powered up it starts a BLE server and advertises a custom service to setup, check or erase the WiFi credentials. The Android app will find the ESP32 BLE server or ESP32 with active Bluetooth Serial:

By clicking on the device name the configuration screen opens. If there are already some WiFi credentials stored on the ESP32, they will be read from the device and displayed:

The configuration screen has 3 buttons to read the existing configuration, write a new configuration to the ESP32 or to erase any configuration on the device.

In case you want to use two AP settings, the switch button “Enable two AP” will show the edit boxes for the second AP:

The SSID and password for the WiFi APs should be entered in the text edit fields. Then a push on the “Send WiFi config” will send the new WiFi credentials to the ESP32.

The small text field at the bottom will show some debug messages during the process.

The source code

This post concentrates on the software that has to run on the ESP32. The complete source code is available in my Bitbucket repo.

I wrote the code with PlatformIO on Visual Studio Code, but as the code is all in one file, you can simply copy the code into a .ino file and use ArduinoIDE to test it.

The example needs to be able to encode and decode JSON objects and my favorite library for this is bblanchon‘s ArduinoJSON library. You need to install this library in your ArduinoIDE or with PlatformIO. Beside of that we need only three standard Arduino includes:

The Preferences library include is needed because I am using the preferences to store the WiFi credentials on the ESP32.

For the BLE Server I used the code from my ESP32 BLE server example and modified it for this application. We use the same include files to get access to BLE:

One difference is that instead of using “official” BLE services and characteristics I defined a custom service UUID and a custom characteristic UUID. This is to make sure that there is no collision or misunderstanding with existing BLE devices:

If you want to use different UUID’s, please note two things:

  • Do not just write some numbers and letters into the UUID but instead use an online UUID creator like Online UUID Generator
  • You need to change the Android source code and recompile it as well, because the UUIDs are hardcoded in the Android application (I put this on my TODO list already)

Next we need to define some Strings to hold the SSID’s and PW’s and pointers to the BLE server, service, advertisers and characteristic

As you can see I defined a primary and secondary set of credentials. This is because I use here the possibility to connect to one of two allowed WiFi AP’s as described in ESP8266 – Switch automatically between 2 access points. If you do not need this, you can simply change the code to delete the references to the secondary AP.

As shown in the BLE Server tutorial, we need to define some callbacks for the BLE events. The first set of callbacks is for client connection and disconnection events. If a client connects the BLE advertising of the service stops automatically. So in case a client disconnects, we start the advertising here again.

The next set of callbacks is for characteristic read and write events.

The characteristic write events receives the WiFi credentials from the Android app. The data is decoded with a simple method (XOR with a key) to make the data unreadable for sniffers. First step is to encode the received data.

The credentials are sent within a JSON object that makes it easy to parse through the data and extract the SSID names and passwords. The JSON object is in the form

The code checks that all keys are in the JSON object, extracts them and saves the values in the ESP32 preferences.

There is as well the possibility to delete the previously stored WiFi credentials by a simple JSON object containing the key “erase”.

Here is the code part for the erase:

The last part of the erase procedure is actually optional and you might want to remove it. By erasing the complete NVS partition all stored preferences are deleted, that includes as well Bluetooth pairing informations.

And there is as well the possibility to restart the ESP32

with this code part:

And the rest is some cleanup and debug output.

The characteristic read event is used to report back the current WiFi credentials to the Android app. The stored values for the two AP’s is converted into an JSON object, then decoded (XOR with a key) and then sent back to the Android App.

After defining the callbacks come the code to initialize the BLE server.

First the BLE device is initializes, then we start the BLE server and assign the callbacks for connection and reconnection of clients.

After that BLE service and the characteristic for the WiFi credentials is created.

And then the server and the advertising is started:

setup() and loop() code blocks

Inside the setup() function the first thing is to create a unique device name to distinguish between several ESP32 modules. This unique device name is created by using the MAC address of the module in the function createName() and stored in the global variable apName.

After the unique device name is created, the serial port is initialized and some debug info is send out

Next the preferences are checked to see if there are any WiFi credentials are stored already. If credentials are found, they are stored in the global variables ssidPrim, pwPrim, ssidSec and pwSec. The flag hasCredentials is set to TRUE if credentials were found or FALSE if no credentials were saved.

The next step initializes the BLE server

Then, if WiFi credentials were found, the connection to the WiFi AP is started.

The loop() function is doing nothing here than checking if a WiFi connection status change has occured. The connStatusChanged flag can be set true when

  • the BLE server has received WiFi credentials
  • a WiFi connection has been established
  • a WiFi connection has been lost

If a connection status change has been detected and the status isConnected shows that the device is connected to a WiFi network, the WiFi AP info are sent for debugging over the Serial port.

else a check for WiFi credentials is done and if true an initial connect (in case the device got new WiFi credentials) or a reconnect to WiFi is initiated

Handle WiFi connections

I use the same technique as descibed in ESP8266 – Switch automatically between 2 access points for the ESP32. Two valid AP credentials are stored in the device. The function scanWiFi() searches the available WiFi AP’s if one or two of them match the stored AP’s. If no matching AP is found, the function returns false.

Which of the stored AP’s should be used depends then on the signal strength. If there is the possibility to connect to either of the stored AP’s, the one with the stronger signal is selected.

Based on the results of scanWiFi() the function connectWiFi() then tries to connect to an AP. But before connecting, two WiFi event callbacks are initiated that will alarm the loop() if a connection change has occured.

gotIP() is called after the WiFi was assigned an IP address by the AP

lostCon() is called if the WiFi got disconnected

After initializing the callbacks, connectWiFi() checks which AP should be used and initiates the connection to this AP





  • Rico

    hi there,
    very interesting post , thanks for sharing your devs 🙂
    this technics sounds really usefull yet I have one question regarding BLE security :

    how do you handle the fact that WIFI credentials are sent in clear via the BLE charateristics?
    Am I wrong by saying that anyone connecting with a BLE app like nrfBLE can get the values too ?

    • beegee1962

      Thanks for your positive feedback and pointing out the security flaw.

      In the next version which was released today I am actually encoding the credentials before sending them. It is a simple encoding, but makes the data unreadable for sniffers or apps like nrfBLE.

      I will add today as well a new example where I use Bluetooth Serial instead of BLE. This has the encoding as well.

  • ud

    Tried to compile your code on arduino ide 1.8.5 (latest version) with included esp32 libraries. However there seems to be a problem with the preferences.h, see error listed below during compile.
    When I used #include Arduino could not find the library, even though it says the library is installed.
    When I used the #include “….. complete path of install/preferences.h” the library was indeed found, but the linker seems to have a problem.
    Can you please let me know if there is a work around..?
    Thank you for a great write up and sharing,
    ———- error messages below ———

    —- With include —-

    C:\esp32\code\arduino\esp32wifible\esp32wifible.ino:18:25: fatal error: preferences.h: No such file or directory

    compilation terminated

    —- With #include “C:\Program Files (x86)\Arduino\hardware\espressif\esp32\libraries\Preferences\src\preferences.h”

    sketch\esp32wifible.ino.cpp.o:(.literal._ZN17MyCallbackHandler7onWriteEP17BLECharacteristic[MyCallbackHandler::onWrite(BLECharacteristic*)]+0x38): undefined reference to Preferences::Preferences()'

    sketch\esp32wifible.ino.cpp.o:(.literal._ZN17MyCallbackHandler7onWriteEP17BLECharacteristic[MyCallbackHandler::onWrite(BLECharacteristic*)]+0x3c): undefined reference to Preferences::begin(char const*, bool)’

    sketch\esp32wifible.ino.cpp.o:(.literal._ZN17MyCallbackHandler7onWriteEP17BLECharacteristic[MyCallbackHandler::onWrite(BLECharacteristic*)]+0x40): undefined reference to Preferences::putString(char const*, String)'

    sketch\esp32wifible.ino.cpp.o:(.literal._ZN17MyCallbackHandler7onWriteEP17BLECharacteristic[MyCallbackHandler::onWrite(BLECharacteristic*)]+0x44): undefined reference to Preferences::putBool(char const*, bool)’

    sketch\esp32wifible.ino.cpp.o:(.literal._ZN17MyCallbackHandler7onWriteEP17BLECharacteristic[MyCallbackHandler::onWrite(BLECharacteristic*)]+0x48): undefined reference to Preferences::end()'

    sketch\esp32wifible.ino.cpp.o:(.literal._ZN17MyCallbackHandler7onWriteEP17BLECharacteristic[MyCallbackHandler::onWrite(BLECharacteristic*)]+0x4c): undefined reference to Preferences::clear()’

    sketch\esp32wifible.ino.cpp.o:(.literal._ZN17MyCallbackHandler7onWriteEP17BLECharacteristic[MyCallbackHandler::onWrite(BLECharacteristic*)]+0x50): undefined reference to Preferences::~Preferences()'

    sketch\esp32wifible.ino.cpp.o:(.literal._Z5setupv+0x1c): undefined reference to Preferences::getBool(char const*, bool)’

    sketch\esp32wifible.ino.cpp.o:(.literal._Z5setupv+0x20): undefined reference to Preferences::getString(char const*, String)'

    sketch\esp32wifible.ino.cpp.o: In function MyCallbackHandler::onWrite(BLECharacteristic*)’:

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:109: undefined reference to Preferences::Preferences()'

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:110: undefined reference to Preferences::begin(char const*, bool)’

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:111: undefined reference to Preferences::putString(char const*, String)'

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:112: undefined reference to Preferences::putString(char const*, String)’

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:113: undefined reference to Preferences::putString(char const*, String)'

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:114: undefined reference to Preferences::putString(char const*, String)’

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:115: undefined reference to Preferences::putBool(char const*, bool)'

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:116: undefined reference to Preferences::end()’

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:125: undefined reference to Preferences::Preferences()'

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:126: undefined reference to Preferences::begin(char const*, bool)’

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:127: undefined reference to Preferences::clear()'

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:128: undefined reference to Preferences::end()’

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:125: undefined reference to Preferences::~Preferences()'

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:125: undefined reference to Preferences::~Preferences()’

    sketch\esp32wifible.ino.cpp.o: In function setup()':

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:324: undefined reference to Preferences::Preferences()’

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:325: undefined reference to Preferences::begin(char const*, bool)'

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:326: undefined reference to Preferences::getBool(char const*, bool)’

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:328: undefined reference to Preferences::getString(char const*, String)'

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:329: undefined reference to Preferences::getString(char const*, String)’

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:330: undefined reference to Preferences::getString(char const*, String)'

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:331: undefined reference to Preferences::getString(char const*, String)’

    Multiple libraries were found for “WiFi.h”
    Used: C:\Program Files (x86)\Arduino\hardware\espressif\esp32\libraries\WiFi
    Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:347: undefined reference to Preferences::end()'

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:324: undefined reference to Preferences::~Preferences()’

    C:\esp32\code\arduino\esp32wifible/esp32wifible.ino:324: undefined reference to `Preferences::~Preferences()’

    collect2.exe: error: ld returned 1 exit status

    exit status 1
    Error compiling for board ESP32 Dev Module.

    • ud

      OK, please delete my previous post. I found that the following works:
      For compiling in Arduino ide:
      #include preferences.h
      # include Preferences.h

      Note: the left and right brackets have been left out of this text line as the web page appears to delete what ever is between them

      Thank you

      • beegee1962

        Hi UD
        Are you running Arduino IDE on Linux? That might explain the problem. I am on a Windows 7 platform and there is no case sensitivity for the library names.
        But it is a good finding and I will update the code. Thank you!

        • I’m on Windows and had the same issue with “preferences.h”. Capitalizing it to “Preferences.h” fixed the issue. The previous commenter’s large comment could be massively trimmed for readability as well.

          • beegee1962

            Code on Github and explanation here has been corrected. Sorry for causing the issue with uppercase/lowercase mismatch.

  • Steven

    Hi beegee
    Great post thank you. Have you never had issues with the memory consumption using both BLE and WiFi libraries? Using both in parallel – especially also using ethernet (ETH.h) – causes out of memory crashes for me and many others (at least on the wroom, maybe it’s better with additional PSRAM).

    • beegee1962

      Yes, I have the same problems. Heap is running out fast when you try to use BLE and WiFi together, not to mention if additional sensors are attached to the system.
      Arduino-ESP32 framework and the underlying ESP-IDF is still in development. Hopefully at some point in the future the required libraries are better optimized.
      Additional PSRAM could be a solution, but I couldn’t get my hands yet on a Wroover module to test it.

  • Olá. Parabens e obrigado por compartilhar o seu trabalho.
    Eu migrei para o wifimulti.
    Ficou muito melhor. Segue link para download.


    • beegee1962

      Thank you for sharing, but please post in English. It is difficult to read Portugese.

  • Excuse me. Now in English.
    I made some modifications to your code to implement the library
    It was very good. Worked perfectly. In my opinion it got better.
    I’m working on a prototype with Blynk for sensor monitoring. Today I use WiFiManager, but I plan on migrating to this BLE soon. However, for this, I need to register the Token ID of the device through APP. I have to create another field in the application to enter this information. Any idea?
    I also need to have an APP for Iphone.
    Thank you in advance for your contribution.

  • You һave mɑde some decent ⲣoints there. I checkеd on the net to find out more about the issue and found most individualѕ
    will go along with yoսr views on this web site.

  • Royshen

    Hello, I tried your code to upload my esp module,
    but I am facing the problem of insufficient memory.
    I complied on arduino, then it almost using 1400000 bytes code size and the limit of module is 1300000 bytes.

    Does anybody have same issue?

  • Anne Brondijk


    Great project! Also thanks for sharing.

    I have however ran into an issue. After flashing the code to the ESP32, I get the following messages printed in the Serial monitor:
    The first few times booting it’s this: “Fatal exception (0): IllegalInstruction”
    After a booting a few times, it’s either: “Fatal exception (28): LoadProhibited” or “Fatal exception 29(StoreProhibitedCause)”

    I have googled these errors but I can’t find a solution that works. Do you have any idea?


    • beegee1962

      Sorry. Without seeing your code I have no idea what could cause that.

      • Anne Brondijk

        Sorry, I should have mentioned that it’s exactly the same as yours, I’m just running the code I downloaded from your gitbucket, I didn’t change anything.

        • Anne Brondijk

          Also, what I said was incomplete. Below every error message was also the following:
          epc1=0x40080338, epc2=0x00000000, epc3=0x00000000, excvaddr=0x000008ff, depc=0x00000000

          So for example, the error message would be:
          Fatal exception (29): StoreProhibited
          epc1=0x40080338, epc2=0x00000000, epc3=0x00000000, excvaddr=0x000008ff, depc=0x00000000

        • beegee1962

          Thats strange. I just reused the code in a customers project and it works fine.

          • Anne Brondijk

            I figured it out. I thought it had something to do with the code as it all compiled and flashed fine, but it turns out it had something to do with the partitioning. In another comment you refer to this guide:

            I think I did something wrong there because if I instead select “Minimal SPIFFS”, the program runs just fine without any errors.

            Thanks for the quick replies anyways though! Great work

  • Christian Ruiz

    it work Fine but when i was using Firebase Library (for example, its the same with MQTT Client):

    void loop() {
    if (connStatusChanged) {
    if (isConnected) {
    Serial.print(“Connected to AP: “);
    Serial.print(” with IP: “);
    Serial.print(” RSSI: “);
    //Connection Firebase Host and Password
    Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH); //Firebase_host and Firebase_aut , its environment variable“/temp/event”, streamCallback); //streamCallback its define later.

    } else {

    Firebase Library is Here:

    the Result It´s

    Error !, Http stream was failed: -1

    Because ESP32 no Connect to Firebase, Its the Same with MQTT Cliente

    Can you Help me, please?.

    • beegee1962

      Not sure what the WiFi connection problem has to do with the WiFi setup over BLE or Bluetooth.
      If your http client fails, you should check if the AP is correct.

  • Christian Ruiz Gonzales

    Please can you send me your email, i have a question but is with personal information in my code.
    this is my email:



  • Mcad

    Hi, Do you have the android code?

  • Erik Mario Barajas Zazueta

    “jsonBuffer’ was not declared in this scope” , i have this problem when i compile de code , how to solved?

  • Leonardo Rodrigues da Silva

    I migrate to ArduinoJson version 6, the new source code is at:
    I don’t know if the sketch size were bigger than 1.2Mb (max on default partition scheme), so I changed the partition scheme to “Minimal SPIFFS”

  • Dear beegee1962, thanks for your work.

    I have a similar problem. I have a ESP32-CAM that sends emails with photos but needs WiFi connection.
    Asking users to remove the SD card to configure WiFi credentials is quite a pain, most cannot do it.

    So I decided that I could use Bluetooth to setup a config.txt file with the necessary credentials and the problem would be solved.

    The problem is that I cannot make ESP32 WiFi and Bluetooth (serial) work simultaneously.

    I have been trying to avoid Bluetooth BLE because I do not need the extra complexity.

    I would like to keep Bluetooth on for about 2 minutes when the the system is powered up then switch off Bluetooth and let WiFi take over.

    I can indeed switch off Bluetooth using the command btStop(); but, although Bluetooth disconnects and WiFi can connect back to the router connection with the mail server always fail.

  • Paulo Borges

    Hi, it is said above that using BT and WiFi at the same time as long as they are not used simultaneously may work.

    I cannot make it work even when only one is used at any one time.

    I have a ESP32-CAM that sends emails with photos but needs WiFi connection.
    Wifi credentials are stored on SD card.
    Asking users to remove the SD card to configure WiFi credentials is quite a pain, most cannot do it.

    So I decided that I could use Bluetooth to setup a config.txt file with the necessary credentials and the problem would be solved.

    The problem is that I cannot make ESP32 WiFi and Bluetooth (serial) work activated (even not transmuting) at the same time.

    I would like to keep Bluetooth on for about 2 minutes when the the system is powered up then switch off Bluetooth and let WiFi take over.

    I can indeed switch off Bluetooth using the command btStop(); but, although Bluetooth disconnects and WiFi can connect back to the router connection with the mail server always fail.

    Removiing the following line from Setup() solves the problem.
    // inti Bluetooth
    SerialBT.begin(“myBT”); //Bluetooth device name

    Assistance welcome.

    • beegee1962

      You are most likely running out of heap memory.
      I do not know much about the ESP32 CAM boards, but if they are based on ESP32 WROVER modules they have additional RAM that will be used by Bluetooth and WiFi if enabled. The ESP32 WROOM has a too less available heap to run both Bluetooth and WiFi and some application stuff if the application needs a lot of heap memory. I guess this is the case on the ESP32 CAM modules.

      To enable PSRAM in ArduinoIDE goto Tools and set PSRAM to enabled.
      In PlatformIO put
      build_flags =

      into the platformio.ini file.

      You can check your available heap and PSRAM with
      #include "Esp.h"

      SerialCMD.println("\n\n[HEA] ##################################");
      SerialCMD.println("[HEA] on start: ");
      SerialCMD.printf("[HEA] Internal Total heap %d, internal Free Heap %d\n", ESP.getHeapSize(), ESP.getFreeHeap());
      SerialCMD.printf("[HEA] SPIRam Total heap %d, SPIRam Free Heap %d\n", ESP.getPsramSize(), ESP.getFreePsram());
      SerialCMD.printf("[HEA] ChipRevision %d, Cpu Freq %d, SDK Version %s\n", ESP.getChipRevision(), ESP.getCpuFreqMHz(), ESP.getSdkVersion());
      SerialCMD.printf("[HEA] Flash Size %d, Flash Speed %d\n", ESP.getFlashChipSize(), ESP.getFlashChipSpeed());
      SerialCMD.println("[HEA] ##################################\n\n");

      Put this before and after your SerialBT to see if you have enough RAM available.

      Beside of this example, the only modules I got to work with both Bluetooth and WiFi running are the ESP32 WROVER modules

  • Hi beegee1962, thanks for sharing your work!

    I have an error after i uploaded the code, the Serial Monitor shows the next:

    ets Jun 8 2016 00:22:57

    rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    mode:DIO, clock div:2
    entry 0x400806a8

    Do you know how can I solve the problem?


    • beegee1962

      What error?
      You posted an ESP32 boot message that says it rebooted from a SW reset.

      Did you try to upload the code again?

  • Hi I came across your apps on the Play store whilst looking for a FOSS bluetooth app that could be used to interface with this long-range LoRa mesh project

    Currently, access is via wifi/ web app which works but is not very friendly to the batteries.

    Having a BLE option as well so you could turn the wifi off would be interesting. It has some basic serial capabilities

    It seems like it crosses over with some of your interests, so I’m posting here in the vague hope you might think it’s a good project and help to build the Android/ BLE serial interface. There’s no money as it’s a open-source volunteer project.

    It currently runs on these boards more are planned.

    • beegee1962

      Hi Sam,

      I was actually looking before into your Disaster-Radio project (I am living in the Philippines, and something like that can be life saving here).

      But you didn’t release the source codes, so I didn’t follow it anymore. I am playing around with LoRa right now, but focusing on the new Semtech SX1262 chips. Right now I am testing a LoRa Mesh implementation based on my SX1262 library.

      I would be very interested to support your project for the BLE interface. I will send you an email to the address you have given.

  • UriShX

    Hi mate,

    I tried my hand at writing a simple web-ble interface to allow configuration of esp32 from a web browser, relying on your code.

    The rationale is that a laptop user could configure the esp32’s WiFi credentials without changing the network defined to which he/she is connected atm. Besides, web-ble works on several OSs (no iOS unfortunately) , and the web app does not require installation.

    Anyway, the code is on my github at, and the app can be accessed from

    Thanks for sharing your code, and I really hope my addition is OK with you, and is useful for you and others.

    • beegee1962


      That’s a great extension to the application, thank you for posting it. I never looked into Web-BLE before.

  • Stephen

    Hi in line 358
    if (ssidPrim.equals(“”)
    || pwPrim.equals(“”)
    || ssidSec.equals(“”)
    || pwPrim.equals(“”)) {

    you have pwPrim twice. I think the last one is meant to be pwSec?

    • beegee1962

      Correct, second pwPrim should be pwSec. Will correct the sources. Thanks for pointing to this bug.

  • Hello sir, i have facing some issue, can you please help me out?
    my system flashing the code to the ESP32. The first few times booting it’s this.
    can you please solve my issue, thanks

  • Robbo

    This is exactly what’s needed to make products deployable, but as a novice to Arduino and ESP ( Not to general programming though ), I get the error message:
    Sketch too big; see for tips on reducing it.
    Error compiling for board ESP32 Wrover Module.

    Now I have a 4MB Flash and *8MB PSRAM on my module. Additionally, I will need space for the actual wifi code which is already using half the available memory.
    Am I missing a trick here?
    Many thanks

    • beegee1962

      It is always the same problem, Espressifs BLE library is too big. You have three options:
      – On ArduinoIDE choose a different partition scheme from Tools–>Partition Scheme menu
      – On PlatformIO create a custom partition table
      – I am right now working to switch the code to use NimBLE library which is much smaller and as well uses lesser memory during runtime.

      For the NimBLE library, I have a converted code example which is using the NimBLE library and reduces used code space by around 20-30%.

      • Robbo

        Yes.. Thanks. As a complete beginner using this part I wasn’t aware about the options to customise the memory usage.
        I believe I read about having BT AND Wifi together causing some problems.. is it wise / sensible / possible to run one or the other depending if a Wifi connection is present or is it now stable to run both concurrently?

        • beegee1962

          On a Wrover module it should be ok to run both BLE and WiFi at the same time. But still the BLE library will take a lot of your free heap.

          If your application is running short on memory, you should take a look at NimBLE library as mentioned. It is 99% compatible with the ESP32 BLE library and much better on memory usage.

  • Robbo

    Well, this is great. But I cannot deploy a product that emulates another companies product.
    Trying to follow amazons guides are a nightmare.
    Is there anybody willing to work with me on doing it correctly??

    • beegee1962

      What do you mean with “emulates another companies product”?

  • js

    Great tutorial and walkthrough!

    Any plans to update for ArduinoJson6 ? I may take a crack at it myself, but your coding style is far superior. 🙂

  • Chori

    Hello, thank you very much for the contribution!. I had a problem compiling it. I get the following error:

    ‘class ArduinoJson690_000::StaticJsonDocument’ has no member named ‘containsKey’

    this error marks me all constainsKey from comment /** Json object for incoming data */ to:

    } else if (jsonDoc.containsKey(“reset”)) {

    Greetings from Argentina!.


Leave a Reply

Your email address will not be published. Required fields are marked *

Free Link Directory