I’ve always loved how Bluetooth can turn any ordinary electronics project into something you can control wirelessly from your phone—no extra buttons or wires needed. Today, I’ll show you how to add Bluetooth to your own projects using the Reyax RYB2340 module. It’s a tiny, low-power module that works with any microcontroller, and you don’t need complicated circuitry to get it running.
In this guide, we’ll use the RYB2340 to control a relay (which could turn lights, fans, or other devices on/off) from a smartphone. Even if you’re new to electronics, you’ll see how simple it is to add wireless control to your own builds.
What I like about this module is that it handles all the Bluetooth complexity for you. Instead of wrestling with wireless protocols, we’ll just send simple serial commands—like texting between your phone and microcontroller.
RYB2340 Module:
- Digikey RYB2340: https://www.digikey.com/en/products/detail/reyax/RYB2340/25616417
- Amazon RYB2340_Lite: https://www.amazon.com/dp/B0DW8Y6L7C
- REYAX Website: https://reyax.com/products/RYB2340_Lite
Why Add Bluetooth to Your Project?
Wireless control opens up so many possibilities for your electronics projects. Imagine turning lights on from your couch, monitoring sensors without cables, or even building a custom remote for your gadgets. That's where Bluetooth Low Energy (BLE) shines—it's designed for simple, energy-efficient wireless communication. Unlike classic Bluetooth, BLE uses minimal power and that makes it suitable even for battery powered projects.
The Reyax RYB2340 module makes adding BLE to your project straightforward. It's a compact, standalone module that handles all the complex wireless work for you. Just connect it to your microcontroller (like an Arduino or ESP8266) via UART, and you can start sending commands from your phone. There is no need for advanced coding as the module uses AT commands, hiding all the heavy lifting on its own side.
What I love about this approach is its flexibility. The RYB2340 will work with almost any microcontroller. You're not locked into one platform, and you don't need to rewrite your entire project just to add wireless control. Just wire it up, send simple serial commands, and you're ready to go.
RYB2340 Module Specs and Features
Let’s break down what makes this little module so useful. The Reyax RYB2340 is a Bluetooth 5.3 Low Energy (BLE) module that’s built around the Texas Instruments CC2340R5 chip. It’s designed for projects where you need reliable wireless control without draining your battery. The module runs on 3.3V and sips just 11mA of current when transmitting.
You’ve got two options for hardware: the evaluation board (which comes with breadboard-friendly pins and basic support components) or the raw module (a tiny 16.7 x 13mm board for embedding directly into your own PCB designs). Both versions include an integrated antenna, so you don’t need extra parts to get a strong signal. There’s even a metal shield covering the circuitry to reduce interference from other electronics.
Building the Circuit: Relay Control via Bluetooth
First, power up the RYB2340 by connecting its VCC pin to 3.3V and GND to ground on your microcontroller. For communication, link the module’s TX pin to D5 (or any other digital pin) on the ESP8266 and its RX pin to D6. These will act as our software serial ports, letting the microcontroller and Bluetooth module talk without interfering with the main USB serial connection.
Since most relays need 5V to switch but our ESP8266 only outputs 3.3V logic, we’ll use a 2N2222 transistor as a switch. Connect the relay’s control pin to the transistor’s collector, then wire the emitter to ground. A 10k resistor is used to bring the 5V to the transistor collector. The base of the transistor goes to D1 on the ESP8266 through a 10k resistor (to limit current). Power the relay coil from the microcontroller’s 5V pin (Vin). This way, when D1 goes high, the transistor activates, grounding the relay’s control pin and turning it on.
With this setup, your microcontroller can now toggle the relay based on Bluetooth commands from your phone. Next, we’ll program the ESP8266 to make it all work together.
Arduino Code
The Arduino code uses software serial to connect the NodeMCU with the Bluetooth module. I explained the code in details in the project video so please check the video if you can't understand how it works. Below is the full code used in the example.
#include <SoftwareSerial.h>
#define RXD2 D5
#define TXD2 D6
SoftwareSerial mySerial(RXD2, TXD2);
String content = "";
void setup()
{
Serial.begin(115200);
mySerial.begin(115200);
delay(1000);
pinMode(D1, OUTPUT);
digitalWrite(D1, LOW);
}
void loop() {
if (Serial.available()){
Serial.print("Writing: ");
content = Serial.readString();
Serial.println(content);
content.trim();
Serial.println();
writeToModule(content);
}
if (mySerial.available()) {
String incomming = mySerial.readString();
Serial.println(incomming);
if(incomming == "RELAY_ON") {
digitalWrite(D1, HIGH);
} else if (incomming == "RELAY_OFF") {
digitalWrite(D1, LOW);
} else if(incomming.startsWith("+----C")) {
digitalWrite(D1, LOW);
} else if(incomming.startsWith("+++++C")) {
digitalWrite(D1, LOW);
writeToModule("SUBSCRIBE");
}
}
}
void writeToModule(String content) {
content = content + "\r\n";
char* bufc = (char*) malloc(sizeof(char) * content.length() + 1);
content.toCharArray(bufc, content.length() + 1);
mySerial.write(bufc);
free(bufc);
delay(100);
readSerial();
}
void readSerial() {
if (mySerial.available()) {
Serial.println(mySerial.readString());
}
}
Testing with the Reyax BLE Connect App
In their download section, Reyax provides an example Android app that can be used to scan for Bluetooth modules, connect to a specific one and display all of the characteristics that the module provides. It can be found here.
I used their code to slightly modify it and add two buttons and a label. The buttons send a specific text to the write characteristic of the module. The ON button send the string "RELAY_ON" while the OFF button send the string "RELAY_OFF"
The label is connected to the notify characteristic, and it displays whatever text we send from the serial of the NodeMCU.
The updated app is available on my GitHub page.
Why Use a Dedicated BLE Module
(Instead of ESP32 Built-In Bluetooth)?
You might be wondering - if boards like the ESP32 already have built-in Bluetooth, why bother with an external module? Here are three key reasons this approach makes sense for many projects:
- Keeps Your Main Microcontroller Free - When your ESP32 handles both Bluetooth and your main program logic, it can get overwhelmed. The RYB2340 acts like a dedicated assistant - it manages all the wireless communication independently through simple serial commands. This means your main microcontroller can focus on reading sensors, controlling outputs, or running complex code without Bluetooth tasks slowing it down.
- Simplifies Your Design - Bluetooth protocols can be tricky to implement. With the RYB2340, Reyax has already handled all the complicated BLE setup in the module's firmware. You just send plain text commands like "RELAY_ON" - no need to dive into Bluetooth profiles or manage wireless stacks. This is especially helpful if you're not familiar with wireless protocols.
- More Flexible for Production - If you eventually move from a development board to a custom PCB, having Bluetooth as a separate module gives you options. You can keep using the evaluation board for prototypes, then switch to the compact RYB2340 module (just 16.7 x 13mm) for your final product without rewriting any code. Plus, its metal shielding prevents interference in crowded electronic environments.
That said, built-in ESP32 Bluetooth is great for simpler projects where you need everything in one chip. But when you want reliable wireless that won't interfere with your main program - especially for battery-powered or sensor-heavy projects - the RYB2340's dedicated approach shines.
The links below are affiliate links. When you click on affiliate links in my articles or videos, it means I may earn a small commission if you make a purchase. These links are a way to support my work without costing you anything extra—the price you pay stays the same, whether you use the link or not. Thank you for your support!
- NodeMCU Microcontroller - https://s.click.aliexpress.com/e/_oF2nzGM
- 2N2222 Transistors - https://s.click.aliexpress.com/e/_oFJ40ch
- Relay Module - https://s.click.aliexpress.com/e/_oEMt0Z3
- Wire Stripper - https://s.click.aliexpress.com/e/_oDTnss8
- Flush Cutting Pliers - https://s.click.aliexpress.com/e/_oDnmZ3I
- Mini Breadboards - https://s.click.aliexpress.com/e/_okZle8Y
- Soldering Station - https://s.click.aliexpress.com/e/_olgLvfS
- Multimeter - https://s.click.aliexpress.com/e/_oFZ31NA
- Bench Power Supply - https://s.click.aliexpress.com/e/_olduGic
- Arduino Learning Kit - https://s.click.aliexpress.com/e/_oogVXdI
- 3D Printer - https://s.click.aliexpress.com/e/_opZmCZi