Problem with Serial communication to HM-10

I am trying to test SoftwareSerial communication with BLE HM-10 module (Chinese rip off I guess).

Pins are OK and module returns “OK” if I send AT directly (bluetooth.println(“AT”);). However, if I send it through serial, it just does not work.

Code:

#include <SoftwareSerial.h>

int bluetoothTx = 10;  // TX
int bluetoothRx = 11;  // RX

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup() {
  // put your setup code here, to run once:
  Serial.begin (9600);
  Serial.println("Hey");
  bluetooth.begin(115200);
  delay(100);
  bluetooth.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (bluetooth.available())
  {
    Serial.print((char)bluetooth.read());
  }

  if (Serial.available())
  {  
    Serial.println (Serial.readString());
    bluetooth.println(Serial.readString());
  }
}

Why have you got

 bluetooth.begin(115200);

followed by 9600 ?

I don't think SoftwareSerial will work at 115200.

...R

I got that part from stackoverflow. Deleting the top line does not chage anything.

It seems the problem is a fake HM-10 module. It kind not really works, that's it.

Hi

I got that part from stackoverflow. Deleting the top line does not chage anything.

No, don't delete any line change the 115200 that Robin2 pointed out to 9600.

Tom..... :)

TomGeorge: No, don't delete any line change the 115200 that Robin2 pointed out to 9600.

Tom, there was already another line with 9600 so deleting that line is OK

...R

puqq:
Pins are OK and module returns “OK” if I send AT directly (bluetooth.println(“AT”);). However, if I send it through serial, it just does not work.

Can you explain in as much detail as possible what you mean by this?
Include details of all connections and post the code that worked.

…R