Simplest Way to Add Bluetooth to Your Project
by taste_the_code in Circuits > Microcontrollers
448 Views, 6 Favorites, 0 Comments
Simplest Way to Add Bluetooth to Your Project


I’ve been working with Bluetooth modules for a while, and the Reyax RYB2340 makes it really easy to add wireless control to any project. This tiny module connects to your Arduino or ESP8266 and lets you control things like lights, relays, or motors straight from your phone.
In this guide, I’ll walk you through wiring the RYB2340, setting up a simple relay control circuit, and writing the Arduino code to make it all work.
Supplies
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
Other tools and materials for Arduino projects:
- 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
Hardware Overview

The Reyax RYB2340 is a compact Bluetooth Low Energy module that handles all the wireless communication for your project. The version I'm using comes on a handy breakout board, making it easy to plug into a breadboard for testing. It is built around TI CC2340R5 chip and supports Bluetooth 5.3 - which means better range and lower power consumption than older versions.
The module operates at 3.3V and draws just 11mA when transmitting, so it won't drain your battery if you are making a battery powered project. On the breakout board, you'll find all the essential pins exposed: power (3.3V and GND), along with UART pins (TX/RX) for serial communication with your microcontroller. There's even a built-in antenna, so you don't need to fuss with external components. For this project, we'll be pairing it with an ESP8266, but it works just as well with Arduino or other 3.3V microcontrollers.
Demo

To provide a functional demo for showcasing the module, I used a relay to make a wireless switch that can be controlled via a mobile phone. I used an ESP8266 microcontroller in the form of a NodeMCU to match it with the 3.3V logic and I modified the provided Android demo to add two buttons to trigger the relay.
Wiring
First, let's power up the RYB2340 module. I connect the 3.3V pin from my ESP8266 to the VCC pin on the Bluetooth module, and the GND pins together – this gives the module clean power without risking damage from higher voltages.
For communication, I hook up the RX pin of the RYB2340 to D6 on the ESP8266 (this will be our microcontroller's TX), and the TX pin of the module to D5 (our RX). This creates a serial link between them.
Now for the relay control: I connect D1 on the ESP8266 to the base of a 2N2222 transistor through a 10K resistor, with the transistor's collector going to the relay coil and emitter to ground. The relay gets its 5V power from the NodeMCU's Vin pin. This way, when D1 goes high, the transistor switches on and activates the relay.
Double-check all connections before powering on – mixing up RX/TX or power pins is an easy mistake to spot now rather than later!
Arduino Code

The code does three main things. First, it sets up a software serial connection between the ESP8266 and the RYB2340 module using pins D5 and D6 - this lets them communicate without interfering with the main serial port we use for debugging.
When running, the code constantly checks two things: if there's data coming from Bluetooth, and if that data says "RELAY_ON" or "RELAY_OFF". If it gets either command, it flips pin D1 high or low to control the relay. As a nice touch, it automatically turns the relay off if the Bluetooth disconnects, which prevents things from getting stuck in the on position.
The code also sends a "SUBSCRIBE" message to the phone when first connected, which updates the app's display. All the Bluetooth complexity is handled by the RYB2340, so our Arduino code stays simple - just reading serial messages and controlling one pin accordingly.
The full code is available here.
Android Example


The Reyax BLE Connect app (modified for this demo) handles the Bluetooth communication with the RYB2340 module. When I open the app, it scans for nearby Bluetooth devices and shows the RYB2340 in the list. Tapping it establishes a connection.
I customized the app's interface by adding two simple buttons—"Relay On" and "Relay Off"—that send the corresponding text commands to the module when pressed. Behind the scenes, the app packages these strings into the proper Bluetooth Low Energy (BLE) format that the RYB2340 understands. The app also displays incoming messages (like the "subscribe" confirmation) in a log, so I can see the communication working both ways.
The beauty is that all the complex BLE protocol work is handled by Reyax's existing app framework—I just added the buttons and tweaked what data gets sent. This makes it surprisingly easy to create a functional controller without deep Android programming knowledge. The app could be expanded to control multiple devices or display sensor data from the ESP8266 with minimal extra code.
You can get my modified version from here.
Next Steps
Now that you can control a relay from your phone, here are some easy ways to expand this project:
- Add More Devices - Hook up lights, motors, or other components to additional relays. The same Bluetooth connection can control them all.
- Sensor Feedback - Connect a temperature or motion sensor to send data back to your phone through the RYB2340.
- Better Enclosure - Move everything from the breadboard to a project box for a cleaner, more permanent setup.
- Try Other Microcontrollers - This works with ESP8266 now, but you could easily adapt it for Arduino or ESP32.
The best part? You don't need to change much code for these upgrades. The RYB2340 handles all the Bluetooth work, so you can focus on adding new features.
What would you want to control first? A lamp? A fan?
Let me know what you build!