HM-10 connects but will not respond to AT commands

I am messing around with an HM10 BLE module for the first time. I have done countless google searches and read all of the forums I could find and am still having issues. Basically, I can successfully connect to the module (red light stops blinking and remains red), but am unable to run any AT commands from the serial monitor or any commands from external applications.

I am using the HM10 found here (this is the second one I've ordered in case the first was faulty): Amazon.com: DSD TECH HM-10 Bluetooth 4.0 BLE iBeacon UART Module with 4PIN Base Board for Arduino UNO R3 Mega 2560 Nano:
It being amazon's top pick told me it was probably reliable, but who knows.

I will list the two different wire connections I made. The first is for simply using the hardware serial to try and run the AT commands from the serial monitor. I uploaded a blank arduino program (blank setup and blank loop) without the Tx/Rx of the HM10 plugged in since I've read this may mess with the module. The second sketch is for attempting to use the software serial to communicate with the HM10 with the LightBlue and BLExAR iPhone apps. :

  1. ARDUINO UNO HM10
    3.3V VCC
    GND GND
    TX 1 RXD
    RX 0 TXD

  2. ARDUINO UNO HM10
    3.3V VCC
    GND GND
    TX 9 RXD
    RX 8 TXD

These are the instructions and the code I last used to try and test it (there are many options for beginner projects out there but I've pretty much been through them all): https://roboindia.com/tutorials/send_receive_data_hc10_bluetooth

I am working on a mac, I'm not sure if there's anything special if using a mac to develop with arduino. I've read some things about FTDI, but I have no idea what that exactly is. I'm out of ideas and could really use some help to figure out how to make this work!

jmoran08:
The first is for simply using the hardware serial to try and run the AT commands from the serial monitor.

...

TX 1 RXD
RX 0 TXD

It's a bit confusing, but you actually need to connect RXD to RX 0 and TXD to TX 0 for that application. The reason is that those labels are indicating the function of the pins on the ATmega328P primary microcontroller on your Uno. But you're only using the Uno as a USB to serial adapter. For that usage, you're actually communicating directly between the HM10 and the USB chip on your Uno. The ATmega328P might as well not even be there. The USB chip is connected to the ATmega328P RX-TX, TX-RX. So actually the function of the pins on the Uno are reversed in this case.

You also need to make sure you have the menu at the bottom right corner of your Serial Monitor set to 9600. The tutorial you linked to shows the line ending menu set to "Both NL & CR" so make sure that's what you have set also. I have never used one of these modules so I have to assume the tutorial is correct on that (not always a safe assumption).

jmoran08:
I am working on a mac, I'm not sure if there's anything special if using a mac to develop with arduino. I've read some things about FTDI, but I have no idea what that exactly is.

That doesn't matter.

The Bluetooth devices are clearly stated to be for 3.6 - 6v power. Running them on Uno's 3.3v pin may not be the cause of your problem, but it cannot possibly be a good idea.

I uploaded a blank arduino program (blank setup and blank loop) without the Tx/Rx of the HM10 plugged in since I've read this may mess with the module.

This is nonsense, and pointless. What you need to know is that Uno's serial is shared between the USB port and the Tx/Rx pins. All this means is that you need to remove bluetooth from the pins while uploading aprogramme. Nothing messes with the module, and this is not a serious problem but, if you wish to configure Bluetooth from the serial monitor, you will be obliged to use software serial anyway.

Some useful HM-10 information here and also

So actually the function of the pins on the Uno are reversed in this case.

Okay that definitely clears some things up for me. I actually tried that because I was just switching around the wiring as much as possible to get something to work. When I connect RX-RX and TX-TX I only get a response "OK" from sending the AT command when selecting No line ending in the serial monitor. The problem is that I cannot get it to respond to any other AT commands no matter which option I choose in the serial monitor (No line ending, New line, Carriage return, or both New Line and Carriage return).

My advice is to work exclusively with the first configuration until you get that working as expected, since it's the most simple. The fact that you did get the OK indicates the wiring is probably correct now (though not necessarily the power supply).

As for the issue with the AT commands, I can't give any advice since I don't have any experience on this topic. Maybe someone else will be able to help.

Nothing messes with the module, and this is not a serious problem but, if you wish to configure Bluetooth from the serial monitor, you will be obliged to use software serial anyway.

So how would you suggest testing out the AT commands? If I set the serial monitor to no line ending I can get OK back from sending AT, but cannot get anything from any other AT commands.

Some useful HM-10 information here and also

I actually came across this previously, though I believe it was before I noticed that this for some reason semi had a response with RX-RX and TX-TX instead of RX-TX and TX-RX. Using that first link, I am able to read what the arduino program sends in the iPhone application, but I cannot get the ble to read what is coming from the iPhone output. The pieces of code I added after the delay of the code in that article are:
char c = ble.read();
Serial.println(c);
All I receive is -1

jmoran08:
So how would you suggest testing out the AT commands?

With a UNO, this is normally done using Software Serial, i.e. your SECOND configuration, using the monitor to send the commands. Your HM-10 is in AT mode by default, and thus about the only(!) things that can go wrong are monitor mismatch and stuffups with case, CR and Linefeeds.

I'm afraid I have no explanation as to how you could possibly connect Rx>Rx and Tx>Tx, and then get an OK, but the fact that you then cannot get any other AT commands to work does not surprise me at all. The terms Rx and Tx, clearly marked, describe the functions of the pins - Rx receives, Tx transmits, and it therefore follows that a receiver needs to be connected to a transmitter. With that in mind, the notion of connecting a Rx to Rx and expecting a result seems to be nothing more than incomprehensible horseshit. I'm afraid I am not familiar with HM-10s, but I would expect the Rx and Tx pins to work like any other Rx and Tx pins.

Currey is the eminence grise with this AT stuff but I might have given you an older link before. Now
http://www.martyncurrey.com/hm-10-bluetooth-4ble-modules/#HM-10%20-%20AT%20commands
says it all, and I suggest you do it the way he tells you. The circuit connections are absolutely clearly shown and described. Note the voltage divider on Arduino Tx, which is a good idea. Note also the Altsoft serial library he uses. I never use software serial and I don't know anything about this, but I think one software serial is much like another for this purpose.

I now recall that Martyn has other HM-10 stuff. I failed to bookmark it, but you might trawl for it.

I might also point out that any problems with reading output from the phone may simply be down to slack input handling. Check here

Nick_Pyner:
I’m afraid I have no explanation as to how you could possibly connect Rx>Rx and Tx>Tx, and then get an OK

I already thoroughly explained why that’s necessary for the first usage earlier in this thread:

This is a topic that has been gone over many times with the ESP8266 users, who are always trying to use their Arduino boards as USB to serial adapters.

I might also point out that any problems with reading output from the phone may simply be down to slack input handling. Check here

After reading through that a bit, I am a little bit confused.

Here is the code I’m using from Martyn Currey:

#include <AltSoftSerial.h>
AltSoftSerial BTserial;
// AltSoftSerial Library, for an extra serial port

char c=’ ';
boolean NL = true;

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(c);
}

// 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.write(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; }
}
}

