Arduino Bluetooth Transmitter/Receiver
by macaulayoscar65 in Circuits > Arduino
52 Views, 0 Favorites, 0 Comments
Arduino Bluetooth Transmitter/Receiver

In this Instructables you will learn how to make a wireless receiver/transmitter with step-by-step instructions. this build is coded and built on two arduinos that you could also swap out for nanos, one nano and one uno, one uno and one mega, or one mega and one nano. this project has many possibilities and applications, for our purposes we will be making a reciever/transmitter setup for a wireless blimp.
Supplies


For this project you will require some materials. Photos of the materials have been included so you know what they look like. Please note that the Arduino uno is interchangeable with the mega and nano as explained before.
Supplies;
-Two Arduino Uno Microcontroller Boards
-2 nRF24L01 Bluetooth Chips
-One Computer
-15-20 Male to Female Wires
-An Updated Copy of Arduino IDE
-A USB cable for laptop->arduino communication
Wiring the Build


While trying to make our build as light as possible we decided not to use a breadboard, therefore the best option for connections is male to female jumper wires, as they allow transmission straight off the microcontroller to the transmitter/receiver.
First, make sure you are looking at the back of your nRF24L01 while attaching wires, or else you may input the connections opposite to their intended place. Refer to the supplied diagram for the location of each pin on the nRF24 module.
secondly, the CN and CSN pins can be on any digital pins on your Arduino other than the 4 SPI pins on your board.
Coding the Artifact

The code for this project is relatively simple. I got this code from https://lastminuteengineers.com/nrf24l01-arduino-wireless-communication/ however there are many other sources on the web that provide similar examples. all this code does is broadcast a "Hello World" on its address and the receiver picks it up and prints it to the serial monitor. make sure to change your address to something unique (on line "const byte address[6] = "00001";") to avoid cross communication due to being on the same address as someone else.
Transmitter code;
// Transmitter Code
// Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
//create an RF24 object
RF24 radio(9, 8); // CE, CSN
//address through which two modules communicate.
const byte address[6] = "00001";
void setup()
{
radio.begin();
//set the address
radio.openWritingPipe(address);
//Set module as transmitter
radio.stopListening();
}
void loop()
{
//Send message to receiver
const char text[] = "Hello World";
radio.write(&text, sizeof(text));
delay(1000);
}
Receiver code;
//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
//create an RF24 object
RF24 radio(9, 8); // CE, CSN
//address through which two modules communicate.
const byte address[6] = "00001";
void setup()
{
while (!Serial);
Serial.begin(9600);
radio.begin();
//set the address
radio.openReadingPipe(0, address);
//Set module as receiver
radio.startListening();
}
void loop()
{
//Read the data if available in buffer
if (radio.available())
{
char text[32] = {0};
radio.read(&text, sizeof(text));
Serial.println(text);
}
}
Please note that you may need to change the numbers on the “RF24 radio(9, 8);” line depending on what digital pins you used for RF24 CN and CSN pins.
Testing
To test the functionality of the connection, set the two modules to the same radio frequency within Arduino IDE, and send a test message (a classic is "Hello world!") to confirm communication between the devices.
Now run your code and have fun, you have just made a transmitter/receiver system!