Reyax RYBG211_lite Bluetooth low energy module with Arduino.

Reyax RYBG211_lite Bluetooth low energy module with Arduino.

Hello everyone, welcome to another post, In this article we will learn about Bluetooth Low Energy….in short BLE, and by using RYBG211_lite BLE module we will make a very interesting and useful home-automation project along with Arduino UNO and also I will test the range of this module. 

In this home-automation project we can control our home-appliances through our smartphone with custom  made application.

Here our smartphone will communicate to the Arduino via RYBG211 BLE Module and it has range of about 200 to 300 meters, which I will test and let you know the exact range. 

This project is very helpful in remote location where WIFI or internet is not available, apart from this home-automation , this BLE module has other useful application like remote sensor monitoring and controlling, tracking of visitor flows etc.  

PCB Prototype.

To avoid the loose and messy wiring on the bread board , I designed a PCB for this project.

Which is compact and reliable.

Designing the PCB.

To design the circuit and PCB, we used EasyEDA which is a browser based software to design PCBs .After soldiering rest of components PCB look like this neat, clean and well arranged.

Designing the circuit works like in any other circuit software tool, you place some components and you wire them together. Then, you assign each component to a footprint. Having the parts assigned, place each component. When you’re happy with the layout, make all the connections and route your PCB.


Save your project and export the Gerber files.

Ordering the PCBs at PCBWay.

This project is sponsored by PCBWay. PCBWay is a full feature Printed Circuit Board manufacturing service.

Turn your DIY breadboard circuits into professional PCBs – get 10 boards for approximately $5 + shipping (which will vary depending on your country).

Once you have your Gerber files, you can order the PCB. Follow the next steps.

1. Download the Gerber files – click here to download the .zip file.

2. Go to PCBWay website and open the PCB Instant Quote page. 

3. PCBWay can grab all the PCB details and automatically fills them for you. Use the “Quick-order PCB (Autofill parameters)”.

4. Press the “+ Add Gerber file” button to upload the provided Gerber files.

And that’s it. You can also use the Online Gerber Viewer to check if your PCB is looking as it should.

Now select the shipping method , the one you prefer and has cost efficient.

You can increase your PCB order quantity and change the solder mask color. I’ve ordered the Green color.

PCBWay has lots of other staggering solder mask, Now they can produce pink, orange, grey, even the transparent solder mask. 

Apart from this they also provide Black core PCB.



Once you’re ready, you can order the PCBs by clicking “Save to Cart” and complete your order.

After approximately one week using the DHL shipping method, I received the PCBs at my place.

As usual, everything comes well packed, and the PCBs are really high-quality. The letters on the silkscreen are really well-printed and easy to read. Additionally, the solder sticks easily to the pads.

Let’s Make it…!

Now grab all the components whose list is mention above, and soldered on the PCB.


After soldiering rest of components PCB look like this neat, clean and well arranged.

What is Bluetooth low energy.

Bluetooth Low Energy, or in short BLE, is a power-conserving variant of Classical Bluetooth. 

BLE’s primary application is short distance transmission of small amounts of data i.e. low bandwidth. Unlike Bluetooth that is always on, BLE remains in sleep mode constantly except for when a connection is initiated. This makes it consume very low power. BLE consumes approximately 100 times less power than Bluetooth (depending on the use case).

BLE supports not only point-to-point communication, but also broadcast mode, and mesh network.

Due to its properties, BLE is suitable for applications that need to exchange small amounts of data periodically running on a coin cell. For example, BLE is of great use in healthcare, fitness, tracking, beacons, security, and home automation industries.

BLE Server and Client.

With Bluetooth Low Energy, there are two types of devices: the server and the client.

The server advertises its existence, so it can be found by other devices, and contains the data that the client can read. The client scans the nearby devices, and when it finds the server it is looking for, it establishes a connection and listens for incoming data. This is called point-to-point communication.

As mentioned previously, BLE also supports broadcast mode and mesh network:

  • Broadcast mode: the server transmits data to many clients that are connected;
  • Mesh network: all the devices are connected, this is a many to many connection.

Features of RYBG211_lite.

RYBG211_lite

  • Bluetooth V5.1 with Bluetooth Low Energy.
  • SILABS 32-bit ARM® Cortex®-M33 core industry-standard chip
  • Can connect 8 Host-Client RYBG21x modules at the same time
  • Metal cover against EMI interference.
  • Control easily by AT commands.
  • Standard Generic Attribute Profile (GATT).
  • Designed with PCB integrated antenna.

Components Required.