I am able to successfully type something in the serial monitor and receive it on my iPhone using the BLExAR app. But when I send anything from that app to the HM-10 the serial monitor doesn’t display anything. I think it is because the BTSerial.available always returns 0. When I take that out and try to simply read, with a slight delay of course, I just receive backwards question marks. Any more suggestions? I have googled this issue for hours and am not finding anything to be helpful.

I think it is because the BTSerial.available always returns 0. When I take that out and try to simply read, with a slight delay of course, I just receive backwards question marks.

If there is nothing available in the buffer since the BT-unit didn't send anything, there is no point in reading anything. BTSerial.available() return the number of bytes available in the buffer. Now i see the whole thread,not just the new one you started i can see what you have done so far. You managed to send AT en get OK back connecting the BT-unit straight to the usb serial, you should be able to reproduce that using the altsoftserial and an echo to the serial-monitor(using hwSerial)

How would I reproduce it with altsoftserial? Do you have example code I could use?

jmoran08:
I am able to successfully type something in the serial monitor and receive it on my iPhone

If you have properly carried out things as outlined in reply#8, thereby achieving one-way communication, and assuming this is actually your intention, there is nothing wrong with your wiring, and you can trust the code. This rather suggests the problems are all at the phone end, and it is simply not sending anything Bluetooth can sensibly receive and pass on to Arduino. I guess this is a simple procedural matter in the phone app.

I’m looking for two way communication, arduino code to iPhone app and iPhone app to arduino app. The iPhone apps I am using to communicate with the BLE should work correctly being that they are commonly used. So are you saying something is faulty with their apps? I’m not sure how else to test the BLE receiving something from an outside device if the iPhone apps won’t work

jmoran08:
I’m looking for two way communication, arduino code to iPhone app and iPhone app to arduino app.

Well, that is at variance with the stated subject of this thread, so I assume you have given up on the AT stuff for the moment, which is a really good idea.

The iPhone apps I am using to communicate with the BLE should work correctly being that they are commonly used. So are you saying something is faulty with their apps?

I'm suggesting nothing of the sort. I am suggesting that you are not using the app properly, and I said specifically that this may be a simple matter of procedure - a mistake you only make once.

I’m not sure how else to test the BLE receiving something from an outside device if the iPhone apps won’t work

It is indeed the way, but 'won't work" is a relative term which ranges from "faulty app" (not very likely) to "user incompetence" (quite likely). Further, the fact that you already have one-way communication more or less proves the app is kosher - hence my comment.

On reflection, you might check Arduino's Rx wire as a last resort, but I recall you got something, which suggests it is OK, even if it was junk.

The BLExAR application has a console in which you either type something from that application and send it or see what is sent from the BLE. All I do is type in a string and send it. I’m not sure if there is a user error in that or not.

