Bits and Droids logo
Mail icon

Flight sim data and Arduino library update 0.4.0

by Bits and Droids | 21-03-2023

Hi guys. I've added 5 new functions which can be found under the heading: "Available functions". You're now able to retrieve the current heading, speed in knots, vertical speed, altitude and GPS Ground speed???

IMPORTANT FOR UNO/MEGA USERS!

When using an Uno or Mega it's important to pass a false boolean when creating the connector (BitsAndDroidsFlightConnector connector(false);). This will tell the system that an Uno is connected. Another thing to keep in mind is that it's important to place a 10Uf capacitor between the ground and reset pins on the board (https://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection/). The Uno resets when a serial connection is made. This would result in a constant state of receiving data <-> reset. When you upload a sketch you can just take the capacitor out (or else it won't upload) and reinsert it afterward.

How does it work?

These are the steps needed to get the library to work:

  • In the Arduino IDE navigate to Sketch -> include library -> Add .ZIP library
  • Select the library from your downloads folder (or the location you've saved it)
  • In a new sketch start by including #include <BitsAndDroidsFlightConnector.h>
  • Create a new connector above the setup block (pass true for Leonardo/Pro micro and false for Uno/Mega/nano): BitsAndDroidsFlightConnector connector(true);
  • Read the notes above depending on the board you're using
  • In the loop block add: connector.dataHandling();
  • Display the data any way you'd like by calling one of the functions that are included (see table below). this can be done by referencing the connector followed by a dot and the desired function. I.e. connector.getActiveCom1()

It still uses the latest connector which can be downloaded from www.bitsanddroids.com/downloads. In the example code, I've made use of an I2C Lcd display but you're able to display the data any way you like. The example code can be found in the Arduino IDE at File -> examples -> BitsAndDroidsFlightConnector (can be found at the Examples from custom libraries category).

Available functions

FunctionActionReturns
.dataHandling()Starts the serial monitoring and manages the dataNothing
.getIndicatedAirspeed()returns current speed in KnotsString i.e. 200
.getIndicatedAltitude()returns current altitude in feetString i.e. -100 or 40000
.getIndicatedHeading()returns current heading in degreesString i.e. 240
.getIndicatedGPSGroundspeed()you tell me?String something
.getTrueVerticalSpeed()returns current vertical speedi.e. -150 or 280
.getActiveCom1()returns active com 1String i.e. 245.200
.getActiveCom2()returns active com 2String i.e. 245.200
.getStandbyCom1()returns standby com 1String i.e. 245.200
.getStandbyCom2()returns standby com 2String i.e. 245.200
.getApVerticalSpeed()returns ap vertical speedString i.e. -1000 or 4500
.getApAltLock()returns ap altitude lockString i.e. 30000
.getKohlmanAltimeter()returns kohlman/altimeterString i.e. 29.92 This can be a weird duck ingame since sometimes it's the digital altimiter and sometimes the old school gauge
.getBarPressure()returns barometric pressureString i.e. 2489 To be honest I have no clue what it actually represents didn't have time to investigate.

Example code

Notice the small Serial.setTimeout(10)? You need to check for yourself if a bigger value is needed to increase stability.

//DONT FORGET TO ADD A 10Uf capacitor after installing the sketch between ground and the reset pin on the board
#include <BitsAndDroidsFlightConnector.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

//create a new connector flase = Uno/Mega, True = Leonardo/Pro Micro
BitsAndDroidsFlightConnector connector(true);
//16x2 I2C display
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 20, 4);

void setup() {
  lcd.init();
  lcd.backlight();
  //This can be left out if you use an Leonardo/Pro micro
  Serial.begin(115200);
  Serial.setTimeout(10);
}

void loop() {
  //start the data processing
   connector.dataHandling();

   lcd.setCursor(0,0);
   //retrieve active com 1 from the connector
   lcd.print(connector.getIndicatedAirspeed());
   lcd.setCursor(0,1);
     //retrieve active com 2 from the connector
   lcd.print(connector.getIndicatedAltitude());
   lcd.setCursor(8,0);
     //retrieve standby com 1 from the connector
   lcd.print(connector.getIndicatedHeading());
   lcd.setCursor(8,1);
   //retrieve standby com 2 from the connector
   lcd.print(connector.getIndicatedGPSGroundspeed());
   lcd.setCursor(0,2);
   //retrieve active com 1 from the connector
   lcd.print(connector.getTrueVerticalSpeed());
   lcd.setCursor(0,3);
     //retrieve active com 2 from the connector
   lcd.print(connector.getActiveCom1());
   lcd.setCursor(8,2);
     //retrieve standby com 1 from the connector
   lcd.print(connector.getStandByCom1());
}

Now as always please let me know if you have any questions or if you'd like to receive more data from the game (you can leave them at my Youtube channel or send them to info@bitsanddroids.com). Suggestions and feedback are always welcome. Till next time!