In Making of this home automation project we need 

  • RYBG211 lite BLE module.
  • Arduino UNO board.
  • 4 ch relay module.
  • 4.7kohm and 10 kohm resistance.
  • Some jumper wires.
  • And one 16×2 LCD display with I2C module.

CODE.

Download this code and Upload in your Arduino board after selecting the right board and com port.

#include <SoftwareSerial.h>
#define rxPin 10
#define txPin 11
const int led1 = 4;
const int led2 = 5;
const int led3 = 6;
const int led4 = 7;
char data_in ;
// Set up a new SoftwareSerial object
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
void setup() {
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);
  digitalWrite(led3, HIGH);
  digitalWrite(led4, HIGH);
    // Set the baud rate for the SoftwareSerial object
    mySerial.begin(9600);
    Serial.begin(9600);
}
void loop() {
  if (mySerial.available() > 0) {
    data_in = (char)mySerial.read();
    Serial.print(data_in);
  }
if (data_in == 'A') {
    digitalWrite(led1, LOW);
    delay(20);
  }
  if (data_in == 'a') {
    digitalWrite(led1, HIGH);
    delay(5);
  }
  if (data_in == 'B') {
    digitalWrite(led2, LOW);
    delay(20);
  }
  if (data_in == 'b') {
    digitalWrite(led2, HIGH);
    delay(5);
  }
  if (data_in == 'E') {
    digitalWrite(led3, LOW);
    delay(20);
  }
  if (data_in == 'e') {
    digitalWrite(led3, HIGH);
    delay(5);
  }
  if (data_in == 'D') {
    digitalWrite(led4, LOW);
    delay(20);
  }
  if (data_in == 'd') {
    digitalWrite(led4, HIGH);
    delay(5);
  }
}

Smartphone Application.

To communicate with the RYBG211_lite BLE Module we need an smartphone application as host. there are lots of app available, but while testing them I found those apps were only good in testing purpose. those apps were are not fit good in real life project.

This light blue app is very good in testing. we can communicate or Connect with any BLE device without worrying about UUID characteristics.

This app will easily connect and communicate with any BLE Module. but we can’t use in daily life, whenever we want to on or off the relay we need to manually send the string data by typing in the app.

And apart from this manually typing and sending, we must spend some time to find this sending location in the app. and trust me this process is very not convenient.

So I thought why not make a custom  app which can easily connect and easy to use. So I designed an app and put the Characteristics and Service UUID of RYBG211 module inside the coding of app. due to this app will easily connect with BLE module. & we can easily control the appliances with single touch no need to type again and again.

Bluetooth Pairing.

To connect the app with BLE first we need to pair the BLE Device with our phone , for this open Bluetooth Settings of your phone and click on pair new device, there  you will  found the rybg211 module click on this and pair with your phone, after successful pairing open the app again. 

When  connected message shown in the app that  means app is now connected with RYBG211 BLE module.

Circuit & Connections.

Circuit diagram without using PCB.

Circuit diagram using PCB.

Range test.

To test the range of this module I make another circuit in which I connect a 16×2 LCD display.

Below is the code testing the range of module ,here we continuously checking if any serial data is available or not if available  then we will  print signal  received, otherwise signal lost will print in the display.

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define rxPin 10
#define txPin 11
char data_in ;
// Set up a new SoftwareSerial object
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
void setup() {
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
    // initialize the LCD
  lcd.begin();
  // Turn on the blacklight and print a message.
  lcd.backlight();
    // Set the baud rate for the SoftwareSerial object
    mySerial.begin(9600);
    Serial.begin(9600);
}
void loop() {
  if (mySerial.available() > 0) {
    data_in = (char)mySerial.read();
    Serial.print(data_in);
    lcd.clear();
    lcd.print("Signal");
    lcd.setCursor(0,1);
    lcd.print("Received");
    delay(500);
   }
   else {
    lcd.clear();
    lcd.print("Signal");
    lcd.setCursor(0,1);
    lcd.print("lost");
    delay(500);
    }
}


I came outside with my friend Sumit to test the Transmission range of this module. He is holding the phone and RYBG211 BLE module is connected to the app.

I am  moving away from the app and let’s see how far this app will remain connected with app.

After walking few meters distance I lost the signal, I am  back to studio and calculate the Transmission range on the google map. 

I took the coordinates of both ends staring and ending points of our test , And I found the Transmission range of this RYBG211_lite BLE module is about 207 meters. Which is pretty good. If you want you can use this module in your projects. 

And that’s it for this article. thank you so much for readings.

Bye bye take care of yourself. 

Video Tutorial.

Leave a Reply

Your email address will not be published.