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

NodeMCU ESP8266 Controlled Drone with TFT Display and nRF24L01 Communication

View and Edit Project In Cirkit DesignerImage of NodeMCU ESP8266 Controlled Drone with TFT Display and nRF24L01 Communication

Circuit Documentation

Summary

This circuit integrates a NodeMCU V3 ESP8266 microcontroller with a variety of peripherals including an LCD TFT screen (ILI9488 HD), an nRF24L01 wireless communication module, an Adafruit Analog 2-Axis Joystick, and a 9V Battery for power. The NodeMCU is responsible for interfacing with the joystick and the LCD screen, as well as communicating wirelessly using the nRF24L01 module. The circuit is designed to capture joystick inputs, process them, and transmit control signals wirelessly, potentially for applications such as remote-controlled devices or drones.

Component List

NodeMCU V3 ESP8266

LCD TFT screen ILI9488 HD

nRF24L01

Adafruit Analog 2-Axis Joystick

9V Battery

Wiring Details

NodeMCU V3 ESP8266

LCD TFT screen ILI9488 HD

nRF24L01

Adafruit Analog 2-Axis Joystick

9V Battery

Documented Code

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9488.h>
#include <Servo.h> // Include the Servo library to control ESCs

#define TFT_CS   D1
#define TFT_RST  D0
#define TFT_DC   D9 // Changed from D3 to D9 to avoid conflict

Adafruit_ILI9488 tft = Adafruit_ILI9488(TFT_CS, TFT_DC, TFT_RST);

RF24 radio(D2, D8); // CE, CSN
const byte address[5] = "00001";

struct Data_Package {
  int throttle;
  int yaw;
  int pitch;
  int roll;
};

Data_Package data;

// Create Servo objects to control the ESCs
Servo esc1;
Servo esc2;
Servo esc3;
Servo esc4;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();

  // Attach the ESCs to the appropriate pins
  esc1.attach(D3); // Connect ESC1 signal wire to D3
  esc2.attach(D4); // Connect ESC2 signal wire to D4
  esc3.attach(D5); // Connect ESC3 signal wire to D5
  esc4.attach(D6); // Connect ESC4 signal wire to D6

  // Initialize ESCs with a low throttle value
  esc1.writeMicroseconds(1000);
  esc2.writeMicroseconds(1000);
  esc3.writeMicroseconds(1000);
  esc4.writeMicroseconds(1000);

  delay(2000); // Wait for ESCs to initialize

  // Initialize the TFT screen
  tft.begin();
  tft.setRotation(1);
  tft.fillScreen(ILI9488_BLACK);
}

void loop() {
  if (radio.available()) {
    radio.read(&data, sizeof(Data_Package));
    
    int throttle = map(data.throttle, 0, 1023, 1000, 2000); // Map throttle to ESC range
    int yaw = map(data.yaw, 0, 1023, 1000, 2000); // Map yaw to ESC range
    int pitch = map(data.pitch, 0, 1023, 1000, 2000); // Map pitch to ESC range
    int roll = map(data.roll, 0, 1023, 1000, 2000); // Map roll to ESC range

    Serial.print("Throttle: ");
    Serial.print(throttle);
    Serial.print(" Yaw: ");
    Serial.print(yaw);
    Serial.print(" Pitch: ");
    Serial.print(pitch);
    Serial.print(" Roll: ");
    Serial.println(roll);

    // Example control logic for motors
    esc1.writeMicroseconds(throttle + pitch + roll);
    esc2.writeMicroseconds(throttle + pitch - roll);
    esc3.writeMicroseconds(throttle - pitch + roll);
    esc4.writeMicroseconds(throttle - pitch - roll);

    // Add additional control logic for yaw if needed
  }

  // Code to receive and display live visuals from the drone
  // This part will depend on how the video data is transmitted
  // and the specific library used for the LCD screen.
  // For example, you might use a separate RF module for video transmission
  // and decode the video data to display on the TFT screen.
}

This code initializes and runs the main functions of the NodeMCU V3 ESP8266 microcontroller. It includes libraries for SPI communication, the nRF24L01 module, graphics for the ILI9488 TFT screen, and servo control. The setup function initializes serial communication, the radio module, and the TFT screen, and attaches the ESCs (Electronic Speed Controllers) to their respective pins. The loop function checks for incoming data from the radio module, processes it, and updates the ESCs accordingly. It also includes a placeholder for video data processing and display on the TFT screen.