1

I'm having issues when trying to use bluetooth on my project. On previous version I used the HC-05 module for bluetooth and it gives me a simple serial connection right after any device connects. Now the project evolved and we opted on using SIM800H because it gives us GSM+Bluetooth.

When I connect any android device it gives me some profiles but never SPP. I can pair normally but when using any SPP server app (https://stackoverflow.com/a/4037619/2637661) I can never send or get data from my device. If I start the connection from the Android app, it says that it's connecting while the SIM800 gives me the URC and I respond:

+BTCONNECTING: "34:c7:31:aa:37:5b","SPP"
AT+BTACPT=1
OK
+BTCONNECT: 1,"Android",34:c7:31:aa:37:5b,"SPP"

But it stays on server mode and I can't use the commands AT+BTSPPSEND or AT+BTSPPGET, as the documentation says.

On the other hand, if I start the connection from my device just like the docs say:

AT+BTCONNECT=1,4 // Device is 1 and SPP profile is 4
OK
AT+BTSPPSEND
>I type anything here + ctrl+z
SEND FAIL

and get nothing on the Android side.

Plus in both cases the connection drops after something like 30s and I can't reestablish it unless I turn the SIM800H off and on again.

Got no success using the APP mode either (sending the string "SIMCOMSPPFORAPP" right after connection succeeds for transparent communication).

The SIM800H firmware version is

AT+CGMR
Revision:1309B07SIM800H32_BT

and I tried using the following apps

Bluetooth Terminal

Bluetooth spp pro

BlueSPP

The GSM side works flawlessly and I can send/receive TCP messages everytime I try.

Does anyone have any kind of experience using this module? Thanks for reading!

UPDATE:

I'm using a simple sketch in order to talk with the module's serial, don't know if it's relevant but here it goes.

#define SIM800_POWER 23

void setup() {
  Serial.begin(9600);
  Serial1.begin(19200);
  Serial.print("Setting all up");
  pinMode(SIM800_POWER, OUTPUT);
  Serial.print(".");
  delay(500);
  digitalWrite(SIM800_POWER, HIGH);
  Serial.print(".");
  Serial.println("OK");
}

void loop() {
  if(Serial1.available()){
    Serial.write(Serial1.read());
  }
  if(Serial.available()){
    Serial1.write(Serial.read());
  }
}

And what I get after trying Andrii's answer:

Setting all up..OK
AT
OK
AT
OK
AT
OK
AT+BTPOWER=0
OK
AT+BTPOWER=1
OK
AT+BTCONNECT=1,4
OK
+BTCONNECT: 1,"Will",d4:87:d8:77:37:0b,"SPP"
AT+BTSTATUS?
+BTSTATUS: 5
P: 1,"Will",d4:87:d8:77:37:0b
C: 1,"Will",d4:87:d8:77:37:0b,"SPP"

OK
AT+BTSPPSEND
> SIMCOMSPPFORAPP
SEND FAIL
Community
  • 1
  • 1
  • 1) is your Android device really number 1 (get list of available devices via AT+BTSTATUS? command)? – Andrii Omelchenko Jan 15 '18 at 15:50
  • Yes, as I tried with many devices I took the time to unpair every other device. `AT+BTSTATUS? +BTSTATUS: 5 P: 1,"Will",d4:87:d8:77:37:0b` – William Monteiro Jan 15 '18 at 16:15
  • No! No! No! You should [never, never, never, never, never, never, never, never, never, never, ever use delay like that](https://stackoverflow.com/a/46064206/23118). You MUST **read** and **parse** the responses given back by the modem, otherwise you will [abort](https://stackoverflow.com/a/16404193/23118) the commands. – hlovdal Jan 16 '18 at 17:26
  • I made this sketch to mess around with my SIM800H module and learn how it works. Neither this code or my production code that controls all other devices (RTC, SD card...) uses delay between the reads. Thanks for highlighting this tough, it **is** important. – William Monteiro Jan 17 '18 at 18:00

1 Answers1

1

Seems AT+BTSPPSEND without any parameters is only for AT-command send from client (your SIM800H) to server (other SIM800, not your Android device unless your Android device implements AT-command support). For data sending you should use AT+BTSPPSEND and after receiving > symbol send SIMCOMSPPFORAPP keyword and then, after receiving SEND OK response send command AT+BTSPPSEND=<LENGTH_OF_YOUR_DATA> and then, after receiving > symbol, send your data until Ctrl+Z code e.g.:

AT+BTSPPSEND
> SIMCOMSPPFORAPP
SEND OK

AT+BTSPPSEND=5
> HELLO
SEND OK

^Z

where HELLO - is your data, and 5 in AT+BTSPPSEND=5 is length of HELLO string. Details in SIM800H_BT_Application_Note.

UPDATE Selected by bold small, but important part of answer (thanks to hlovdal)

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
  • I suppose I should use it after connecting as client `AT+BTCONNECT=1,4` But I get the same behavior. `AT+BTCONNECT=1,4 OK +BTCONNECT: 1,"Will",d4:87:d8:77:37:0b,"SPP" AT+BTSPPSEND > SIMCOMSPPFORAPP SEND FAIL ` – William Monteiro Jan 15 '18 at 16:20
  • I should have set `AT+BTSPPCFG="TT",0` before, as this solved my problem along with your answer. Thank you so much! – William Monteiro Jan 15 '18 at 18:19
  • `after receiving > symbol` is an extremely important concept that I want to highlight with this comment. Actually it is not just one `'>'` character but it is four characters, `"\r\n> "`, and sending anything before receiving them (or possibly a final result code) is a big mistake. More details in the first part of [this answer](https://stackoverflow.com/a/15591673/23118). – hlovdal Jan 16 '18 at 17:37