Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino Nano-Based Drone Transmitter with NRF24L01 Wireless Communication and OLED Display

Image of Arduino Nano-Based Drone Transmitter with NRF24L01 Wireless Communication and OLED Display

Circuit Documentation

Summary

This circuit is designed to serve as a drone controller, utilizing an Arduino Nano as the central processing unit. It features wireless communication capabilities through an NRF24L01 module, visual feedback via an OLED display, user input through two Adafruit Analog 2-Axis Joysticks and a potentiometer, and digital input from toggle switches. The circuit is powered by a 2x 18650 battery pack and incorporates resistors for voltage division and current limiting purposes.

Component List

  • Arduino Nano: A compact microcontroller board based on the ATmega328P, which provides a variety of digital and analog I/O pins.

  • NRF24L01: A 2.4GHz wireless transceiver module used for remote communication between the drone and the controller.

  • OLED 1.3" Display: A small screen that provides visual output, interfaced via the I2C protocol.

  • Adafruit Analog 2-Axis Joystick (x2): Joysticks that offer analog input from two axes and a digital input from an integrated switch.

  • Potentiometer: An adjustable resistor that provides analog input corresponding to its rotational position.

  • Toggle Switch (x3): Switches that provide digital input to the Arduino Nano.

  • Resistor (x2): Resistors with a value of 1000 Ohms, used for voltage division and limiting current.

  • 2x 18650 Battery Pack: The power source for the circuit.

Wiring Details

Arduino Nano

  • D2: Connected to Toggle Switch (Gnd)
  • D3: Connected to Toggle Switch (Vcc)
  • D4: Connected to Toggle Switch (Vcc)
  • D5: Connected to Toggle Switch (Gnd)
  • D9: Connected to NRF24L01 (CSN)
  • D10: Connected to NRF24L01 (CE)
  • D11/MOSI: Connected to NRF24L01 (MOSI)
  • D12/MISO: Connected to NRF24L01 (MISO)
  • D13/SCK: Connected to NRF24L01 (SCK)
  • A0: Connected to Potentiometer (Output)
  • A1: Connected to Adafruit Analog 2-Axis Joystick (YOUT)
  • A2: Connected to Adafruit Analog 2-Axis Joystick (XOUT)
  • A3: Connected to Adafruit Analog 2-Axis Joystick (YOUT)
  • A4: Connected to OLED Display (SDA)
  • A5: Connected to OLED Display (SCL)
  • A6: Connected to Adafruit Analog 2-Axis Joystick (XOUT)
  • A7: Connected to Resistor (pin1)
  • 5V: Connected to Joysticks, Potentiometer, and OLED Display (VCC)
  • GND: Connected to Joysticks, Potentiometer, OLED Display, NRF24L01, and Resistor (GND)
  • 3V3: Connected to NRF24L01 (VCC)
  • VIN: Connected to Resistor (pin1) and Toggle Switch (L1)

NRF24L01

  • CE: Connected to Arduino Nano (D10)
  • CSN: Connected to Arduino Nano (D9)
  • MOSI: Connected to Arduino Nano (D11/MOSI)
  • MISO: Connected to Arduino Nano (D12/MISO)
  • SCK: Connected to Arduino Nano (D13/SCK)
  • VCC (3V): Connected to Arduino Nano (3V3)
  • GND: Connected to common ground

OLED 1.3" Display

  • GND: Connected to common ground
  • VCC: Connected to Arduino Nano (5V)
  • SCL: Connected to Arduino Nano (A5)
  • SDA: Connected to Arduino Nano (A4)

Adafruit Analog 2-Axis Joystick

  • VCC: Connected to Arduino Nano (5V)
  • XOUT: Connected to Arduino Nano (A2) and (A6)
  • YOUT: Connected to Arduino Nano (A1) and (A3)
  • SWITCH: Not connected in this circuit
  • GND: Connected to common ground

Potentiometer

  • VCC: Connected to Arduino Nano (5V)
  • Output: Connected to Arduino Nano (A0)
  • GND: Connected to common ground

Toggle Switch

  • Vcc: Connected to Arduino Nano (D3) and (D4)
  • Sig: Connected to common ground
  • Gnd: Connected to Arduino Nano (D2) and (D5)

Resistor

  • pin1: Connected to Arduino Nano (A7) and (VIN)
  • pin2: Connected to common ground

2x 18650 Battery Pack

  • Vcc: Connected to Toggle Switch (COM)
  • Gnd: Connected to common ground

Documented Code

Arduino Nano Code

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h>

#define OLED_RESET -1
Adafruit_SH1106 display(OLED_RESET);

float vol = 0;
int input = 0;

int vdividerPin = A7;

const uint64_t pipeOut = 0xE8E8F0F0E1LL;

RF24 radio(10, 9); // select  CE and CSN  pins

struct MyData {
  byte throttle;
  byte yaw;
  byte pitch;
  byte roll;
  byte AUX1;
  byte AUX2;
};

MyData data;

unsigned long oledUpdateTime = 0;
const unsigned long oledUpdateInterval = 100;

void resetData()
{
  data.throttle = 0;
  data.yaw = 127;
  data.pitch = 127;
  data.roll = 127;
  data.AUX1 = 0;
  data.AUX2 = 0;
}

void setup()
{
  radio.begin();
  radio.setAutoAck(false);
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(pipeOut);
  resetData();

  display.begin(SH1106_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(20,5);
  display.println("Arduino Drone");
  display.setCursor(15,19);
  display.println("Transmitter By");
  display.setCursor(0,33);
  display.println("--> UnKnown <--");
  display.setCursor(0,47);
  display.println(">UnKnown & UnKnown<");
  display.display();
  delay(10000);
  display.clearDisplay();

  pinMode(vdividerPin, INPUT);
  Serial.begin(9600); 

  pinMode(5, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);

}

int mapJoystickValues(int val, int lower, int middle, int upper, bool reverse)
{
  val = constrain(val, lower, upper);
  if ( val < middle )
    val = map(val, lower, middle, 0, 128);
  else
    val = map(val, middle, upper, 128, 255);
  return ( reverse ? 255 - val : val );
}

void loop()
{
  unsigned long currentMillis = millis();

  if (currentMillis - oledUpdateTime >= oledUpdateInterval) {
    updateOLED();
    oledUpdateTime = currentMillis;
  }
  
  data.throttle = mapJoystickValues( analogRead(A3), 13, 524, 1015, true );
  data.yaw      = mapJoystickValues( analogRead(A1), 50, 505, 1020, true );
  data.pitch    = mapJoystickValues( analogRead(A2), 12, 544, 1021, true );
  data.roll     = mapJoystickValues( analogRead(A6), 34, 522, 1020, true );
  data.AUX1     = digitalRead(5);
  data.AUX2     = digitalRead(3);

  radio.write(&data, sizeof(MyData));
}

void updateOLED() {

  input = analogRead(vdividerPin);
  vol = (input * 10.0) / 1024.0;
  
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(2);
  display.setCursor(0,5);
  display.println("Voltage: ");
  display.setCursor(0,30);
  display.print(vol);
  display.print(" V");
  display.setTextSize(1);
  display.setCursor(0,55);
  display.print("-> BY UnKnown <-");
  display.display();
  delay(100);
}

Additional Documentation

Circuit Documentation
Summary
This circuit is designed to control a drone using an Arduino Nano as the central processing unit. It includes an NRF24L01 module for wireless communication, an OLED display for user feedback, two Adafruit Analog 2-Axis Joysticks for user input, a potentiometer for additional analog input, and toggle switches for digital input. The circuit is powered by a 2x 18650 battery pack, and it