راه اندازی ماژول وایرلس nRF24L01 با اردوینو
nRF24L01 Wireless Module with Arduino
Now we have a demo show how to use the Arduino controlling the nRF24L01 module , and you need two Arduino boards and two modules, one to transmit and the other receive. The connection of two part is the same but the different software.
The nRF24L01 module is worked at 3V voltage level , so the Arduino 5V pins may destroy it , so we need to add some resister to protect the module – using the 10K and the 15K resister to reduce the voltage is a usual method.
Download the code below into the RX Arduino (receive) – This code will drive the nFR24L01 module to receive the data that transmit form the TX module and print it to serial port.
Now power on both Arduino , and connect the RX one to PC via USB. Open the IDE serial port monitor , change the baud rate to 9600 bps , and you can see the data that received.
All the project here(include API.h and NRF24L01.h)
nRF24L01 Demo code for Arduino (unknown, 4,705 hits)
You can fine the cables , resisters and the nRF24L01 module that used in the demo on our webshop.
http://blog.iteadstudio.com/nrf24l01-wireless-module-with-arduino/
دانلود آموزش فارسی راه اندازی ماژول وایرلس NRF24L01
+کدهای گیرنده و فرستنده+کتابخانه+پاورپوینت توضیحات و شماتیک
NRF24L01 Radio 2.4GHz Transmitter Receiver On Arduino
NRF24L01 is a 2.4GHz wireless radio frequency module that can be used to transmit and receive data. This is a great wireless module suitable for short range 100m remote control at 250kbps data rate. Let us look at how to setup NRF24L01 radio frequency transmitter and receiver on the Arduino. For simplicity, let us pick a simple joystick module as the data source where we transmit the X and Y values of the joystick to the receiver via wireless radio frequency at 2.4GHz frequency band. We will have to setup the transmitter and receiver. There are 8 pins on the NRF24L01 RF module, with 2 power pins for the VCC and GND, the CE pin, SCN pin, SCK, MOSI, MISO and IRQ pin. Refer below for the hardware and software setups.
Setup NRF24L01 2.4GHz Radio Frequency Module On Arduino As Transmitter
To setup the NRF24L01 as transmitter on the Arduino, connect the VCC and GND of the module to 3.3v and GND on the Arduino respectively. The CE is connected to pin 9, the SCN is connected to pin 10, the SCK is connected to pin 13, the MOSI is connected to pin 11, the MISO is connected to pin 12 and the IRQ is left unconnected. The joystick module is powered by 5V and GND on the Arduino, while Horizontal (x axis) is set to A0 and Vertical (y axis) is set to A1 of Arduino, we leave the Select (Z axis for “1″ and “0″) unconnected.
Our intention is to have the A0 and A1 analog pins to collect the X and Y values of the joystick, and send the data wirelessly via NRF24L01 module. Download the RF24 Library for NRF24L01, and write below sketch to be uploaded to the Arduino.
NRF24L01 Transmitter Sketch
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
#define JOYSTICK_X A0
#define JOYSTICK_Y A1
const uint64_t pipe = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN, CSN_PIN);
int joystick[2];
void setup()
{
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipe);
}
void loop()
{
joystick[0] = analogRead(JOYSTICK_X);
joystick[1] = analogRead(JOYSTICK_Y);
radio.write( joystick, sizeof(joystick) );
}
Setup NRF24L01 2.4GHz Radio Frequency Module On Arduino As Receiver
To setup the NRF24L01 RF module as a receiver to sync the data at 2.4GHz band, setup a separate Arduino and NRF24L01 module as in the setup in below picture. Power up the NRF24L01 module with VCC and GND connected to 3.3V and GND on the Arduino. The CE is connected to pin 9 on the Arduino, the SCN is connected to pin 10, the SCK is connected to pin 13, the MOSI is connected to pin 11, the MISO is connected to pin 12 and IRQ is left unconnected.
Upload the sketch below to the Arduino to open up the reading pipe, listen and read the joystick X and Y data wirelessly via radio frequency. The data is then serial printed and can be checked via the Serial Monitor on the Arduino software.
NRF24L01 Receiver Sketch
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
const uint64_t pipe = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN, CSN_PIN);
int joystick[2];
void setup()
{
Serial.begin(9600);
delay(1000);
Serial.println(“Nrf24L01 Receiver Starting”);
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();;
}
void loop()
{
if ( radio.available() )
{
bool done = false;
while (!done)
{
done = radio.read( joystick, sizeof(joystick) );
Serial.print(“X = “);
Serial.print(joystick[0]);
Serial.print(” Y = “);
Serial.println(joystick[1]);
}
}
else
{
Serial.println(“No radio available”);
}
}
Check NRF24L01 Result Via Serial Monitor
Connect the receiver to the computer, open up the Arduino software and Serial Monitor, the X and Y data of the joystick shall be printed out as in below picture.
http://www.bashmodulo.com/arduino/nrf24l01-radio-frequency-transmitter-receiver-on-arduino/
دانلود آموزش فارسی راه اندازی ماژول وایرلس NRF24L01
- ۰ نظر
- ۲۵ مرداد ۹۴ ، ۲۳:۳۳