Skip to content

jlmyra/NEW_FPV_Transmitter_Code_ESP32_ESPNOW

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP-NOW Transmitter for MultiWii Drone

ESP32-based RC transmitter for the MultiWii ESP32 drone flight controller using ESP-NOW wireless protocol.

Features

  • 4-channel control (Throttle, Yaw, Pitch, Roll)
  • 2 AUX switches for flight modes
  • Bi-directional telemetry from drone
  • 16x2 I2C LCD display
  • 50Hz update rate
  • 500ms failsafe timeout
  • Signal strength (RSSI) monitoring

Hardware Requirements

Components

Component Quantity Notes
ESP32 Dev Board 1 Any ESP32 with ADC1 pins
Analog Joysticks 2 2-axis with button (optional)
Toggle Switches 2 For AUX1/AUX2
16x2 I2C LCD 1 Address 0x27 (optional)
Battery 1 1S-2S LiPo recommended

Wiring (MH-ET LIVE MiniKit)

Function GPIO MiniKit Pin Notes
Throttle 36 Pin 3 Left stick Y-axis (ADC, input-only)
Yaw 39 Pin 4 Left stick X-axis (ADC, input-only)
Pitch 34 Pin 5 Right stick Y-axis (ADC, input-only)
Roll 35 Pin 6 Right stick X-axis (ADC, input-only)
AUX1 26 Pin 10 Flight mode switch
AUX2 27 Pin 11 Secondary function
Left JS Btn 4 Pin 26 Left joystick button (optional)
Right JS Btn 16 Pin 27 Right joystick button (optional)
Battery 32 Pin 7 Voltage divider (optional)
LCD SDA 21 Pin 9 (right) I2C data
LCD SCL 22 Pin 12 (right) I2C clock

Notes:

  • GPIO 34-39 are input-only (no internal pullups) - perfect for joystick ADC
  • GPIO 26, 27 have internal pullups for switches
  • Avoid GPIO 0, 2, 5, 12, 15 (strapping pins)
  • Avoid GPIO 6-11 (connected to internal flash)

Software Setup

1. Install ESP32 Board Support

In Arduino IDE:

  1. File > Preferences
  2. Add to Additional Board URLs:
    https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
    
  3. Tools > Board > Boards Manager > Install "ESP32 by Espressif" (version 3.0.7+)

2. Install Libraries

  • LiquidCrystal_I2C - For LCD display (install via Library Manager)

3. Configure the Transmitter

Edit ESP_NOW_Transmitter.ino:

Set Drone MAC Address (Required)

// Line 27 - Replace with your drone's MAC address
uint8_t RECEIVER_MAC[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};

Get the drone's MAC address from its Serial Monitor output at boot:

ESP32 Receiver MAC Address: AA:BB:CC:DD:EE:FF

Calibrate Joysticks

  1. Upload code with Serial Monitor open (115200 baud)
  2. Move each joystick to min, center, and max positions
  3. Note the raw ADC values (divided by 4 for 10-bit scale)
  4. Update calibration arrays:
// Lines 52-55
int throttleCal[] = {13, 524, 1015};   // {min, center, max}
int yawCal[]      = {50, 505, 1020};
int pitchCal[]    = {12, 544, 1021};
int rollCal[]     = {34, 522, 1020};

Reverse Stick Directions (if needed)

// Lines 58-61
bool throttleReverse = true;   // Set false to invert
bool yawReverse      = true;
bool pitchReverse    = true;
bool rollReverse     = true;

4. Upload

  1. Select Tools > Board > ESP32 Dev Module
  2. Select correct COM port
  3. Click Upload

Usage

Pairing

  1. Power on the drone first
  2. Power on the transmitter
  3. Transmitter auto-pairs when it receives first packet from drone
  4. LCD shows "TX OK" then telemetry data when linked

LCD Display

With telemetry:

3.7V 85% ARM
T:127 ANGLE
  • Line 1: Drone battery, signal strength, armed status
  • Line 2: Throttle value, flight mode

Without telemetry:

TX OK  NO LINK
T:127 AUX1:0

Serial Debug Output

Open Serial Monitor at 115200 baud:

TX: T=0 Y=128 P=128 R=128 AUX=0/0 | OK | Drone: 3.7V 85% ARM ANG

Arming the Drone

  1. Ensure throttle is at minimum (stick down)
  2. Move yaw stick fully right and hold for ~1 second
  3. LCD shows "ARM" when armed
  4. To disarm: throttle minimum + yaw left

Data Structures

Control Data (TX → Drone)

struct struct_message {
  uint8_t throttle;  // 0-255
  uint8_t yaw;       // 0-255
  uint8_t pitch;     // 0-255
  uint8_t roll;      // 0-255
  uint8_t AUX1;      // 0 or 1
  uint8_t AUX2;      // 0 or 1
  uint8_t switches;  // Reserved
};

Telemetry Data (Drone → TX)

struct struct_ack {
  uint8_t vbat;     // Battery (0.1V units, 37 = 3.7V)
  uint8_t rssi;     // Signal strength (0-100%)
  int16_t heading;  // Compass heading (degrees)
  int16_t pitch;    // Pitch angle (0.1 degrees)
  int16_t roll;     // Roll angle (0.1 degrees)
  int16_t alt;      // Altitude (cm)
  uint8_t flags;    // Status flags
};

Flag bits:

Bit Meaning
0 Armed
1 Angle mode
2 Horizon mode
3 Baro mode

Troubleshooting

"TX --" on LCD / No Connection

  • Verify drone is powered and ESP-NOW initialized
  • Check MAC address matches exactly
  • Ensure both devices on same WiFi channel (default: auto)

Joysticks Not Responding Correctly

  • Re-calibrate joystick values
  • Check wiring to correct GPIO pins
  • Verify using ADC1 pins (32-39)

LCD Not Working

  • Check I2C address (try 0x3F if 0x27 doesn't work)
  • Verify SDA/SCL wiring (21/22)
  • Run I2C scanner sketch to find address

Controls Inverted

  • Toggle the *Reverse boolean for that axis
  • Or swap the wiring on the joystick potentiometer

Customization

Change Update Rate

#define TX_INTERVAL_MS  20  // 50Hz (default)
// Use 10 for 100Hz, 50 for 20Hz

Add More AUX Channels

The switches byte is reserved for additional channels. Modify both transmitter and ESP_NOW_RX.cpp to use individual bits.

Remove LCD

Comment out LCD code and remove the library include if not using a display.

License

GPL (inherited from MultiWii project)

Credits

  • Original nRF24 transmitter: ELECTRONOOBS
  • ESP-NOW conversion: Claude Code
  • MultiWii flight controller: Alexandre Dubus

About

FPV Drone Transmitter that communicates with the FPV Drone

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages