App not working with my XC4382 BLE Bluetooth Module

Hello, I am having trouble connecting my XC4382 BLE Bluetooth Module (also known as HM-10, I believe) to the app to control my Arduino. I am running it off IOS, so that could be the problem, but every source seems to tell me something different. I've tried downloading the extension pack for HM-10, but my mac doesn't support the file.

The error message that comes up when I attempt to connect under the ai companion option is:
Runtime Error Unrecognized method. Irritants: (IsConnected)

I am following this tutorial right here:

If anyone could help, that would be great.

Two things: if you can find an Android phone to test this on, please do.
Second, in the tutorial they are talking about HM-05 which is fundamentally different from HM-10, because that one is not BLE, but classical BT.
The programming for it is very different, and much easier, in App Inventor.

Bluetooth is not yet properly supported on iOS:
http://doesappinventorrunonios.com

The data on the above web page concerns Classic Bluetooth. BLE is currently delivered as an extension by MIT but Apple iOS does not permit extensions unfortunately. I see the only answer is to switch to Android.
https://www.professorcad.co.uk/appinventortips#TipsBluetooth

Hey, thank you very much. I recently got an HC-05 Module instead and paired it with the emulator connect feature. It now seems that I can't find my module on the Bluetooth connection screen, and I'm not sure why. I've tried looking up tutorials to change it the block code, and nothing.

Not quite sure what to do.

You need to use the real device, not the emulator.

1 Like

And you need to pair the BT device on your phone first. You have to do this only once and your phone will remember.
I am not sure what happens if you have Android 12 or so, but try.

You are using an Android smartphone now?

Hey,

Yes, I did, but I'm still having problems getting the android to control my robot. It comes up with Error 516L Unable to write: Broken Pipe, so I researched and found that converting the 5v to 3.3v on the RX pin was helpful, but it still doesn't work.

This is my Arduino code, and this is my block code on the MIT App Inventor. Not sure what the issue is.

Blockquote
#include <SoftwareSerial.h>
#include <Servo.h>

Servo servo01;
Servo servo02;
Servo servo03;
Servo servo04;
Servo servo05;

SoftwareSerial Bluetooth(19, 18); // Arduino(RX, TX) - HC-05 Bluetooth (TX, RX)

int servo1Pos, servo2Pos, servo3Pos, servo4Pos, servo5Pos; // current position
int servo1PPos, servo2PPos, servo3PPos, servo4PPos, servo5PPos; // previous position
int servo01SP[50], servo02SP[50], servo03SP[50], servo04SP[50], servo05SP[50]; // for storing positions/steps
int speedDelay = 20;
int index = 0;
String dataIn = "";

void setup() {
servo01.attach(10);
servo02.attach(9);
servo03.attach(47);
servo04.attach(38);
servo05.attach(32);
Serial3.begin(9600); // Default baud rate of the Bluetooth module
Bluetooth.setTimeout(1);
delay(20);
// Robot arm initial position
servo1PPos = 0;
servo01.write(servo1PPos); // base
servo2PPos = 150;
servo02.write(servo2PPos); // neck 1
servo3PPos = 100;
servo03.write(servo3PPos); // neck 2
servo4PPos = 70;
servo04.write(servo4PPos);
servo5PPos = 90;
servo05.write(servo5PPos);
}

void loop() {
// Check for incoming data
if (Bluetooth.available() > 0) {
dataIn = Bluetooth.readString(); // Read the data as string

// If "Waist" slider has changed value - Move Servo 1 to position
if (dataIn.startsWith("s1")) {
  String dataInS = dataIn.substring(2, dataIn.length()); // Extract only the number. E.g. from "s1120" to "120"
  servo1Pos = dataInS.toInt();  // Convert the string into integer
  // We use for loops so we can control the speed of the servo
  // If previous position is bigger then current position
  if (servo1PPos > servo1Pos) {
    for ( int j = servo1PPos; j >= servo1Pos; j--) {   // Run servo down
      servo01.write(j);
      delay(20);    // defines the speed at which the servo rotates
    }
  }
  // If previous position is smaller then current position
  if (servo1PPos < servo1Pos) {
    for ( int j = servo1PPos; j <= servo1Pos; j++) {   // Run servo up
      servo01.write(j);
      delay(20);
    }
  }
  servo1PPos = servo1Pos;   // set current position as previous position
}

// Move Servo 2
if (dataIn.startsWith("s2")) {
  String dataInS = dataIn.substring(2, dataIn.length());
  servo2Pos = dataInS.toInt();

  if (servo2PPos > servo2Pos) {
    for ( int j = servo2PPos; j >= servo2Pos; j--) {
      servo02.write(j);
      delay(50);
    }
  }
  if (servo2PPos < servo2Pos) {
    for ( int j = servo2PPos; j <= servo2Pos; j++) {
      servo02.write(j);
      delay(50);
    }
  }
  servo2PPos = servo2Pos;
}
// Move Servo 3
if (dataIn.startsWith("s3")) {
  String dataInS = dataIn.substring(2, dataIn.length());
  servo3Pos = dataInS.toInt();
  if (servo3PPos > servo3Pos) {
    for ( int j = servo3PPos; j >= servo3Pos; j--) {
      servo03.write(j);
      delay(30);
    }
  }
  if (servo3PPos < servo3Pos) {
    for ( int j = servo3PPos; j <= servo3Pos; j++) {
      servo03.write(j);
      delay(30);
    }
  }
  servo3PPos = servo3Pos;
}
// Move Servo 4
if (dataIn.startsWith("s4")) {
  String dataInS = dataIn.substring(2, dataIn.length());
  servo4Pos = dataInS.toInt();
  if (servo4PPos > servo4Pos) {
    for ( int j = servo4PPos; j >= servo4Pos; j--) {
      servo04.write(j);
      delay(30);
    }
  }
  if (servo4PPos < servo4Pos) {
    for ( int j = servo4PPos; j <= servo4Pos; j++) {
      servo04.write(j);
      delay(30);
    }
  }
  servo4PPos = servo4Pos;
}
// Move Servo 5
if (dataIn.startsWith("s5")) {
  String dataInS = dataIn.substring(2, dataIn.length());
  servo5Pos = dataInS.toInt();
  if (servo5PPos > servo5Pos) {
    for ( int j = servo5PPos; j >= servo5Pos; j--) {
      servo05.write(j);
      delay(30);
    }
  }
  if (servo5PPos < servo5Pos) {
    for ( int j = servo5PPos; j <= servo5Pos; j++) {
      servo05.write(j);
      delay(30);
    }
  }
  servo5PPos = servo5Pos;
}
// If button "SAVE" is pressed
if (dataIn.startsWith("SAVE")) {
  servo01SP[index] = servo1PPos;  // save position into the array
  servo02SP[index] = servo2PPos;
  servo03SP[index] = servo3PPos;
  servo04SP[index] = servo4PPos;
  servo05SP[index] = servo5PPos;
  index++;                        // Increase the array index
}
// If button "RUN" is pressed
if (dataIn.startsWith("RUN")) {
  runservo();  // Automatic mode - run the saved steps 
}
// If button "RESET" is pressed
if ( dataIn == "RESET") {
  memset(servo01SP, 0, sizeof(servo01SP)); // Clear the array data to 0
  memset(servo02SP, 0, sizeof(servo02SP));
  memset(servo03SP, 0, sizeof(servo03SP));
  memset(servo04SP, 0, sizeof(servo04SP));
  memset(servo05SP, 0, sizeof(servo05SP));
  index = 0;  // Index to 0
}

}
}

