I’m currently trying to send data from Arduino Uno to QGroundcontrol via the Pixhawk.
On board of my plane I have two NTC sensors and a RPM Sensor to measure temperature and speed (rpm).
I think Mavlink is the right path to send the data from the Arduino to my Pixhawk and then to QGC or what do you think?
This is my Arduino code:
#include <Thermistor.h>
#include <NTC_Thermistor.h>
// wiring: https://funduino.de/nr-54-ntc-temperatursensor
const int Sensor_Pin1 = A0;
const int Sensor_Pin2 = A1;
const int signalPin = 2;
#define Referenzwiderstand 10000 //
#define Nominalwiderstand 10000 //
#define Nominaltemperatur 25 //
#define BWert 3950 //
Thermistor* thermistor1;
Thermistor* thermistor2;
volatile unsigned long startMicros = 0;
volatile bool firstEdgeDetected = false;
void setup() {
Serial.begin(9600);
pinMode(signalPin, INPUT);
attachInterrupt(digitalPinToInterrupt(signalPin), handleInterrupt, RISING);
thermistor1 = new NTC_Thermistor(Sensor_Pin1, Referenzwiderstand, Nominalwiderstand, Nominaltemperatur, BWert);
thermistor2 = new NTC_Thermistor(Sensor_Pin2, Referenzwiderstand, Nominalwiderstand, Nominaltemperatur, BWert);
}
void loop() {
double celsius1 = 0;
double celsius2 = 0;
for (int i = 0; i <= 999; i++) {
celsius1 += thermistor1->readCelsius();
celsius2 += thermistor2->readCelsius();
}
celsius1 /= 1000;
celsius2 /= 1000;
Serial.print("Temperatur1: ");
Serial.print(celsius1);
Serial.print(" °C");
Serial.print(" Temperatur2: ");
Serial.print(celsius2);
Serial.println(" °C");
delay(100);
}
void handleInterrupt() {
if (!firstEdgeDetected) {
startMicros = micros();
firstEdgeDetected = true;
} else {
unsigned long endMicros = micros();
firstEdgeDetected = false;
unsigned long timeBetweenEdges = endMicros - startMicros;
float frequency = 1000000.0 / timeBetweenEdges;
Serial.print("Frequenz: ");
Serial.print(frequency);
Serial.println(" Hz");
}
}