Hello! I want use esp32 as reciever for a controll my flight controller (f 405).
I need to connect by UART and send THROTTLE, PITCH and others. I have used protocol mavlink.
This is code for ESP32:
#include <Arduino.h>
#include <HardwareSerial.h>
#include <mavlink.h>
#define UART_TX_PIN 17
#define UART_RX_PIN 16
HardwareSerial SERIAL_PORT (1);
void setup() {
Serial.begin(115200);
SERIAL_PORT.begin(115200, SERIAL_8N1, UART_RX_PIN, UART_TX_PIN);
delay(5000);
}
void loop() {
uint16_t throttle_value = 1500;
mavlink_message_t msg;
uint8_t buf[MAVLINK_MAX_PACKET_LEN];
mavlink_msg_rc_channels_override_pack(0xFF, 0xBE, &msg, 1, 1, 0, 0, 0, 0, throttle_value, 0, 0, 0);
uint16_t len = mavlink_msg_to_send_buffer(buf, &msg);
SERIAL_PORT.write(buf, len);
delay(1000);
}
But this is code dont start the motors. Maybe problem on the code or no... I dont understand. So thank for any help.