Sending AT commands with no line ending for HM-10

Hi,
I need to use HM-10 with Arduino Uno or Nano.
I'm not able to figure out how to send AT commands and read the reply.

Here's what I've tried so far:

#include <SoftwareSerial.h>
 
SoftwareSerial blueToothSerial(0,1); // RX, TX
 
void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  Serial.println("Serial began");
  blueToothSerial.begin(9600);
  delay(2000);

}
 
void loop()
{
  Serial.println("looping...");
  blueToothSerial.print("AT+DISC?");
  delay(5000);
  if (blueToothSerial.available())
  {
    Serial.println("bluetooth serial available");
    Serial.write(blueToothSerial.read());
  }
  if (Serial.available())
    blueToothSerial.write(Serial.read());
}

However, I'm not able to read any reply, I feel the command is not firing. The execution doesnt go inside if(blueToothSerial.available())

dushyantbangal:

#include <SoftwareSerial.h>

SoftwareSerial blueToothSerial(0,1); // RX, TX

Fatal mistake. You are using hardware serial pins 0,1 for software serial. Put it somewhere else, like pins 2,3.

Nick_Pyner:
Fatal mistake. You are using hardware serial pins 0,1 for software serial. Put it somewhere else, like pins 2,3.

No, I've tried it on 3,4 and many others.

Read reply #1 again.

dushyantbangal:
No, I've tried it on 3,4 and many others.

I know this is a bit old, but I had the same issue and I kept finding this thread when searching.

For me, using blueToothSerial.write (instead of blueToothSerial.print) worked (and yes, required pins other than 0/1). My module doesn't require the new line or carriage return characters, you'll need to add those if yours does.