BC04C

From ElectroDragon Wiki
Revision as of 23:04, 28 November 2016 by Chao (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

AT Commands

  • Format for inquiry: Add ? after At commands, for example, AT+CHK?, AT+STOP?
  • Format for setting: add parameter after AT commands, AT+BAUD1, AT+STOP1
  • All the settings will store in the module and keep same after restart
Function Commands Parameter Example
1 General AT check AT - -
2 Set Baud rate AT+BAUD 1-1200; 2-2400; 3-4800; 4-9600; 5-19200; 6-38400; 7-57600; 8-115200 AT+BAUD1 return: OK+SetBaud:1200
3 Set check bit AT+CHK 0: NO CRC, 1: ODD, 2:EVEN -
4 Set Stop bit AT+STP 1:1Stop, 2:2stop -
5 Set UART AT+UART[para1][para2][para3] para1:baud rate, para2:CRC, para3:stop -
(Not available) Set module discoverable status AT+ DISC 0:searchable and connectable, 1:only searchable, 2:connectable only -
(Not available) Set Pio0 function AT+KEY 0: Cancel current status. 1: Cancel current status and restore factory setup. -
(Not available) Set PIO1 output status AT+LED 0:Unconnected Output 500ms High 500ms Low, Connected output High. 1:Unconnected output Low, Connected output High. -
6 Set module PIO Pins output status AT+PIO Length 10, every bit value is 1 or 0. 0: output low; 1:output high AT+PIO? return OK+PIO0000000000; Setup PIO2 and PIO3output high and others output low: AT+PIO1100000000
6.1 Set PIO pins output high or low AT+PIO[para1][para2] Para1 is which PIO pin you want to Query/Set Value: 2,3,4,5,6,7,8,9,A,B. Para2 is Query or setup value. 0 is low and 1 is high AT+PIO21
7 Set name AT+NAME
8 Set name AT+DEFAULT
9 Restart AT+RESTART
10 Set Master and Slaver Role AT+ROLE M: Master S: Slaver -
11 Set Pin Code AT+PIN Max length is 12, Allow A~Z -
13 Clear pair data AT+CLEAR -
(Not available) Scan slave device AT+SCAN? Notice: Work with “AT+IMME0” and “AT+ROLEM” -
15 connect to device AT+CONN -
14 connect to last device AT+CONLAST -
(Not available) Connect to a slave device MAC address AT+LNK Notice: Work with “AT+IMME0” and “AT+ROLEM” -
21 Query Last Connected Device Address AT+RADD? - -
19, 20 Query module address AT+LADD? and AT+ADDR? - -
22 Query/Set Module work type AT+IMME 0: When module is powered on, only respond the AT Command, don’t do anything. until AT + WORK is received 1: When power on, work immediately Notice: This command is only used for Master Role. -
23 Start work AT+WORK
24 Query/Set module connect remote device timeout value AT+TCON Para1 allowed value: 0000~9999 Unit is second. Default: 0000 Connect

forever || -

25 check or set device type AT+COD
26 Query/Set Module Work Mode AT+TYPE 0:Transmission Mode; 1:Remote Control Mode; 2:PIO Collection Mode; Default: 0 -
(Not available) Query/Set report PIO states string delay time(unit ms) AT+TPIO Para1 value is between 0000 and 9999 ms If value >0, when PIO states is changed, module will send PIO states string to remote device delay this value. Default: 0 send once -
28 Switch Remote Control Mode to Transmission Mode(Only this time) AT+START - -
29 Query/Set Buffer save parameter AT+BUFF 0: Not save 1:Save Default: 0 -
(Not available) Query/Set Module Notification AT+NOTI 0: Don’t notify(default) 1:Notify when connected and disconnected -

PIO0 (KEY) and PIO1 LED function

  • PIO0 key: clear pairing info when not connected, disconnect, restart and enter into search mode when it is connected.
  • RST button: Reset the module
  • PIO1 LED: blink when not connected, and stay high when connected.

Working Mode

There are three types of working mode, see our videos to understand how it work firstly:

  • Transmission mode: data can transfer via bluetooth remotely
  • GPIO set mode (w/transmission mode): BC04C external GPIO can set remotely, first set working mode to 1 (AT+TYPE1) and use AT+PIO command to set GPIO.
  • GPIO monitor mode (w/transmission mode): when external GPIO TTL status are changed, this info will send back, in a certain time frame, you need set AT+TYPE2, and AT+TPIO1000 for timing, 1000 means 1000 ms.

Demo code

#include <SoftwareSerial.h>
SoftwareSerial BTSerial(2, 3); // RX | TX
void setup()
{
  Serial.begin(9600);
  Serial.println("Enter AT commands:");
  BTSerial.begin(9600);  
}
void loop()
{

  if (BTSerial.available())
    Serial.write(BTSerial.read());
  if (Serial.available())
    BTSerial.write(Serial.read());
}

Note

  • Use SSOM32 for testing (Un-tick "send new" option), the module do not need any simulate end after commands (\r\n).
  • In arduino use first option on line ending
  • When connected with other bluetooth devices, module will enter into data transmission mode, not command mode
  • AT Command will not work on Data transmission mode (LED stay on)

First time usage and Control

  • On the first time use, if you want to control the GPIOs, you should not connect the module with devices with BlueSPP first, otherwise when you connect to it, the module is working on data transfer mode.
  • Disconnect any devices, and use a normal USB-TTL to setup working mode first, re-power the module and setup will be remembered inside, now you can connect and control.