Bluetooth 4.0 BLE-модуль CC2540 / CC2541 (CC41-A)

Позволяет подключаться Bluetooth 4.0 устройствам и передавать данные через UART

Скачать даташит на BLE модуль CC41-A

По умолчанию скорость соединения 9600, не забудьте указать в конце команд символы новой строки и перевода каретки NL&CR (\r\n).
Список команд можно получить отправив AT+HELP:

********************************************************************
* Command             Description			           *
* ---------------------------------------------------------------- *
* 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+PASS             Get/Set pin code for pairing                 *
* AT+BAUD             Get/Set baud rate		                   *
* AT+LADDR            Get local bluetooth address		   *
* AT+ADDR             Get local bluetooth address		   *
* AT+DEFAULT          Restore factory default			   *
* AT+RENEW            Restore factory default			   *
* AT+STATE            Get current state				   *
* AT+PWRM             Get/Set power on mode(low power) 		   *
* AT+POWE             Get/Set RF transmit power 		   *
* AT+SLEEP            Sleep mode 		                   *
* AT+ROLE             Get/Set current role.	                   *
* AT+PARI             Get/Set UART parity bit.                     *
* AT+STOP             Get/Set UART stop bit.                       *
* AT+START            System start working.			   *
* AT+IMME             System wait for command when power on.	   *
* AT+IBEA             Switch iBeacon mode.	                   *
* AT+IBE0             Set iBeacon UUID 0.            	           *
* AT+IBE1             Set iBeacon UUID 1.            	           *
* AT+IBE2             Set iBeacon UUID 2.            	           *
* AT+IBE3             Set iBeacon UUID 3.            	           *
* AT+MARJ             Set iBeacon MARJ .            	           *
* AT+MINO             Set iBeacon MINO .            	           *
* AT+MEA              Set iBeacon MEA .            	           *
* AT+NOTI             Notify connection event .                    *
* AT+UUID             Get/Set system SERVER_UUID .            	   *
* AT+CHAR             Get/Set system CHAR_UUID .            	   *
* -----------------------------------------------------------------*
* Note: (M) = The command support slave mode only. 		   *
* For more information, please visit http://www.bolutek.com        *
* Copyright@2013 www.bolutek.com. All rights reserved.		   *
********************************************************************

AT+ROLE1 - Перевести модуль в режим Master
AT+HELP выведет другой список команд для режима Master:

********************************************************************
* Command             Description			           *
* ---------------------------------------------------------------- *
* 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+LADDR            Get local bluetooth address		   *
* AT+ADDR             Get local bluetooth address		   *
* AT+DEFAULT          Restore factory default			   *
* AT+RENEW            Restore factory default			   *
* AT+STATE            Get current state				   *
* AT+PWRM             Get/Set power on mode(low power) 		   *
* AT+POWE             Get/Set RF transmit power 		   *
* AT+SLEEP            Sleep mode 		                   *
* AT+ROLE             Get/Set current role.	                   *
* AT+PARI             Get/Set UART parity bit.                     *
* AT+STOP             Get/Set UART stop bit.                       *
* AT+INQ              Search slave model                           *
* AT+SHOW             Show the searched slave model.               *
* AT+CONN             Connect the index slave model.               *
* AT+IMME             System wait for command when power on.	   *
* AT+START            System start working.			   *
* AT+UUID             Get/Set system SERVER_UUID .            	   *
* AT+CHAR             Get/Set system CHAR_UUID .            	   *
* -----------------------------------------------------------------*
* Note: (M) = The command support master mode only. 	           *
* Copyright@2013 www.bolutek.com. All rights reserved.		   *
********************************************************************

AT+INQ поиск доступныйх Slave модулей
AT+SHOW выводит результаты поиска из кэша
AT+CONN[n] подключение к устройству по индексу

Код для Master модуля

#include 
 
SoftwareSerial BTSerial(4, 5);
 
void setup() {
   Serial.begin(9600);
   BTSerial.begin(9600);
   BTSerial.write("AT+DEFAULT\r\n");
   BTSerial.write("AT+RESET\r\n");
   BTSerial.write("AT+NAME=Controller\r\n");
   BTSerial.write("AT+ROLE1\r\n");
   BTSerial.write("AT+TYPE1"); //Simple pairing
}
 
void loop()
{
   if (BTSerial.available())
       Serial.write(BTSerial.read());
   if (Serial.available())
       BTSerial.write(Serial.read());
}

Код для Slave модуля

#include 
 
SoftwareSerial BTSerial(4, 5);
char cmd[32] = {0};
 
void setup() {
   Serial.begin(9600);
   BTSerial.begin(9600);
   BTSerial.write("AT+NAME=Remote\r\n");
   BTSerial.write("AT+TYPE1"); //Simple pairing
}
 
void loop()
{
   static int iter = 0;
   if (BTSerial.available())
   {
       cmd[iter] = BTSerial.read();
 
       //if CRLF (CC41A EOM)
       if((cmd[iter] == 10) && (cmd[iter-1]==13))
       {
   
           Serial.println(cmd);             //dump to serial console
 
           BTSerial.write("Command executed:");
           BTSerial.write(cmd); BTSerial.write("\n");
     } else {
   
     }
   }
   
   if(Serial.available()){
     BTSerial.write(Serial.read());
   }
}


Написать отзыв

Примечание: HTML разметка не поддерживается! Используйте обычный текст.
    Плохо           Хорошо

Bluetooth 4.0 BLE-модуль CC2540 / CC2541 (CC41-A)

  • Модель: CC2541, CC41-A
  • Наличие: 9
  • 600 руб.


Теги: Bluetooth 4.0, BLE, модуль, CC2540, CC2541, CC41-A