Nano Esp32 bleKeyboard isConnected, Does Not Print Over BLE

Hello,

I have been struggling to send data through a Genuine Arduino Nano ESP32 to a smart device as a Bluetooth keyboard. I have tried two separate Genuine Nano ESP32 boards and have had the same result with both of them.

  • The bleKeyboard function isConnected() is true. I know this is the case since I can print a confirmation to the serial monitor immediately once I pair the ESP32 keyboard and it reads "Connected" on my device's Bluetooth menu. This connection verification message immediately stops printing once I power off, reset, or un-pair the Nano ESP32 Keyboard from said device.

  • In contrast with the Serial.print() command recognizing the change of isConnected(), The commands bleKeyboard.print() and bleKeyboard.press() do not print the programmed message indicating the status of the isConnected() command to the connected device.

  • The Touchscreen Keyboards on my Connected devices do not move out of the way when the ESP32 Keyboards are paired, nor does a blinking typing cursor appear. This is out of the norm of my limited experience with BLE keyboards.

  • Predictably, pressing the push-button connected to the digital pin on the NanoESP32 is not printing the desired message.

#include <Arduino.h>
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>


/**
 * This example turns the ESP32 into a Bluetooth LE keyboard 
 */
#include "BleKeyboard.h"

BleKeyboard bleKeyboard;

int pinA = 7;                                       //Declaring variables for the pins
int pinB = 9;
int pinC = 17;

void setup() {
  Serial.begin(115200);
  Serial.println("Starting BLE work!");
  
  bleKeyboard.begin();
  
}

void loop() {
  
  
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  if(bleKeyboard.isConnected()) {
    Serial.println("Sending 'Hello world'...");
    bleKeyboard.press('A');
    bleKeyboard.println("Hello world");}
  else{
    Serial.println("No Bluetooth Connected");
  }
    //delay(1000);

    //Serial.println("Sending Enter key...");
    //BleKeyboard.write(KEY_RETURN);

    delay(1000);
  
  if (digitalRead(pinA) == LOW){
    delay(90);
    
    bleKeyboard.press('A');        //Sending a string
    delay(50);}
    
    if (digitalRead(pinB) == LOW){
      
    bleKeyboard.press('B');         //Sending a string
    delay(50);}

   else if (digitalRead(pinC) == LOW){
   
    bleKeyboard.press('C');         
    
    delay(50);}}


//  }
//  Serial.println("Waiting 5 seconds...");
//  delay(5000);
//}

Many Thanks and Cheers!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.