0

I have been having a lot of trouble extablishing a bluetooth connection between my iOS phone and a Raspberry Pi Pico W using bluetooth. I have taken a look at a lot of online resources on the matter but am making little progress.

At this point, I am;

  1. Trying to connect the Pico W with my phone through Bluetooth
  2. Trying to Pico connect with and eventually display something on the 'Bluetooth Serial' iOS application.

I tried to do this through two codes: 1.

#include <BluetoothSerial.h>
#include <SerialBT.h>

void setup(){
SerialBT.begin();
}

void loop(){
  for(byte i=0; i<10; i++){
    SerialBT.print(i);
    delay(500);
  }
 } 
/*
   Hello_World.ino
   Henry Abrahamsen
   8/12/23
   Simple code using the basic features of Bluetooth Serial
   Details available at https://docs.henhen1227.com/
*/

#include <BluetoothSerial.h>

#define bluetoothModuleSerial Serial1

// Create a BluetoothSerial object
// Serial port that the bluetooth module is connected
// Verbose mode: true
BluetoothSerial blueSerial(bluetoothModuleSerial, true);

void setup() {
  // Start communication with bluetooth device
  bluetoothModuleSerial.begin(9600);
  Serial.begin(9600);

  Serial.println("Setup Complete");
}


void loop() {
  blueSerial.readSerial();

  // If the button with id `B0`
  if (blueSerial.isButtonPressed(0)) {
    Serial.println("The button `B0` has been pressed!");

    // Send alert to the BluetoothSerial Connect App
    blueSerial.sendAlert("Hello from the Arduino");
  }
} 

But in both of these cases, I cannot even see the picoW show up in the bluetooth settings of my phone. It came up a couple of times (out of the 100 times I tried) and in both cases when i tried to pair it from the settings, it said the phone does not support this kind of device.

I don't understand what is going wrong. Should I perhaps write the code differently? I can find resources on bluetooth connections with micopython but I am not that familiar with the language and am new to arduino IDE too so I have no idea how to adapt it. All in all, I am pretty lost so I would appreciate all guidance.

Eventually, I would want a button pressed (connected to the pico) to act an an input in an application I made with reactNative which is why it is important to establish a connection of some sort between the pico and the app on the phone. I am open to doing this on wifi too if it is more suitable. All help is appreciated. Thank you all so much.

2
  • you have to put ``` on a separate blank line for the code formatting to work ... please edit your post
    – jsotola
    Commented May 19 at 18:01
  • iOS doesn't support Bluetooth Classic serial. The app you are using has been designed to work with a HM-10 module that uses the new Bluetooth GATT server characteristics to emulate the tx and rx lines. What is your hardware setup? Do you have an HM-10 module attached? Or are you attempting to do this with the Pico's built in Bluetooth?
    – ukBaz
    Commented Jun 2 at 5:22

0

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.