Wireless Bluetooth Module for your Arduino

If you’d like to wirelessly attach your Arduino to another device (such as a phone or tablet) via bluetooth, I’d recommend the serial bluetooth module from Elecrow.com.

Here is what they look like:

 

Serial Bluetooth Module

 

The module has firmware from BOLUTEK. The PDF document with all of the available BOLUTEK commands is BLK-MD-BC04-B_AT COMMANDS . I also document the AT commands in the sample source code (aduino sketch) below.

There was no sample code that I could find for using these with an Arduino so I wrote my own. The following sketch (load it into any arduino) sets up the module in slave mode so you can connect to it with any blue tooth enabled device. The PIN code is 232323 as you can see from the source.

 

# Blue Tooth Module Code
# from earl@microcontrollerelectronics.com
#
#include <SoftwareSerial.h>   //Software Serial Port
#define RxD 6
#define TxD 7
#define INTERVAL 10000
long previousMillis = 0;
char recvChar;

SoftwareSerial blueToothSerial(RxD,TxD);

void setup() {
  Serial.begin(9600);
  while (!Serial);
  delay(2000);
  pinMode(RxD, INPUT);
  pinMode(TxD, OUTPUT);
  setupBlueToothConnection();
}

void BT_cmd(String cmd) {
  char recvChar;
  if (cmd != "") {
    blueToothSerial.print(cmd + "\r\n");
    delay(200);
  }
  while(blueToothSerial.available()) {
    recvChar = blueToothSerial.read();
    Serial.print(recvChar);
  }
}

void loop() {
  if(millis() - previousMillis > INTERVAL) {
    previousMillis = millis();
    BT_cmd("AT+STATE");
    BT_cmd("AT+LSP");
  }
  if(blueToothSerial.available()){
    recvChar = blueToothSerial.read();
    Serial.print(recvChar);
  }
  if(Serial.available()){
    recvChar  = Serial.read();
    blueToothSerial.print(recvChar);
  }
}

void setupBlueToothConnection() {
/*
AT                   Check if the command terminal work normally
AT+RESET             Software reboot
AT+VERSION           Get firmware, bluetooth, HCI and LMP version
AT+HELP              List all the commands
AT+NAME              Get/Set local device name
AT+PIN               Get/Set pin code for pairing
AT+BAUD              Get/Set baud rate
AT+CLEAR             Remove the remembered remote address
AT+LADDR             Get local bluetooth address
AT+RNAME             Get remote device name
AT+DEFAULT           Restore factory default
AT+CMODE             Get/Set connection mode
AT+BIND              Get/Set bind bluetooth address
AT+COD               Get/Set local class of device
AT+IAC               Get/Set inquiry access code
AT+ROLE              Get/Set master or slave mode
AT+STATE             Get current state
AT+SENM              Get/Set security and encryption mode
AT+IPSCAN            Get/Set page and inquiry scan parameters
AT+SNIFF             Get/Set sniff power table parameters
AT+LOWPOWER          Start/Stop low power mode
AT+UARTMODE          Get/Set uart stop bits and parity
AT+ENABLEIND         Enable/Disable Indication print
AT+LSP               List Paired Device List
AT+RESETPDL          Reset Paired Device List
AT+REMOVEPDL         Remove one entry from Paired Device List
AT+SUPERVISION       Get/Set supervision timeout
AT+AUTOINQ           Start/Stop auto inquiry
AT+INQ               Start inquiry
AT+INQC              Cancel ongoing inquiry
(M)AT+AUTOCONN       Start/Stop auto connection
(M)AT+INQM           Get/Set inquiry parameters
(M)AT+CONNECT        Connect to a remote device by BD address
*/

  blueToothSerial.begin(9600);
  delay(1000);
  BT_cmd("AT+ENABLEIND1");         //Enable Indications
  BT_cmd("AT+ROLE0");              //set the bluetooth to work in slave mode
  BT_cmd("AT+NAMEArduinoBTSlave"); //set the bluetooth name
  BT_cmd("AT+PIN232323");          //set PIN
  BT_cmd("AT+AUTOINQ1");           //Automatic Search
  Serial.println("\r\nThe slave bluetooth is inquirable!");
}

2 comments

    • shawnSmith on January 28, 2015 at 9:37 pm
    • Reply

    Thanks for letting me know about this module. I’m building a Bluetooth controlled coffee machine with arduino and I’ve been looking for an easy way to connect it. but I’m having trouble choosing between all the chips out there. Have you looked at this bluetooth chipset guide ? Do you think it makes sense to maybe use an nRF51822 connected to Arduino?

    • earl on January 29, 2015 at 3:21 pm
      Author
    • Reply

    Thanks for sharing that guide. It is interesting. The nRF51822 would be a good choice too as it is supported on the arduino here for example. Besides the chip set, I’d look at how it is packaged in the ‘module’, size and price too of course.

Leave a Reply

Your email address will not be published.