Hello,
I want to send data from an Arduino to Mission Planner.
To do so I have written this code and connected the rx/tx port of the Arduino to the Telem2 port of my Pixhawk flight controller.
In Mission Planner I configured the following options for the telem2 port (see images).
I’m trying to send dummy data from the Arduino with this code:
#include "mavlink.h"
// RAW DATA SEND
// Pixhawk System ID und Component ID
const uint8_t pixhawk_sysid = 1; // Set your Pixhawk's System ID
const uint8_t pixhawk_compid = 1; // Set your Pixhawk's Component ID
void setup() {
Serial.begin(115200); // Kommunikation über den seriellen Monitor
}
void loop() {
sendRawPressureData();
delay(1000); // Nachricht alle 1 Sekunde senden
}
void sendRawPressureData() {
mavlink_message_t msg;
uint64_t time_usec = micros();
int16_t press_abs = 1000;
int16_t press_diff1 = 500;
int16_t press_diff2 = 300;
int16_t temperature = 250;
// Packen der RAW_PRESSURE-MAVLink-Nachricht
mavlink_msg_raw_pressure_pack(pixhawk_sysid, pixhawk_compid, &msg, time_usec, press_abs, press_diff1, press_diff2, temperature);
// Senden der MAVLink-Nachricht über die serielle Schnittstelle
uint8_t buf[MAVLINK_MAX_PACKET_LEN];
uint16_t len = mavlink_msg_to_send_buffer(buf, &msg);
Serial.write(buf, len);
// Debug-Ausgabe auf dem seriellen Monitor
Serial.println("Nachricht gesendet.");
}
I would be very thankful for further instructions and help to complete this!
BTW is this the right way to do this?
Thanks