ArduinoBlue App receives but doesn’t transmit

I have successfully set up control of a motor from an iPad to an HM10/BT05+Arduino Nano using the Arduino IDE and the BluetoothLE app. I’m now trying to go to the next level and make use of buttons and a slider in the ArduinoBlue App. I have managed to send text from the serial monitor within the IDE. This pops up in a small window on the iPad. Unfortunately I cannot receive data back from the iPad app. The button data is always -1 and I cannot send text from the iPad to the serial monitor.The nano is running the ArduinoBlue_basic.ino example code. Have tried both ArduinoBlue ver 3.1.[12]. Help would be much appreciated. Thanks.

Please post that sketch here; don't forget to use code tags as described in How to get the best out of this forum.

To which pins is the bluetooth module connected?

Which means that either the sketch can't read it or the iPad app is not sending it.

That sounds a little worrying. Is the data supposed to go directly to serial monitor or through the 328P of the Nano?

Note:
I'm not an apple user and have very limited experience with bluetooth.


/*
* Demo program to demonstrate the features of the app.
*/

#include <SoftwareSerial.h>
#include <ArduinoBlue.h>


// The bluetooth tx and rx pins must be supported by software serial.
// Visit https://www.arduino.cc/en/Reference/SoftwareSerial for unsupported pins.
// Bluetooth TX -> Arduino D4
const int BLUETOOTH_TX = 4;
// Bluetooth RX -> Arduino D5
const int BLUETOOTH_RX = 5;

int prevThrottle = 49;
int prevSteering = 49;
int throttle, steering, sliderVal, button, sliderId;

SoftwareSerial bluetooth(BLUETOOTH_TX, BLUETOOTH_RX);
ArduinoBlue phone(bluetooth); // pass reference of bluetooth object to ArduinoBlue constructor.

// Setup code runs once after program starts.
void setup() {
    // Start serial monitor at 9600 bps.
    Serial.begin(9600);

    // Start bluetooth serial at 9600 bps.
    bluetooth.begin(9600);

    // delay just in case bluetooth module needs time to "get ready".
    delay(100);

    Serial.println("setup complete");
}

// Put your main code here, to run repeatedly:
void loop() {
    // ID of the button pressed pressed.
    button = phone.getButton();

    // Returns the text data sent from the phone.
    // After it returns the latest data, empty string "" is sent in subsequent.
    // calls until text data is sent again.
    String str = phone.getText();

    // Throttle and steering values go from 0 to 99.
    // When throttle and steering values are at 99/2 = 49, the joystick is at center.
    throttle = phone.getThrottle();
    steering = phone.getSteering();

    // ID of the slider moved.
    sliderId = phone.getSliderId();

    // Slider value goes from 0 to 200.
    sliderVal = phone.getSliderVal();

    // Display button data whenever its pressed.
    if (button != -1) {
        Serial.print("Button: ");
        Serial.println(button);
    }

    // Display slider data when slider moves
    if (sliderId != -1) {
        Serial.print("Slider ID: ");
        Serial.print(sliderId);
        Serial.print("\tValue: ");
        Serial.println(sliderVal);
    }

    // Display throttle and steering data if steering or throttle value is changed
    if (prevThrottle != throttle || prevSteering != steering) {
        Serial.print("Throttle: "); Serial.print(throttle); Serial.print("\tSteering: "); Serial.println(steering);
        prevThrottle = throttle;
        prevSteering = steering;
    }

    // If a text from the phone was sent print it to the serial monitor
    if (str != "") {
        Serial.println(str);
    }

    // Send string from serial command line to the phone. This will alert the user.
    if (Serial.available()) {
        Serial.write("send: ");
        String str = Serial.readString();
        phone.sendMessage(str); // phone.sendMessage(str) sends the text to the phone.
        Serial.print(str);
        Serial.write('\n');
    }
}

ArduinoBlue is an app available from the Apple Store. Probably need help from someone with actual experience of the specific app.

Hey there! I had the same problem you described. My setup was with an Arduino Mega 2560 (and iOS Arduino blue) to control some Neopixel, and I did a lot of checks with the controller sending signals to either Serial Monitor or Arduino blue. Nothing was send from phone to BT receiver - Serial Monitor to phone worked though.

Weirdest thing: It just worked for the Arduino Uno, exact same setup.

Trying different versions of the library only made it worse, some times it wouldn't even compile for the Mega.

Long story short: The Arduino Mega did not accept the pins given in the example code to connect to the BT receiver:


SoftwareSerial bluetooth(2, 3);    //TX -> 2, RX -> 3

Instead, just plugged it into 12 and 13 and it worked like a charme. Not sure, the Arduino Nano has the same problem, but it is worth a try! To tired to do it myself though, and I need more CPU power/RAM.

I hope this helps you or someone else - I had a lot of headache and wasted time due to this small bug. Gave me a reason to sign up to the forum; I needed to share this!

Best luck, M

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