// Automatic mode custom function - run the saved steps
void runservo() {
while (dataIn != "RESET") { // Run the steps over and over again until "RESET" button is pressed
for (int i = 0; i <= index - 2; i++) { // Run through all steps(index)
if (Bluetooth.available() > 0) { // Check for incomding data
dataIn = Bluetooth.readString();
if ( dataIn == "PAUSE") { // If button "PAUSE" is pressed
while (dataIn != "RUN") { // Wait until "RUN" is pressed again
if (Bluetooth.available() > 0) {
dataIn = Bluetooth.readString();
if ( dataIn == "RESET") {
break;
}
}
}
}
// If speed slider is changed
if (dataIn.startsWith("ss")) {
String dataInS = dataIn.substring(2, dataIn.length());
speedDelay = dataInS.toInt(); // Change servo speed (delay time)
}
}
// Servo 1
if (servo01SP[i] == servo01SP[i + 1]) {
}
if (servo01SP[i] > servo01SP[i + 1]) {
for ( int j = servo01SP[i]; j >= servo01SP[i + 1]; j--) {
servo01.write(j);
delay(speedDelay);
}
}
if (servo01SP[i] < servo01SP[i + 1]) {
for ( int j = servo01SP[i]; j <= servo01SP[i + 1]; j++) {
servo01.write(j);
delay(speedDelay);
}
}

  // Servo 2
  if (servo02SP[i] == servo02SP[i + 1]) {
  }
  if (servo02SP[i] > servo02SP[i + 1]) {
    for ( int j = servo02SP[i]; j >= servo02SP[i + 1]; j--) {
      servo02.write(j);
      delay(speedDelay);
    }
  }
  if (servo02SP[i] < servo02SP[i + 1]) {
    for ( int j = servo02SP[i]; j <= servo02SP[i + 1]; j++) {
      servo02.write(j);
      delay(speedDelay);
    }
  }

  // Servo 3
  if (servo03SP[i] == servo03SP[i + 1]) {
  }
  if (servo03SP[i] > servo03SP[i + 1]) {
    for ( int j = servo03SP[i]; j >= servo03SP[i + 1]; j--) {
      servo03.write(j);
      delay(speedDelay);
    }
  }
  if (servo03SP[i] < servo03SP[i + 1]) {
    for ( int j = servo03SP[i]; j <= servo03SP[i + 1]; j++) {
      servo03.write(j);
      delay(speedDelay);
    }
  }

  // Servo 4
  if (servo04SP[i] == servo04SP[i + 1]) {
  }
  if (servo04SP[i] > servo04SP[i + 1]) {
    for ( int j = servo04SP[i]; j >= servo04SP[i + 1]; j--) {
      servo04.write(j);
      delay(speedDelay);
    }
  }
  if (servo04SP[i] < servo04SP[i + 1]) {
    for ( int j = servo04SP[i]; j <= servo04SP[i + 1]; j++) {
      servo04.write(j);
      delay(speedDelay);
    }
  }

  // Servo 5
  if (servo05SP[i] == servo05SP[i + 1]) {
  }
  if (servo05SP[i] > servo05SP[i + 1]) {
    for ( int j = servo05SP[i]; j >= servo05SP[i + 1]; j--) {
      servo05.write(j);
      delay(speedDelay);
    }
  }
  if (servo05SP[i] < servo05SP[i + 1]) {
    for ( int j = servo05SP[i]; j <= servo05SP[i + 1]; j++) {
      servo05.write(j);
      delay(speedDelay);
    }
  }
}

}
}

Blockquote

First of all, does the phone connect now?
Second of all, you are going too fast. Good development goes in steps. First make sure connection and disconnection works, then try one servo, then add the others.
My second question is, what are the servo's in your phone app? If they are sliders, you may have a timing problem. These sliders fire so fast that the communication with your arm just chockes.
You said you were following an example tutorial. Did you change anything?