Send AT Commands to HM-10 via AI2 and print it's response in the app

Hi there,

I currently have a project I’m working on with my Arduino Nano connected to a HM-10 via AltSoftSerial.

The nano is plugged into my PC and would be using hardware serial.

Things work fine in terms of figuring out how to communicate back and forth with characters or integers, but one thing I’d like to get working is being able to send AT commands to the HM-10 via the AI2 Android app and have the HM-10’s response to those commands print in a text box in the app for debug.

So far I haven’t figured out how to achieve this. In this video, it seems you are able to sendbytes to run AT commands, but I’d like to be able to view the response to for query commands like AT+NAME?

https://www.youtube.com/watch?v=PINCucGRhA8

I have this simple arduino code from martyncurrey.com in order to print things to both directions and that works fine for ints and characters. Incoming data is printed in the serial monitor in the arduino IDE, and if I type an AT command in the serial monitor it makes it’s way to the HM10 and I get a response.

However when I sendbytes in AI2 as suggested by that video, I dont get a printout of the HM-10s response.

If anyone has any idea’s on how this is done, I’d greatly appreciate it.

Here’s the Arduino side code:

// SerialIn_SerialOut_HM-10_01
//
// Uses hardware serial to talk to the host computer and AltSoftSerial for communication with the bluetooth module
//
// What ever is entered in the serial monitor is sent to the connected device
// Anything received from the connected device is copied to the serial monitor
// Does not send line endings to the HM-10
//
// Pins
// BT VCC to Arduino 5V out.
// BT GND to GND
// Arduino D8 (SS RX) - BT TX no need voltage divider
// Arduino D9 (SS TX) - BT RX through a voltage divider (5v to 3.3v)
//

#include <AltSoftSerial.h>
AltSoftSerial BTserial;

char c = ’ ';
boolean NL = false;

void setup()
{
Serial.begin(9600);
Serial.print("Sketch: "); Serial.println(FILE);
Serial.print("Uploaded: “); Serial.println(DATE);
Serial.println(” ");

BTserial.begin(9600);
Serial.println(“BTserial started at 9600”);
}

void loop()
{

// Read from the Bluetooth module and send to the Arduino Serial Monitor
if (BTserial.available() )
{
c = BTserial.read();
Serial.write©;
}

// Read from the Serial Monitor and send to the Bluetooth module
if (Serial.available())
{
c = Serial.read();

// do not send line end characters to the HM-10
if (c != 10 & c != 13 )
{
  BTserial.print(c);
}

// Echo the user input to the main window.
// If there is a new line print the ">" character.
if (NL) {
  Serial.print("\r\n>");
  NL = false;
}
Serial.write(c);
if (c == 10) {
  NL = true;
}

}
}


Please export your project and post it here.

I couldn't wait, so I followed your links and downloaded the app source, and tidied it up for a nice board post ...
RadeniteBOOST.aia (165.7 KB)
BLE version

Here is the AI2 HM10 FAQ:

Also see the main BLE FAQ:

Note the recent BLE version change and extended version cleanup instructions.

Reading your AI2 app, I do not see any BLE event blocks for receiving data from the HM-10.
I also don't see any BLE block to register for reads with the HM-10.
I have seen that coding pattern in more recent AI2 BLE apps.

(I defer to the real BLE users.
I'm just a FAQ janitor.)

I've tried his project and tested with AT+RESET but it doesn't seem to work. It seems like the HM10 isn't receiving the AT command still. Galaxy Note 9.

I'm using the latest BLE extension now, 20200616.

Here you can find information about HM-10 and Arduino UNO.

I'm doing a tutorial in Spanish on updating the HM-10, AT commands and HM-10 Stand alone, if you want you can ask me about the content of this tutorial.

http://kio4.com/arduino/161_HM10_BLE_Actualizar.htm

I followed your tutorial and I got it to work with sending AT+RESET, AT+NAME etc.

I had to set the HM10 mode to MODE2 (remote control mode)

One thing I would like to know is, how can we read and show the response from the HM10 on the Android app?

Try set

AT+NOTI1

Thanks but I mean what kind of blocks in Ai2? How do you use the writebytesWithResponse block and what do you send on the arduino sketch side?

Stand alone
http://kio4.com/arduino/161_HM10_BLE_Actualizar.htm#2

Arduino+HM-10
http://kio4.com/arduino/161_HM10_BLE.htm

Arduino+HM-10 conneted + AT command, I have not tried it.