Example for Arduino-BLE Connection
Last revision 2026/01/26
This article explains how to establish connections between Arduino and BLE4.1 devices, covering key components like smartphone apps, P2P and star network modes, and wireless programming, while ensuring efficient Bluetooth communication and low power consumption.
Bluetooth Connection
Before using BLE4.1 series devices, it is better to know some key buttons first.
-
BOOT: Update Bluetooth firmware/Enable the approach connection (<10cm).
- Firmware update: Press and hold the "BOOT" button until you plug USB cable, entering firmware update mode. For any enquiry, please refers to the part: Firmware Update. (You can release your hand after you plugged the USB cable.)
-
Approach connection**: Press and hold the host BOOT button, approach the slave Bluetooth device to connect.
-
WAKEUP: the button can wake up the device from low-power consum[ption mode (you can also connect this pin to MCU to realize the same function)
-
RST: BLE4.1 reset button
Below is the BLE4.1 minimum system circuit diagram for your reference: Fig1: the BLE4.1 minimum system circuit diagram.

Smartphone Bluetooth Connection
- Android Terminal and IOS Terminal
- BlunoBasicDemo Android,
- Android source code (DFRobot)
- LightBlue IOS
- Blynk IOS
Different from the traditional Bluetooth (such as Bluetooth headset), BLE4.1 need specified eigenvalue and device service ID to connect smartphone. The direct connection between BLE and smartphone device manager will lead to communication problems.
Therefore, it needs a the third party APP, such as BunoBasicDemo (published by DFRobot), BLE Device Monitor from TI .etc. In this section, we'll take BunoBasicDemo published by DFRobot as an example.
-
Set BLE4.1 as peripheral device with command AT+ROLE=ROLE_PERIPHERAL. Set connection mode as P2P by AT+NETWORK=P2P command and restart BLE4.1 (power off and restart).
-
Open BunoBasicDemo app, click SCAN, then we'll see the scanned BLE4.1 device .

-
Click the device to connect. Once it connected successfully, it will show Connected and LINK will light for 3s and blink for every 3s.

-
Send data frome the Data sending Area

-
Click Send Data to send data.

PC Bluetooth Connection
The direct connection between PC and BLE4.1 built-in Bluetooth is not available for temporarily (similar to smartphone, PC also need another software to realize the connection. The development is still in planning).
Bluetooth P2P Communication
The procedure of BLE4.1 P2P connection is similar to BLE4.0, and the only difference is the P2P mode command.
-
There are two devices in all, one should be set as the master device(ROLE_CENTRAL) and the other one should be set as the slave device(ROLE_PERIPHERAL).
-
Config two BLE4.1 devices as P2P connection mode with AT+NETWORK=P2P (Default: P2P mode).

-
AT Command: AT+ROLE=ROLE_CENTRAL, AT+ROLE=ROLE_PERIPHERAL,

-
Restart BLE4.1 device and begin the approach connection.
- Approach Connection: press and hold host BOOT button and move it close to the target slave device (<10cm) until a successful connection, then the LINK will light on each 3 seconds.
- The first time you press and hold the host BOOT button is only for add the new devices to the white list. It doesn't need the same operation for the second connection.
- BLE 4.1 device is also compatible with BLE4.0 devices (Bluno 1st generation). And BLE 4.0 only supports P2P connection, so it doesn't need to set the connection mode for 4.0, just BLE 4.1 only.
Bluetooth Star Network Connection
The star network connection mode is similar to the P2P connection mode, the difference between them in setting is that the star network uses the command AT+NETWORK=STAR.
The light LINK suggests the node device has been added to the white list of the central device and then it will connect the listed device automatically.

Star network connection is only for BLE4.1 device, not applicable to Bluno 1st generation (BLE4.0) and other BLE brands device.**
In the star connection, Bluetooth device adopt special data packet compression method.
You can use Arduino library to realize network data transmit. Click the link to download Arduino library files and Arduinojson library files.
During the connection, the slave device which first connected to the host will get ID: 1 and hereby superimposed.
sample code
The sample code shows how to get network ID of the device and ID of the data source. You’d better to power the device in turn when build star network.
#include <DFRobot_Bluno2.h>
#include <ArduinoJson.h>
DFRobot_Bluno2 blunoNet;
int blunoID=0;
void setup()
{
Serial.begin(9600);
blunoNet.begin(Serial);//get id
}
void loop()
{
uint8_t event=blunoNet.getEvent();//queue
switch(event)
{
case EVENT_NETINFO:
{
eventNode e = blunoNet.popEvent();
StaticJsonBuffer<200> jsonBuffer;
JsonObject& root = jsonBuffer.parseObject((const char *)e.payload);
if (!root.success()) {
return;
}
int s = root["r"].size();
for(int i = 0; i < s; i++){
if(root["r"][i]["s"].as<int>()){
blunoID = root["r"][i]["i"].as<int>();
break;
}
break;
}
}
case EVENT_DATA:
{
eventNode e = blunoNet.popEvent();
blunoNet.sendPacket(e.src, blunoID, "hello12345678901234567890",26);
break;
}
default: //no event
{
break;
}
}
blunoNet.loop();
if(Serial.available()){
char message=Serial.read();
blunoNet.sendPacket(!blunoID, blunoID, &message,1);
}
}
Bluetooth Low Power Consumption Mode
After Bluetooth enter low power consumption mode, the BLE 4.1 consumes lower than 10uA, and it can still broadcast and keep data interaction.
With command AT+LOWPOWER=ON, BLE4.1 device will enable low power consumption mode after you reboot the device.
BLE4.1 device will enter this mode in 10s. You can also use AT+BOOT to make a software reboot.
Here is something you should notice: The MCU should WAKEUP the BLE Chip first, or it will be messy code.
In the low power consumption mode, if there is no extra operation, Bluetooth will enter this mode after 10s. You can awake Bluetooth by interruption pins; awake ATmega328P by Bluetooth:
- BLE4.1 wakes up the Arduino controller (ATmega328P) with P4_2 (D2_Arduino): high voltage wakeup.
- Arduino controller (ATmega328P) wakes up BLE4.1 by WAKEUP (D3_Arduino): low voltage wakeup.
Wireless Programming
Bluno 2 wireless programming is completely compatible with Bluno1 (BLE4.0). And it is only available under P2P connection mode: the host (the central device) to the slave side.
Similar to P2P connection, set one as host and plug to the PC; set the other one as slave. Pairing the host and the slave, download is available.
Was this article helpful?
