Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Nano Controlled NRF24L01 Wireless Communication System

View and Edit Project In Cirkit DesignerImage of Arduino Nano Controlled NRF24L01 Wireless Communication System

Circuit Documentation

Summary of the Circuit

This circuit is designed to utilize an Arduino Nano as the central microcontroller to interface with an NRF24L01 Adapter for wireless communication. The circuit includes a toggle switch to control power to the Arduino Nano and another toggle switch to act as an input for sending messages via the NRF24L01 module. A resistor and LED are connected to the Arduino Nano to provide visual feedback when a message is sent. The circuit is powered by a 3.7V power source.

Component List

NRF24L01 Adapter

Toggle Switch SPST (Single Pole Single Throw)

NRF24L01 Long Range

Resistor

Arduino Nano

LED: Two Pin (red)

3.7V Power Source

Wiring Details

NRF24L01 Adapter

Toggle Switch SPST

Resistor

Arduino Nano

LED: Two Pin (red)

3.7V Power Source

Documented Code

#include "nRF24L01.h" // NRF24L01 library created by TMRh20 https://github.com/TMRh20/RF24
#include "RF24.h"
#include "SPI.h"
#define SwitchPin 2
#define LED_PIN 3
int SentMessage[1] = {000};
RF24 radio(9, 10); // NRF24L01 used SPI pins + Pin 9 and 10 on the NANO
const uint64_t pipe = 0xE6E6E6E6E6E6; // Needs to be the same for communicating between 2 NRF24L01

void setup()
{
  pinMode(SwitchPin, INPUT_PULLUP);
  digitalWrite(SwitchPin, HIGH);
  radio.begin(); // Start the NRF24L01
  radio.openWritingPipe(pipe); // Get NRF24L01 ready to transmit
  pinMode(LED_PIN, OUTPUT);
}

void loop()
{
  if (digitalRead(SwitchPin) == LOW)    // If switch is pressed
  {
    SentMessage[0] = 111;
    radio.write(SentMessage, 1);      // Send pressed data to NRF24L01
    digitalWrite(LED_PIN, HIGH); 
  }
  else
  {
    SentMessage[0] = 000;
    radio.write(SentMessage, 1);      // Send idle data to NRF24L01
    digitalWrite(LED_PIN, LOW);
  }
}

This code is designed to run on the Arduino Nano. It initializes the NRF24L01 module and sets up a communication pipe. When the toggle switch connected to pin D2 is closed, the Arduino sends a message with the value 111 to the NRF24L01 module, and the LED connected to pin D3 is turned on. When the switch is open, it sends a message with the value 000 and turns the LED off.