RFduino - Sending and Receiving Data Via BLE

About: I am an electrical engineer and an Arduino and electronics enthusiasts. I believe working with electricity should be fun as well as beneficial to engineers and the world at large. Twitter handle: @arduinoha...

Intro: RFduino - Sending and Receiving Data Via BLE

Nowadays it is easy for one to integrate bluetooth capability to his or her project. This is thanks to Bluetooth Low energy boards such as the RFduino. I got an RFduino board recently and thought of sharing a simple tutorial on sending and receiving data between the RFduino BLE board and my phone.

Step 1: Requirements

-RFD22102 BLE Module

-RFD22121 USB shield

-BLE enabled Phone

-Android BLE serial app

Step 2: Hardware Connection

Mount the RFduino BLE module onto the USB shield then connect the USB shield to one of the USB ports of your computer

Step 3: Code

You need to download the RFduino library and install it as shown in this link

Upload the following codes to perform the sending function and receiving function.

Step 4: Sending Data From the RFduino

#include "RFduinoBLE.h"

void setup() {

RFduinoBLE.advertisementData = "CouDow"; // shouldnt be more than 10 characters long RFduinoBLE.deviceName = "Timer"; // name of your RFduino. Will appear when other BLE enabled devices search for it RFduinoBLE.begin(); // begin

}

void loop() {

RFduinoBLE.send(1); // send number 1 to connected BLE device

delay(3000); // delay for 3 seconds

}

Step 5: Receiving Data With the RFduino

#include "RFduinoBLE.h"

void setup() {

Serial.begin(9600);

RFduinoBLE.advertisementData = "CouDow"; // shouldnt be more than 10 characters long RFduinoBLE.deviceName = "Timer"; // name of your RFduino. Will appear when other BLE enabled devices search for it

RFduinoBLE.begin(); // begin

}

void loop() {

}

void RFduinoBLE_onReceive(char *data, int len) {

// display the first recieved byte

Serial.println(data[0]);

}

Step 6: Explanation

When you upload the first code, the RFduino will send the number 1 infinitely every 3 seconds. You will be able to view this with your phone using a BLE serial app. You can find an example app that you can use in this link.

When you upload the second code, the RFduino will display the first byte of any incoming data on the arduino serial monitor. For instance, if your send 34 from the app, 3 will be displayed on the serial monitor.

There are many things that you can do with the RFduino. I will be posting a full tutorial of a project i am working on with it. Meanwhile, you can check out the full tutorial of this article here.

Share

    Recommendations

    • Electronics Tips & Tricks Challenge

      Electronics Tips & Tricks Challenge
    • Plastics Contest

      Plastics Contest
    • Audio Contest 2018

      Audio Contest 2018

    4 Discussions

    0
    None
    OmnimushaO

    2 years ago

    can , programmed by bluetoch??

    0
    None
    OmnimushaO

    2 years ago

    can , programmed bluetoch??

    0
    None
    tym3k

    3 years ago

    Can an RFDuino be used to receive ancs notifications?

    1 reply
    0
    None
    yhtomitsytym3k

    Reply 3 years ago on Introduction

    erm, for now No. The RFduino acts a server and not a client. So, it cannot receive ancs notifications