I want to connect an ESP32 to a SMA Sunny Boy SB5000-TL Solar convertor over Bluetooth, but I cannot establish a connection and I'm kind of stuck. I use the internal bluetooth module of the ESP32.

What I've done:

  • I started with this project: https://github.com/delhatch/ESP32_to_SMA but I did not get past the connection. I tried to locate the problem area:

  • I tried using an Android app (Oxley Solar) to connect to the SB5000-TL Solar convertor, and that works great. The pin code of the convertor is set to 0000.

  • I tried using two ESP32 modules, one as master, one as slave and that works as well, though I do not need to set a pin. So the bluetooth module of my ESP32 works properly.

So the problem must be in my code, I guess.

This is the code I use to connect to the convertor:

#include "BluetoothSerial.h"

#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it

BluetoothSerial SerialBT;
boolean confirmRequestPending = true;

// uint8_t ESP32Slave[6]  = {0x84, 0xCC, 0xA8, 0x2C, 0x70, 0x1E}; // Address of Slave.
uint8_t SMA[6]  = {0x00, 0x40, 0x65, 0x12, 0x4B, 0x3E}; // Address of my SMA inverter.
const char *pin = "0000"; //<- standard pin

void setup() {
  SerialBT.begin("ESP32master", true); //Bluetooth device name
  bool connected = SerialBT.connect(SMA);
  if (connected) {
  } else {
    Serial.println("NOT Connected!");

void loop() {


void callback(esp_spp_cb_event_t event, esp_spp_cb_param_t *param) {
  Serial.print("Got event!");  Serial.println(event);

void BTConfirmRequestCallback(uint32_t numVal)
  confirmRequestPending = true;

void BTAuthCompleteCallback(boolean success)
  confirmRequestPending = false;
  if (success)
    Serial.println("Pairing success!!");
    Serial.println("Pairing failed, rejected by user!!");

This is the result in the Serial console:

Got event!0
Got event!8
NOT Connected!
Got event!1

I tried to replace the Mac Address with the name of the Convertor, I tried with and without pin.

I'm kind of stuck. Any idea's of how I can check what is wrong?

Is there any kind of scanner I can use to see what is happening with the app that works and what is (not) happening with my code?

Other ways to get more info/leads?
Could I use a Bluetooth sniffer or so (no experience) to find out what happens?

Any advice would be greatly appreciated!

  • I have searched the net for a solution for this issue for esp32 trying to connect as a serial master . All i can find is that there is a connection success reporting issue with BluetoothSerial.h while using the correct address or name of the slave .latest version 1.4 i think reports as connection successful, when it is not. version 1.3 reports connection failed. Very frustrating with no updated fix at github. You have probably noticed that all examples of BLE classic use an esp32 as slave and an android phone connecting as a master to switch relays on and off on a BLE board . But there are no Sep 2, 2022 at 8:50


Your Answer

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

Browse other questions tagged or ask your own question.