├── Arduino Examples ├── Basic_Receive_Functionality │ └── Basic_Receive_Functionality.ino ├── NEW_Basic_Send_N_Receive_Functionality │ └── NEW_Basic_Send_N_Receive_Functionality.ino ├── Variometer_Sketch_V1 │ └── Variometer_Sketch_V1.ino └── Variometer_Sketch_V2 │ └── Variometer_Sketch_V2.ino ├── Debug Version ├── FS2020TA.exe └── SimConnect.dll ├── FS2020TA.exe ├── README.md └── SimConnect.dll /Arduino Examples/Basic_Receive_Functionality/Basic_Receive_Functionality.ino: -------------------------------------------------------------------------------- 1 | 2 | void setup() { 3 | // put your setup code here, to run once: 4 | 5 | Serial.begin(115200); 6 | Serial.setTimeout(50); 7 | // Needed for fast reaction. Could be solved by better get Data From FS2020 function 8 | // Only needed because of the "readStringUntil" function used. Normal Timeout = 1000ms 9 | 10 | } 11 | 12 | void loop() { 13 | getDataFromFS2020(); 14 | } 15 | 16 | 17 | void getDataFromFS2020() { 18 | //Declaration of variables to store the incoming data 19 | String input = "@"; //General input buffer 20 | int value; //Value memory 21 | int index; //Index memory 22 | if (Serial.available() > 0) { 23 | Serial.readStringUntil('@'); //Look out for first Indicator 24 | input += Serial.readStringUntil('/') + "/"; //read the ID 25 | index = Serial.readStringUntil('=').toInt(); 26 | 27 | if (input.indexOf("@763/") != -1) { //Check for Vertical Speed ID 28 | value = Serial.readStringUntil('$').toInt(); //Saves the value as int to "value" Variable for later use 29 | 30 | //Do something with the values... 31 | //like displaying or sending something 32 | //Or include a function like: 33 | //void refreshStepperMotorPosition(int value) 34 | 35 | } if (input.indexOf("@90/") != -1) { //Check for AP Master ID -> Gives Bool Value 36 | value = Serial.readStringUntil('$').toInt(); //Saves the value as int to "value" Variable for later use 37 | 38 | if (value == 1) { 39 | //do something 40 | Serial.print("@465/1$"); //Turns landing lights on when AP is on 41 | } else { 42 | //do something else 43 | Serial.print("@465/0$"); //Turns landing lights on when AP is off 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Arduino Examples/NEW_Basic_Send_N_Receive_Functionality/NEW_Basic_Send_N_Receive_Functionality.ino: -------------------------------------------------------------------------------- 1 | 2 | struct DataSet { 3 | int id; //ID memory 4 | int index; //Index memory 5 | String stringValue; //Value memory String format 6 | int intValue; //Value memory integer format 7 | float floatValue; //Value memory float format 8 | }; 9 | 10 | 11 | void setup() { 12 | // put your setup code here, to run once: 13 | Serial.begin(115200); 14 | } 15 | 16 | void loop() { 17 | getDataFromFS2020_V1(); //Handling of the data inside the function 18 | DataSet newestData = getDataFromFS2020_V2(); //returns struct with the last complete DataSet received from the simulator 19 | //sendCommandToFS2020(465, 1); //Sends command/Import to the simulator format (ID, Value) 20 | } 21 | 22 | 23 | 24 | void getDataFromFS2020_V1() { 25 | //Declaration of variables to store the incoming data 26 | int id = -1; //ID memory 27 | int index; //Index memory 28 | String stringValue; //Value memory String format 29 | int intValue; //Value memory integer format 30 | float floatValue; //Value memory float format 31 | 32 | 33 | 34 | 35 | String temp = ""; 36 | 37 | if (Serial.available() > 0) { 38 | Serial.readStringUntil('@'); //Look out for first Indicator 39 | id = Serial.readStringUntil('/').toInt(); //Reads ID 40 | index = Serial.readStringUntil('=').toInt(); //Reads index 41 | stringValue = Serial.readStringUntil('$'); //Reads value as String 42 | intValue = stringValue.toInt(); //Converts value to integer 43 | floatValue = stringValue.toFloat(); //Converts value to Float 44 | } 45 | 46 | switch (id) { 47 | 48 | case 763: //to add a new variable just add another case with your id 49 | //do something 50 | //Add whatever you want. You can get the values you want by using the 51 | //variables defined above: 52 | /* 53 | int id = -1; //ID memory 54 | int index; //Index memory 55 | String stringValue; //Value memory String format 56 | float floatValue; //Value memory float format 57 | */ 58 | break; 59 | case 90: 60 | if (intValue == 1) { 61 | //do something 62 | sendCommandToFS2020(465, 1); //Turns landing lights on when AP is on 63 | } else { 64 | //do something else 65 | sendCommandToFS2020(465, 0); //Turns landing lights on when AP is off 66 | } 67 | 68 | break; 69 | default: 70 | break; 71 | } 72 | } 73 | 74 | 75 | DataSet getDataFromFS2020_V2() { 76 | DataSet returnDataSet; 77 | String temp = ""; 78 | 79 | if (Serial.available() > 0) { 80 | Serial.readStringUntil('@'); //Look out for first Indicator 81 | returnDataSet.id = Serial.readStringUntil('/').toInt(); //Reads ID 82 | returnDataSet.index = Serial.readStringUntil('=').toInt(); //Reads index 83 | returnDataSet.stringValue = Serial.readStringUntil('$'); //Reads value as String 84 | returnDataSet.intValue = returnDataSet.stringValue.toInt(); //Converts value to integer 85 | returnDataSet.floatValue = returnDataSet.stringValue.toFloat(); //Converts value to Float 86 | } 87 | return returnDataSet; 88 | } 89 | 90 | 91 | 92 | 93 | 94 | void sendCommandToFS2020(int id, int value) { 95 | String output = "@" + String(id) + "/" + String(value) + "$"; 96 | Serial.print(output); 97 | } 98 | 99 | void sendCommandToFS2020(int id, double value) { 100 | String output = "@" + String(id) + "/" + String(value) + "$"; 101 | Serial.print(output); 102 | } 103 | 104 | void sendCommandToFS2020(int id, float value) { 105 | String output = "@" + String(id) + "/" + String(value) + "$"; 106 | Serial.print(output); 107 | } 108 | 109 | void sendCommandToFS2020(int id, String value) { 110 | String output = "@" + String(id) + "/" + String(value) + "$"; 111 | Serial.print(output); 112 | } 113 | 114 | void sendCommandToFS2020(String id, String value) { 115 | String output = "@" + id + "/" + value + "$"; 116 | Serial.print(output); 117 | } 118 | -------------------------------------------------------------------------------- /Arduino Examples/Variometer_Sketch_V1/Variometer_Sketch_V1.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | ////////////////////////////// 4 | ////BEGIN BASIC PARAMETERS//// 5 | 6 | #define STEPPER_STEPS_PER_REVOLUTION 2048 7 | #define STEPPER_SPEED 10 8 | 9 | ////END BASISC PARAMETERS//// 10 | ///////////////////////////// 11 | 12 | ////////////////////// 13 | ////Stepper Struct//// 14 | 15 | struct stepper { 16 | int pos = 0; 17 | int nextPos = 0; 18 | }; 19 | 20 | ////Stepper Struct//// 21 | ////////////////////// 22 | 23 | 24 | 25 | ////////////////////////////// 26 | ////BEGIN GLOBAL VARIABLES//// 27 | 28 | unsigned long timer = 0; //TimeOut Timer 29 | 30 | bool flag = 0; 31 | 32 | Stepper myStepper(STEPPER_STEPS_PER_REVOLUTION, 2, 4, 3, 5); //Variometer 33 | stepper stepStruct; 34 | 35 | ////END GLOBAL VARIABLES//// 36 | //////////////////////////// 37 | 38 | 39 | 40 | void setup() { 41 | 42 | myStepper.setSpeed(STEPPER_SPEED); 43 | 44 | Serial.begin(115200); 45 | Serial.setTimeout(50); 46 | 47 | timer = millis(); 48 | } 49 | 50 | void loop() { 51 | // put your main code here, to run repeatedly: 52 | writeToStepper (); 53 | getDataFromFS2020(); 54 | writeToStepper (); 55 | 56 | if (timer + 2000 < millis()) { 57 | timer = millis(); 58 | if (flag) { 59 | Serial.print("@465/1$"); 60 | } else { 61 | Serial.print("@465/0$"); 62 | } 63 | flag = !flag; 64 | } 65 | } 66 | 67 | 68 | void getDataFromFS2020() { 69 | 70 | String input = "@"; 71 | int value; 72 | int index; 73 | if (Serial.available() > 0) { 74 | Serial.readStringUntil('@'); //Look out for first Indicator 75 | input += Serial.readStringUntil('/') + "/"; //read the ID 76 | index = Serial.readStringUntil('=').toInt(); 77 | 78 | if (input.indexOf("@763/") != -1) { //Check for Vertical Speed ID 79 | value = Serial.readStringUntil('$').toInt(); //Saves the value as int to "value" Variable for later use 80 | updateVariometer (value); 81 | } 82 | } 83 | } 84 | 85 | 86 | void writeToStepper () { 87 | int steps = stepStruct.nextPos - stepStruct.pos; 88 | //Serial.print(steps); 89 | if (steps > 0) { 90 | myStepper.step(1); 91 | stepStruct.pos++; 92 | } else if (steps < 0) { 93 | myStepper.step(-1); 94 | stepStruct.pos--; 95 | } 96 | } 97 | 98 | 99 | void updateVariometer (int feetPerMinute) { 100 | 101 | /* Components: 102 | - 1X Stepper Motor 103 | Positive Max 1024 = 6000 ft/min 104 | Negative Max -1024 = -6000 ft/min 105 | */ 106 | 107 | if (feetPerMinute > 6000) feetPerMinute = 6000; 108 | if (feetPerMinute < -6000) feetPerMinute = -6000; 109 | stepStruct.nextPos = (int) ((1024.0 / 6000.0) * feetPerMinute); 110 | 111 | } 112 | -------------------------------------------------------------------------------- /Arduino Examples/Variometer_Sketch_V2/Variometer_Sketch_V2.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | ////////////////////////////// 4 | ////BEGIN BASIC PARAMETERS//// 5 | 6 | #define STEPPER_STEPS_PER_REVOLUTION 2048 7 | #define STEPPER_SPEED 10 8 | 9 | ////END BASISC PARAMETERS//// 10 | ///////////////////////////// 11 | 12 | ////////////////////// 13 | ////Stepper Struct//// 14 | 15 | struct stepper { 16 | int pos = 0; 17 | int nextPos = 0; 18 | }; 19 | 20 | ////Stepper Struct//// 21 | ////////////////////// 22 | 23 | 24 | 25 | ////////////////////////////// 26 | ////BEGIN GLOBAL VARIABLES//// 27 | 28 | unsigned long timer = 0; //TimeOut Timer 29 | 30 | bool flag = 0; 31 | 32 | Stepper myStepper(STEPPER_STEPS_PER_REVOLUTION, 2, 4, 3, 5); //Variometer 33 | stepper stepStruct; 34 | 35 | ////END GLOBAL VARIABLES//// 36 | //////////////////////////// 37 | 38 | 39 | 40 | void setup() { 41 | 42 | myStepper.setSpeed(STEPPER_SPEED); 43 | Serial.begin(115200); 44 | Serial.setTimeout(50); 45 | timer = millis(); 46 | } 47 | 48 | void loop() { 49 | // put your main code here, to run repeatedly: 50 | writeToStepper (); 51 | getDataFromFS2020(); 52 | //writeToStepper (); 53 | 54 | if (timer + 2000 < millis()) { 55 | timer = millis(); 56 | if (flag) { 57 | sendCommandToFS2020(465, 1); 58 | } else { 59 | sendCommandToFS2020(465, 0); 60 | } 61 | flag = !flag; 62 | } 63 | } 64 | 65 | 66 | void writeToStepper () { 67 | int steps = stepStruct.nextPos - stepStruct.pos; 68 | //Serial.print(steps); 69 | if (steps > 0) { 70 | myStepper.step(1); 71 | stepStruct.pos++; 72 | } else if (steps < 0) { 73 | myStepper.step(-1); 74 | stepStruct.pos--; 75 | } 76 | } 77 | 78 | 79 | void updateVariometer (int feetPerMinute) { 80 | 81 | /* Components: 82 | - 1X Stepper Motor 83 | Positive Max 1024 = 6000 ft/min 84 | Negative Max -1024 = -6000 ft/min 85 | */ 86 | 87 | if (feetPerMinute > 6000) feetPerMinute = 6000; 88 | if (feetPerMinute < -6000) feetPerMinute = -6000; 89 | stepStruct.nextPos = (int) ((1024.0 / 6000.0) * feetPerMinute); 90 | 91 | } 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | void getDataFromFS2020() { 100 | //Declaration of variables to store the incoming data 101 | int id = -1; //ID memory 102 | int index; //Index memory 103 | String stringValue; //Value memory String format 104 | int intValue; //Value memory integer format 105 | float floatValue; //Value memory float format 106 | //bool worked = 0; //Integrity variable 107 | 108 | 109 | 110 | 111 | String temp = ""; 112 | 113 | if (Serial.available() > 0) { 114 | Serial.readStringUntil('@'); //Look out for first Indicator 115 | //temp += Serial.readStringUntil('/'); //read the ID 116 | //id = temp.toInt(); 117 | id = Serial.readStringUntil('/').toInt(); 118 | index = Serial.readStringUntil('=').toInt(); 119 | stringValue = Serial.readStringUntil('$'); 120 | intValue = stringValue.toInt(); 121 | floatValue = stringValue.toFloat(); 122 | } 123 | 124 | switch (id) { 125 | 126 | 127 | case 763: //to add a new variable just add another case with you id 128 | updateVariometer (intValue); 129 | break; 130 | 131 | default: 132 | break; 133 | } 134 | } 135 | 136 | 137 | 138 | 139 | void sendCommandToFS2020(int id, int value) { 140 | String output = "@" + String(id) + "/" + String(value) + "$"; 141 | Serial.print(output); 142 | } 143 | 144 | void sendCommandToFS2020(int id, double value) { 145 | String output = "@" + String(id) + "/" + String(value) + "$"; 146 | Serial.print(output); 147 | } 148 | 149 | void sendCommandToFS2020(int id, float value) { 150 | String output = "@" + String(id) + "/" + String(value) + "$"; 151 | Serial.print(output); 152 | } 153 | 154 | void sendCommandToFS2020(int id, String value) { 155 | String output = "@" + String(id) + "/" + String(value) + "$"; 156 | Serial.print(output); 157 | } 158 | 159 | void sendCommandToFS2020(String id, String value) { 160 | String output = "@" + id + "/" + value + "$"; 161 | Serial.print(output); 162 | } 163 | -------------------------------------------------------------------------------- /Debug Version/FS2020TA.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Seahawk240/Microsoft-FS2020-To-Arduino/89fad5ee3c449a9ca791c35d4d5c61f580a30dc7/Debug Version/FS2020TA.exe -------------------------------------------------------------------------------- /Debug Version/SimConnect.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Seahawk240/Microsoft-FS2020-To-Arduino/89fad5ee3c449a9ca791c35d4d5c61f580a30dc7/Debug Version/SimConnect.dll -------------------------------------------------------------------------------- /FS2020TA.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Seahawk240/Microsoft-FS2020-To-Arduino/89fad5ee3c449a9ca791c35d4d5c61f580a30dc7/FS2020TA.exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Microsoft-FS2020-To-Arduino 2 | A Simple Program which enables communication between a Serial Device (like an Arduino) and the Flight Simulator 2020 3 | 4 | ![alt text](https://user-images.githubusercontent.com/75649854/107162680-3be02e00-69a5-11eb-81bf-a947f9bedb74.png) 5 | 6 | 7 | Just unpack the Zip, copy the programm to wherever you like and start it. Help Pages which explain the functionality of the programm 8 | are included in the Programm itself and will be updated if needed. For Feedback or Bug reports, just check out the "Issues" Page on my Git-Hub page: 9 | Thanks for participating! :) 10 | 11 | https://github.com/Seahawk240/Microsoft-FS2020-To-Arduino.git 12 | 13 | 14 | The programm is completely free! But if you like what you see and want to contribute and help financially you can do that over PayPal: 15 | 16 | 17 | 18 | 19 | [![](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/donate?hosted_button_id=393N836S9BLX4) 20 | 21 | 22 | 23 | 24 | ![alt text](https://repository-images.githubusercontent.com/319487168/e18cb500-c925-11eb-91be-8cbee99cacf7) 25 | -------------------------------------------------------------------------------- /SimConnect.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Seahawk240/Microsoft-FS2020-To-Arduino/89fad5ee3c449a9ca791c35d4d5c61f580a30dc7/SimConnect.dll --------------------------------------------------------------------------------