Zhu Qi
Published © MIT

Use BLE to configure Dual-band WiFi Microcontroller

With a BLE5.0 & Dual-band WiFi microcontroller, you will never have to worry about re-compiling the code just to change the Wi-Fi SSID & PSW

BeginnerProtip1 hour159
Use BLE to configure Dual-band WiFi Microcontroller

Things used in this project

Hardware components

ready RTL8722DM
×1

Software apps and online services

Easy WiFi Config

Story

Read more

Code

BLEConfigWiFi.ino

C/C++
#include "BLEDevice.h"
#include "BLEWifiConfigService.h"

BLEWifiConfigService configService;

void setup() {
    Serial.begin(115200);

    BLE.init();
    BLE.configServer(1);
    configService.addService();
    configService.begin();

    // Wifi config service requires a specific advertisement format to be recognised by the app
    // The advertisement needs the local BT address, which can only be obtained after starting peripheral mode
    // Thus, we stop advertising to update the advert data, wait for advertising to stop, then restart advertising with new data
    BLE.beginPeripheral();
    BLE.configAdvert()->stopAdv();
    BLE.configAdvert()->setAdvData(configService.advData());
    BLE.configAdvert()->updateAdvertParams();
    delay(100);
    BLE.configAdvert()->startAdv();

}

void loop() {
    delay(1000);
}

Credits

Zhu Qi

Zhu Qi

8 projects • 3 followers

Comments