2.4GHz NRF24L01 Trådløs Serial Transceiver Antenne Module, er en lille opgradering af den originale “NRF24L01”, dette modul har også fået tilføjet en antenne, så signalet kan forbedres.
Tekniske detaljer:
Frequence: 2.4GHz~2.5GHz
Operating voltage: 1.9 ~ 3.6 V (Not 5V)
Current: 115mA
Multi-frequency: 125 frequency
Support up to six channels of data reception
Transmission distance up to 1000 meters in outdoor open occasions!
Installere Arduino IDE Software
Før du kan starte din programmering skal Arduino’s IDE software hentes. Dette program bruges til at programmere chippen.
Download fra dette link: Downlaod
Installere RF24-Master Library
- Download library (Download)
- Udpak filer
- Flyt/kopir mappen “RF24-Master” til “libraries” som findes i “Arduino IDE” mappen (C:\Program Files (x86)\Arduino\libraries)
- Åben Arduino IDE software og klik på “Sketch/Include library”
- Klik nu på “Add Zip. library” og find Zip filen du lige har downloaded.
- Åben “Manage” for at opdatere library.
- Luk, og åben Arduino IDE programmet. (Genstart programmet)
- Nu er RF24-Master Library installeret
Programmering
Inden programmeringen kan udfæres skal den rigtige “COM” port findes. Klik “Værktøj/Port” – og vælg COM port.
Eksempel
Her vises er eksempel på hvordan du kan få LED til at tænde/slukke ved at trykke på en knap et andet sted på et andet board.
Du skal bruge:
- 2x Arduino Uno R3
- 2x Mini-B USB stik
- LED
- Print Push Button
- 2x 100Ohm Modstand
- Breadboard
- Dupont Breadboard Kabel
For Transmitter
NRF24L01 | Arduino UNO/Nano | Arduino Mega 2560 |
VCC | 3.3V | 3.3V |
GND | GND | GND |
CSN | Pin 8 | Pin 8 |
CE | Pin 7 | Pin 7 |
SCK | Pin 13 | Pin 52 |
MOSI | Pin 11 | Pin 51 |
MISO | Pin 12 | Pin 50 |
Make the connections for the Button as shown in the Circuit Diagram |
For Receiver
NRF24L01 | Arduino UNO/Nano | Arduino Mega 2560 |
VCC | 3.3V | 3.3V |
GND | GND | GND |
CSN | Pin 8 | Pin 8 |
CE | Pin 7 | Pin 7 |
SCK | Pin 13 | Pin 52 |
MOSI | Pin 11 | Pin 51 |
MISO | Pin 12 | Pin 50 |
LED Positive | Pin 3 | Pin 3 |
LED Negative | GND through 100 ohm resistor | GND through 100 ohm resistor |
Forbind sådan:
Info: Modulet kan ikke tåle at få “GND” ind på VCC”. Modulet bliver varm og går istykker. “GND” og “VCC” skal passe som vist på tegningen.
Kode: Resiver
#include <SPI.h> #include <nRF24L01.h> #include <RF24.h> RF24 radio(7, 8); // CE, CSN const byte address[6] = "00001"; boolean button_state = 0; int led_pin = 2; void setup() { pinMode(6, OUTPUT); Serial.begin(9600); radio.begin(); radio.openReadingPipe(0, address); //Setting the address at which we will receive the data radio.setPALevel(RF24_PA_MIN); //You can set this as minimum or maximum depending on the distance between the transmitter and receiver. radio.startListening(); //This sets the module as receiver } void loop() { if (radio.available()) //Looking for the data. { char text[32] = ""; //Saving the incoming data radio.read(&text, sizeof(text)); //Reading the data radio.read(&button_state, sizeof(button_state)); //Reading the data if(button_state == HIGH) { digitalWrite(2, HIGH); Serial.println(text); } else { digitalWrite(2, LOW); Serial.println(text);} } delay(5); }
Kode: Transmitter
#include <SPI.h> #include <nRF24L01.h> #include <RF24.h> RF24 radio(7, 8); // CE, CSN const byte address[6] = "00001"; //Byte of array representing the address. This is the address where we will send the data. This should be same on the receiving side. int button_pin = 2; boolean button_state = 0; void setup() { pinMode(button_pin, INPUT); radio.begin(); //Starting the Wireless communication radio.openWritingPipe(address); //Setting the address where we will send the data radio.setPALevel(RF24_PA_MIN); //You can set it as minimum or maximum depending on the distance between the transmitter and receiver. radio.stopListening(); //This sets the module as transmitter } void loop() { button_state = digitalRead(button_pin); if(button_state == HIGH) { const char text[] = "Your Button State is HIGH"; radio.write(&text, sizeof(text)); //Sending the message to receiver } else { const char text[] = "Your Button State is LOW"; radio.write(&text, sizeof(text)); //Sending the message to receiver } radio.write(&button_state, sizeof(button_state)); //Sending the message to receiver }
Download
Kontakt os
Du er altid velkommen til at kontakte os på info@ardustore.dk, eller sende os en besked via messenger (Klik her) og vi vil hjælpe dig.
Anmeldelser
Der er endnu ikke nogle anmeldelser.