Difference between revisions of "Template:Pico-BLE Guide"

From Waveshare Wiki
Jump to: navigation, search
 
(32 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Software Setup==
+
 
{{Pico Get Start}}
+
<!--
==Examples==
+
==Text Tutorial(to be continued...)==
 +
Basic introduction
 +
----
 +
[https://pico.wiki/index.php/2021/04/27/getting-started-with-raspberry-pi-pico-basic-intro.html Raspberry Pi Pico Basic introduction]<br>
 +
[https://pico.wiki/index.php/2021/04/06/getting-started-with-raspberry-pi-pico-gpio.html 【MicroPython】machine.Pin function]<br>
 +
[https://pico.wiki/index.php/2021/04/06/getting-started-with-raspberry-pi-pico-pwm.html 【MicroPython】machine.PWM function]<br>
 +
[https://pico.wiki/index.php/2021/04/06/getting-started-with-raspberry-pi-pico-adc.html 【MicroPython】machine.ADC function]<br>
 +
[https://pico.wiki/index.php/2021/05/28/getting-started-with-raspberry-pi-pico-uart.html 【MicroPython】machine.UART function]<br>
 +
[https://pico.wiki/index.php/2021/06/08/getting-started-with-raspberry-pi-pico-i2c.html 【MicroPython】machine.I2C function]<br>
 +
[https://pico.wiki/index.php/2021/06/09/getting-started-with-raspberry-pi-pico-spi.html 【MicroPython】machine.SPI function]<br>
 +
[http://pico.wiki/index.php/2021/01/27/pico-c-c-windows%e6%95%99%e7%a8%8b1.html 【C/C++】 Windows Tutorial 1——environment setup]<br>
 +
[http://pico.wiki/index.php/2021/01/27/pico-c-c-windows%e6%95%99%e7%a8%8b2.html 【C/C++】 Windows Tutorial 2——new project]<br>
 +
===Open Source Demo===
 +
[https://github.com/waveshareteam/Pico_MircoPython_Examples MircoPython Video Firmware (github)]<br>
 +
[https://www.waveshare.net/w/upload/b/b2/Raspberry_Pi_Pico_Demo.zip MicroPython Firmware/Blink demo(C)]<br>
 +
[https://github.com/raspberrypi/pico-examples/ Raspberry Pi C/C++ demo example (github)]<br>
 +
[https://github.com/raspberrypi/pico-micropython-examples Raspberry Pi micropython demo example (github)]
 +
-->
 +
 
 +
=Examples=
 
For the Pico-BLE module, we provide an serial example. Hereby we take C codes to explain the function.
 
For the Pico-BLE module, we provide an serial example. Hereby we take C codes to explain the function.
===Low-level hardware interface===
+
==Hardware Interface==
====BLE.c====
+
===BLE.c===
The Bluetooth module initialization function mainly judges whether the Bluetooth module is successfully connected to the mobile phone, whether the notify function is enabled, querying the baud rate of the Bluetooth module, judges whether it is in low power mode, name, address, and modifying the name of the module
+
The Bluetooth module initialization function mainly judges whether the Bluetooth module is successfully connected to the mobile phone, whether the notify function is enabled, querying the baud rate of the Bluetooth module, judges whether it is in low power mode, name, address, and modifying the name of the module.
 
  void BLE_Init()
 
  void BLE_Init()
Execute and process BLE commands
+
Execute and process BLE commands.
 
<pre>
 
<pre>
 
uint8_t Cmd_Process(uint8_t *data)
 
uint8_t Cmd_Process(uint8_t *data)
 
     data: the address of the command pointer to send
 
     data: the address of the command pointer to send
 
</pre>
 
</pre>
Transparent transmission receiving function, what data the mobile phone sends to the module, the module receives and returns the same data through this function
+
Transparent transmission receiving function, what data the mobile phone sends to the module, the module receives and returns the same data with this function.
 
<pre>
 
<pre>
 
void UART_RX()    Query receive
 
void UART_RX()    Query receive
Line 18: Line 37:
 
</pre>
 
</pre>
  
===Parameter modification===
+
==Parameter Modification==
====BLE.h====
+
===BLE.h===
 
<pre>
 
<pre>
 
#define UART_ID uart0      Pico serial port selection
 
#define UART_ID uart0      Pico serial port selection
Line 30: Line 49:
 
#define BLE_MODE_PIN 15    Bluetooth module status detection pin
 
#define BLE_MODE_PIN 15    Bluetooth module status detection pin
 
</pre>
 
</pre>
===Module command===
+
 
====CMD.h====
+
==Module Command==
 +
===CMD.h===
 
For specific use, please refer to the user manual.
 
For specific use, please refer to the user manual.
 +
 +
=Demonstration=
 +
==Mobile Phone APP Demo==
 +
<!--
 +
Connect Pico and Pico-BLE to open the python demo and run.<br/>
 +
[[File:Pico-BLE01.png]]<br/>
 +
Open the PicoGO software on the mobile phone (this is just a demonstration, you can download any Bluetooth APP in the app store).<br/>
 +
[[File:Pico-BLE02.png]]<br/>
 +
Click on Bluetooth Control.<br/>
 +
[[File:Pico-BLE03.png]]<br/>
 +
Click Search in the upper right corner.<br/>
 +
[[File:Pico-BLE04.png]]<br/>
 +
Click the serial port mode (the request pairing interface will pop up later, no password is required).<br/>
 +
[[File:Pico-BLE05.png]]<br/>
 +
Click pairing, the following will appear on the computer and mobile phone.<br/>
 +
[[File:Pico-BLE06.png]]<br/>
 +
[[File:Pico-BLE07.png]]<br/>
 +
Enter the data on the mobile phone and click send (the interface you send will be displayed on the computer).<br/>
 +
[[File:Pico-BLE08.png]]<br/>
 +
[[File:Pico-BLE09.png]]<br/>
 +
PS: APPs using the BLE protocol on the mobile phone need to open the notify interface.<br/>
 +
-->
 +
Connect the Pico and Pico-BLE:<br>
 +
Open the Python demo and run: 
 +
[[File:Pico-BEL04.jpg|thumb|none]]
 +
Open the software on the smartphone. (This is just a demo, you can download any Bluetooth APP from the app store.)
 +
[[File:Pico-BEL-7.jpg|thumb|none]]
 +
Click to pair:
 +
[[File:Pico-BEL-8.jpg|thumb|none]]
 +
Click on Pairing and the following will appear on the computer and the phone:
 +
[[File:Pico-BEL-9.jpg|thumb|none]]
 +
[[File:Pico-BEL-10.jpg|thumb|none]]
 +
Enter the data on your cell phone and click send (your computer will show you the screen where you sent it):
 +
[[File:Pico-BEL-5.jpg|thumb|none]]<br>
 +
[[File:Pico-BEL012.jpg|thumb|none]]<br>
 +
PS: Apps using the BLE protocol on the mobile side need to open the notify interface.

Latest revision as of 08:57, 6 February 2024


Examples

For the Pico-BLE module, we provide an serial example. Hereby we take C codes to explain the function.

Hardware Interface

BLE.c

The Bluetooth module initialization function mainly judges whether the Bluetooth module is successfully connected to the mobile phone, whether the notify function is enabled, querying the baud rate of the Bluetooth module, judges whether it is in low power mode, name, address, and modifying the name of the module.

void BLE_Init()

Execute and process BLE commands.

uint8_t Cmd_Process(uint8_t *data)
    data: the address of the command pointer to send

Transparent transmission receiving function, what data the mobile phone sends to the module, the module receives and returns the same data with this function.

void UART_RX()     Query receive
void UART_RX_IRQ() Interrupt receive

Parameter Modification

BLE.h

#define UART_ID uart0       Pico serial port selection
#define BAUD_RATE 115200    Serial port baud rate selection
#define DATA_BITS 8         Serial port data bits
#define STOP_BITS 1         Serial port data stop bits
#define PARITY UART_PARITY_NONE  Whether the serial port performs parity check
#define UART_TX_PIN 0       Pico serial port TX pin selection
#define UART_RX_PIN 1       Pico serial port RX pin selection
#define BLE_MODE_PIN 15     Bluetooth module status detection pin

Module Command

CMD.h

For specific use, please refer to the user manual.

Demonstration

Mobile Phone APP Demo

Connect the Pico and Pico-BLE:
Open the Python demo and run:

Pico-BEL04.jpg

Open the software on the smartphone. (This is just a demo, you can download any Bluetooth APP from the app store.)

Pico-BEL-7.jpg

Click to pair:

Pico-BEL-8.jpg

Click on Pairing and the following will appear on the computer and the phone:

Pico-BEL-9.jpg
Pico-BEL-10.jpg

Enter the data on your cell phone and click send (your computer will show you the screen where you sent it):

Pico-BEL-5.jpg


Pico-BEL012.jpg


PS: Apps using the BLE protocol on the mobile side need to open the notify interface.