Wiki

Clone wiki

BitBotGeek´s / USB nRF24l01+ Config v0.9

#USB nRF24l01+ Config v0.9

The program has been designed to facilitate the nRF24l01+ configuration through USB adapter.

In addition, it allows establishing a communication with other nRF24l01+, sending and receiving data.



####Requirements

####Software

  • CH340T driver, download here
  • USB nRF24l01+ Config v0.9, download here

####Hardware

  • USB Adapter for nRF24l01+
  • nRF24l01+

##Set up nRF24l01+

1.- Install CH340T driver.

2.- Install USB nRF24l01+ Config v0.9.

3.- Connect USB Adapter, system should assign a com port.

4.- Open USB nRF24l01+ Config v0.9. On USB Adapter Parameters, select the COM port assigned, set nRF24l01+ BaudRate(default:9600) and click Connect.

5.- Press Load to view device current configuration.

  • RF BaudRate : Sets the data rate in bits per second (baud) for serial data transmission.
  • RF Rate : Sets the data rate in bits per second (baud) for RF data transmission.
  • RF Freq : Sets the channel (400-525) for RF transmission.
  • RF Local address : Sets USB Adapter address.
  • RF Target address : Sets destination address.
  • RF Checksum : Sets Checksum 8-16(default:16).

Note: RF Rate and RF Freq, same values for all devices.

6.- Press Save for changes to take effect.


##Half-duplex communication

######Additional requirements

  • Arduino IDE.
  • Arduino board.
  • nRF24l01+.
  • RF24.h library, download here.

######Schematic

######Programming

Once connections are checked, open arduino IDE and upload Receiver.ino sketch.

//--------------RECEIVER--------------------//

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN 9
#define CSN_PIN 10
uint8_t TARGET_ADDRESS[] = {0xF0,0xF0,0xF0,0xF0,0xD2}; //Destination address(USB Adapter)
uint8_t LOCAL_ADDRESS[] = {0xF0,0xF0,0xF0,0xF0,0xE1}; //Set arduino address
#define CHANNEL 76 // 0-125 in this case-> 2400+76=2476
#define RF_POWER_LEVEL RF24_PA_LOW // RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH and RF24_PA_MAX
#define INTERVAL 500 // Timeout Interval

struct struct_example{
    char buffer_size = 31;
    char char_1 = -30;
    char char_2 = 120;
    uint8_t uint8_t_1 = 255;
    uint8_t uint8_t_2 = 0;
    int int_1 = 10200;
    int int_2 = -3000;
    float float_1 = 18.43f;
    float float_2 = -2343.212f;    
  };

RF24 radio(9,10);

void setup(void)
   {
    Serial.begin(57600); 
    SPI.begin();
    radio.begin();
    radio.setRetries(15,15);
    radio.setDataRate( RF24_250KBPS );
    radio.setChannel(CHANNEL);
    radio.setPALevel(RF_POWER_LEVEL);
    radio.openWritingPipe(TARGET_ADDRESS);
    radio.openReadingPipe(1,LOCAL_ADDRESS);
    radio.startListening();
   }

void loop(){
  unsigned long t_transcurrido = millis();
  bool timeout = false;

  while ( ! radio.available() && ! timeout )       // Wait INTERVAL (500ms)
        if (millis() - t_transcurrido > INTERVAL )
            timeout = true;

  if ( timeout )
       Serial.println("Waiting data...");
  else
   {   
       unsigned char r_buffer [31];
       radio.read( &r_buffer, sizeof(r_buffer)+1); // Read data received

       Serial.println((char*)r_buffer);

        radio.stopListening();        // stop Listening to Send data

        struct_example msg;
        radio.write( &msg , sizeof(msg));
        Serial.println("Sending Data");

       // Volvemos a la escucha para recibir mas paquetes
       radio.startListening();
   }
}

Open Monitor Serial.

Connect USB Adapter, open USB nRF24l01+ Config v0.9 connect it.

For successful communication, it is necessary to indicate the type of data that we are going to handle. So, let's see the structure:

struct struct_example{
    char buffer_size = 31;
    char char_1 = -30;
    char char_2 = 120;
    uint8_t uint8_t_1 = 255;
    uint8_t uint8_t_2 = 0;
    int int_1 = 10200;
    int int_2 = -3000;
    float float_1 = 18.43f;
    float float_2 = -2343.212f;    
  };

On Data Received Parameters panel, you have to add the types of variables in structure order. First byte indicates the buffer size, this has to be discarded and start with the next.

Press Apply button to enable write data text box and write Hello World!





######Contact Support

email: bitbotgeeks@gmail.com

Updated