I did get an OK back, though now that I am using the newer code I posted above I have the BLE’s RX in pin 9 and the TX in pin 8.

jmoran08:
I’m not sure if there is a user error in that or not.

The error will not be in the string per se, but the manner in which it is sent, i.e. CR, linefeed, or the like. I recognise that Martyn is not helpful re iPhone in his latest work. Nor am I, for the same reason, but I'm pretty sure that is where the problem lies and there is some answer in Googleland, or maybe even in the app instructions.

I did get an OK back, though now that I am using the newer code I posted above I have the BLE’s RX in pin 9 and the TX in pin 8.

Your wiring is clearly correct - the way I noted in reply #6, and Martyn, and probably God as well, intended, with Rx>Tx and Tx to Rx, and putting them the other way round is indeed the incomprehensible horseshit I previously mentioned. Martyn is absolutely clear on what pin does what, what it needs to be connected to, and why. He also actually has the experience to back it up.

I hesitantly comment on the OK you receive, but.

IF you get this after you have connected to the terminal, I guess it is coming from the terminal, i.e. it is actually a signal to Arduino that all is well and ready to go. This sounds like a really good idea, and probably confirms what I have been saying about where the problem lies(!)

IF you get this without connecting to the terminal. I submit that you can only get it in response to an AT command, about which you say nothing, but it would mean you are able to send AT commands and your only problem is to be able to send the more complex ones in the proper manner, i.e. the same old problems of CR/ linefeeds and all caps.. This is comprehensively described by Currey.

I withdraw my comment about staying clear of AT mode being a good idea. I still believe it is a good idea, as HM-10 should do what you want in default mode, but there just might be something going on that I don't know about. This is to do with the ROLE commands, but I don't see how they can be different for transmit and receive.

More information here, specifically concerning BLExAR app.

IF you get this after you have connected to the terminal, I guess it is coming from the terminal, i.e. it is actually a signal to Arduino that all is well and ready to go. This sounds like a really good idea, and probably confirms what I have been saying about where the problem lies(!)
Which terminal are you referring to here? The terminal of the iPhone app or the serial monitor? At this point I do believe the wiring is correct, and I do receive “OK” when giving “AT” from the serial monitor, but I have not sent AT commands from the BLExAR app and have not received any responses from any other AT commands.

Looking at that link, it seems like they only describe the one way data transfer (arduino to iPhone app) that I have working. The problem is that I still cannot get it to go the other direction. I apologize if I’m being a bit repetitive, maybe I am not entirely understanding your suggestions.

jmoran08:
IF you get this after you have connected to the terminal, I guess it is coming from the terminal, i.e. it is actually a signal to Arduino that all is well and ready to go. This sounds like a really good idea, and probably confirms what I have been saying about where the problem lies(!)
Which terminal are you referring to here? The terminal of the iPhone app or the serial monitor?

I was actually referring to the terminal on the phone, and the OK was confirming the connection - just a guess.

At this point I do believe the wiring is correct,

I’m sure that is true

and I do receive “OK” when giving “AT” from the serial monitor,

This confirms you are in AT mode, which is actually the default mode for HM-10.

but I have not sent AT commands from the BLExAR

It is not possible to send AT commands from BLExAR. Any comms from the phone requires Bluetooth to be in comms mode, and thus unresponsive to AT commands.

app and have not received any responses from any other AT commands.

I’m afraid I cannot comment any further than I did previously, except reiterate that the OK means you are on the right track. I have had an HM-10 for some years but I have never gotten round to using it, insufficient motivation, but I believe the actual configuration just requires strict adherence to the required format.

Looking at that link, it seems like they only describe the one way data transfer (arduino to iPhone app) that I have working. The problem is that I still cannot get it to go the other direction.

Ditto, except reiterate that I assume the code is kosher and therefore suspect the problem is at the phone end.

. I apologize if I’m being a bit repetitive, maybe I am not entirely understanding your suggestions

Don’t deceived by all those gold stars, we all learn…

I have just realised that you might be able to prove the phone app is the villain.
You might find the following background notes useful.

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

About 95% of this is not relevant to you BUT:

  1. The procedure described uses Bluetooth on HARDWARE SERIAL pins 0,1, i.e. the first method in your original post.
  2. The actual communications commences with Arduino talking to the serial port, irrespective of what is connected.
  3. This means that, while the ultimate objective is Arduino<>phone communications, the programme may be tested using Arduino<>serial monitor. No Bluetooth connected which means that the type of bluetooth is immaterial.

If you can get this programme working with serial monitor, then with phone one-way, but cannot get two-way, I think that proves the problem is at the phone end.

So, super frustrating, but I just discovered that I had an HM-10 module (from Amazon's top choice list) that was actually not the original. I came across this before but thought "why would it be amazon's top choice if it doesn't work". You know what they say about assuming.

After I received the correct module the BLExAR scanner app actually still did not work, so there may be an issue with that app in and of itself. But another iPhone app did successfully communicate both ways with it.

Thank you all for the help. I appreciate it