GithubHelp home page GithubHelp logo

sp_bt's Introduction

SP_BT Module User Guide

中文

Directory Structure

Directory Description
doc Reference documentation
img Images
script Maixpy script example
src C program example based on the standalone sdk

Introduce

SP_BT is a Bluetooth serial transmission module with ultra-low power and high reliability.

  • Bluetooth version:Support BLE 5.0 (compatible with BLE4.0, BLE4.2)

  • Default Baud Rate:9600

    See Specification for more information

Pin figure

Mode of connection

MCU:FUN(IO) SP_BT
UART:TXD(IO_7) RXD
USRT:RXD(IO_6) TXD
1.8-3.3V 3.3V
GND GND

MCU configuration

IO port configuration

Configure IO port corresponding to MCU as UART function pin.

  • C

    // set uart rx/tx func to io_6/7
    fpioa_set_function(6, FUNC_UART1_RX + UART_NUM * 2);
    fpioa_set_function(7, FUNC_UART1_TX + UART_NUM * 2);
  • MaixPy

    # set uart rx/tx func to io_6/7
    fm.register(6,fm.fpioa.UART1_RX)
    fm.register(7,fm.fpioa.UART1_TX)

UART initialization

The UART initialization baud rate must be consistent with the SP_BT baud rate. The AT instruction can be used to change the Baud rate of SP_BT, which defaults to 9600.

  • C

    uart_init(UART_DEVICE_1);
    uart_configure(UART_DEVICE_1, 9600, 8, UART_STOP_1, UART_PARITY_NONE);
  • MaixPy

    uart = UART(UART.UART1,9600,8,1,0,timeout=1000, read_buf_len=4096)

SP_BT configuration

AT instruction list

Order Description
AT+BAUD<Param> Baud rates (0-6 represent different baud rates)
AT+NAME<Param> Boardcast name
AT+SLEEP<param> Sleep

See JDY-23-V2.1.pdf for more information

AT instruction usage

  • Process

    1. Send AT instruction
    2. Receive the reply
    3. Determines whether the setup was successful
  • C

    //change the name of sp_bt module to MAIXCUBE
    uart_send_data(UART_NUM, "AT+NAMEMAIXCUBE\r\n", strlen("AT+NAMEMAIXCUBE\r\n")); //send AT order
    msleep(100);
    ret = uart_receive_data(UART_NUM, rcv_buf, sizeof(rcv_buf)); //receive response
    if(ret != 0 && strstr(rcv_buf, "OK"))
    {
       printk(LOG_COLOR_W "set name success!\r\n");
    }
    
    // get the name of sp_bt module
    uart_send_data(UART_NUM, "AT+NAME\r\n", strlen("AT+NAME\r\n")); //send AT order
    msleep(100);
    ret = uart_receive_data(UART_NUM, rcv_buf, sizeof(rcv_buf)); //receive response
    if(ret != 0 && strstr(rcv_buf, "NAME"))
    {
       printk(LOG_COLOR_W "get name success!\r\n");
    }
  • MaixPy

    #change the name of sp_bt module to MAIXCUBE
    uart.write("AT+NAMEMAIXCUBE\r\n") #send AT order
    time.sleep_ms(100)
    read_data = uart.read() #receive response
    if read_data:
        read_str = read_data.decode('utf-8')
        count = read_str.count("OK")
        if count != 0:
            uart.write("set name success\r\n")
    
    # get the name of sp_bt module
    uart.write("AT+NAME\r\n") #send AT order
    time.sleep_ms(100)
    read_data = uart.read() #receive response
    if read_data:
        read_str = read_data.decode('utf-8')
        count = read_str.count("NAME")
        if count != 0:
            uart.write("get name success\r\n")

Note that you must add \r\n after sending AT instruction

Result

Using BLE Utility to connect the device to do the send and receive test results are as follows:

Runtime environments

Language Board SDK/Firmware version
C MaixCube kendryte-standalone-sdk v0.5.6
MaixPy MaixCube maixpy v0.5.1

LICENSE

See LICENSE fil.

Othre information

Version Editor
v0.1 vamoosebbf

sp_bt's People

Contributors

vamoosebbf avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.