serial bluetooth and ESP NOW

zachtos
Posts: 2
Joined: Wed Jun 15, 2022 11:58 pm

serial bluetooth and ESP NOW

Postby zachtos » Thu Jun 16, 2022 12:02 am

I am not able to get ESP NOW to function properly while using the built in serial bluetooth library.

Code: Select all

    char *pin = "123";//"R069D"; //<- standard pin would be provided by default

    SerialBT.begin("abc");//, false); 
    SerialBT.setPin(pin);
    
    esp_err_t err;
 
    WiFi.mode(WIFI_STA);
    
err = esp_now_init();
    if (err != ESP_OK)
    {
      Serial.println("Problem during ESP-NOW init");
      ESP.restart();
      return;
    }
    else
    {
      espNowStarted = true;
      Serial.println("ESP-NOW init OK");
    }

   
    Serial.print("[OLD] ESP32 Board MAC Address:  ");
    Serial.println(WiFi.macAddress());
    
    esp_now_register_recv_cb(OnDataRecv);
    esp_now_register_send_cb(OnDataSent);

  // register peer
    esp_now_peer_info_t peerInfo;
    peerInfo.channel = 0;
    peerInfo.encrypt = false;
    
    // register first peer
      memcpy(peerInfo.peer_addr, peerAdmin, 6);
    if (esp_now_add_peer(&peerInfo) != ESP_OK){
      Serial.println("Failed to add peer");
      ESP.restart();
      return;
    }   

    memcpy(peerInfo.peer_addr, espAll, 6); //can also broadcast with zero (0) which does each individual
    if (esp_now_add_peer(&peerInfo) != ESP_OK){ //delivery success always with 0xFF broadcast, so no ack in that mode
      Serial.println("Failed to add peer");
      ESP.restart();
      return;
    }
I can send but not receive, I'm trying broadcast address and it does not work. If I switch back to BLE mode, everything is fine. What am I missing about the basic compatibilities of ESP NOW with serialBluetooth?

rpiloverbd
Posts: 101
Joined: Tue Mar 22, 2022 5:23 am

Re: serial bluetooth and ESP NOW

Postby rpiloverbd » Fri Jun 17, 2022 11:11 am

Have you checked the baud rates of sender and receiver devices?

Who is online

Users browsing this forum: No registered users and 77 guests