Recommended Bluetooth module based on BLE5.0 protocol with small package and low power consumption

Today I recommend a small size, low power consumption Bluetooth module PW02 (Pengwei IoT) based on the BLE5.0 protocol .

First, let's take a look at the Bluetooth module and its package size .
Insert picture description here
Insert picture description here

  The module is a serial Bluetooth, the baud rate defaults to 9600 , and it supports AT command set . One thing is that the Bluetooth module does not save task configuration information. Once the module is powered off , all information will be restored to default data .

  The transmission distance can reach 30~50m .

  The default mode is transparent transmission mode after power-on , and you can jump to the AT command mode through the AT command set .

  The connection diagram between the Bluetooth module and the MCU is as follows: (P03 can control whether it is low-power mode or full-speed mode. RESET is the reset function. P05 and P01 are RX and TX respectively )
Insert picture description here

  At present, if you use it as a debugging device (interconnect with your mobile phone to view print information), you only need to understand the instructions for these few days.
Enter and exit AT command set mode
Insert picture description here

Modify module name
Insert picture description here

Modify the specific procedure of baud rate
Insert picture description here
to realize the modification.

First define the Bluetooth command to be sent

unsigned char  BlueToothCmd[4][20]=
{
    
    
  {
    
    "AT:STR\x0d\x0a"},                                                              
  {
    
    "AT:NAME=10001\x0d\x0a"},                                                         
  {
    
    "AT:BAUD=7\x0d\x0a"},                                                        
  {
    
    "AT:END\x0d\x0a"},                                                                                                              
};

  After that, it is judged whether the returned data is correct to exit the judgment . You can use the strstr function . If the recovered character string contains the character string, it means that the recovery is correct, jump out of judgment, and execute the next instruction.

  The reception of the serial port has been introduced before, and you can read the previous blog post .

int8_t StateCheck(char *data)
{
    
       
    char *point;
     point = strstr(data, "Changed");      // ERR
    if(point != NULL)
    {
    
    
      return 20;
    }
    
     point = strstr(data, "OK+Set");      // ERR
    if(point != NULL)
    {
    
    
      return 21;
    }
    
    point = strstr(data, "AT:END");      // ERR
    if(point != NULL)
    {
    
    
      return 22;
    }
    
    point = strstr(data, "Cpri");      // ERR
    if(point != NULL)
    {
    
    
      return 23;
    }
    
    point = strstr(data, "Opri");      // ERR
    if(point != NULL)
    {
    
    
      return 24;
    }
    point = strstr(data, "GetSig");      // ERR
    if(point != NULL)
    {
    
    
      return 25;
    }
    
    point = strstr(data, "ERR");      // ERR
    if(point != NULL)
    {
    
    
      return 0;
    }
    // rtn:1
    point = strstr(data, "OK");       // OK
    if(point != NULL)
    {
    
    
      return 1;
    }

    return -1;
}

  Note: The Bluetooth module currently only supports as a slave to connect to a mobile phone or computer, and does not support the connection between the module and the module .

Guess you like

Origin blog.csdn.net/qq_34430371/article/details/107018460