Skip to content

bendechrai/msfs2mqtt

Repository files navigation

MSFS to MQTT Bridge

MSFS to MQTT Bridge is a CLI application that reads data from Microsoft Flight Simulator (MSFS) using FSUIPC and publishes the data to an MQTT broker. This allows you to monitor flight data in real-time using MQTT clients.

Features

  • Connects to Microsoft Flight Simulator using FSUIPC
  • Reads over 70 data points from the simulator including:
    • Flight data (position, altitude, attitude)
    • Speed data (ground, true air, indicated air speeds)
    • Engine parameters (N1, N2, temperatures, pressures)
    • Autopilot settings
    • Aircraft controls and surfaces
    • Environment data
    • Navigation systems
    • Fuel systems
  • Publishes data to any MQTT broker
  • Uses efficient memory block reading to optimize performance
  • Error recovery and reconnection logic

Installation

Required Software

  1. Microsoft Flight Simulator: MSFS 2020 or MSFS 2024
  2. FSUIPC7: Required to access flight simulator data. Check out Pete & John Dowson's Software page for more information.
  3. .NET 8.0 SDK: Required to build and run MSFS2MQTT
  4. MQTT Broker: Required to receive and distribute data

Step 1: Install and Configure FSUIPC

  1. Purchase and download FSUIPC7 for MSFS 2020/2024
  2. Install FSUIPC following the instructions provided
  3. Register FSUIPC if you purchased a license
  4. Launch Microsoft Flight Simulator
  5. Press Ctrl+F to open the FSUIPC configuration window
  6. Ensure FSUIPC is working correctly

Step 2: Set Up MQTT Broker

Mosquitto (recommended for local setups)

  1. Download and install Mosquitto
  2. Create or edit the mosquitto.conf file to configure access:
listener 1883
allow_anonymous true
  1. Start the Mosquitto broker:
mosquitto -c mosquitto.conf

HiveMQ (alternative)

  1. Download and install HiveMQ broker
  2. Start HiveMQ according to its documentation
  3. Access the web UI at http://localhost:8080 (default)

Step 3: Install and Configure MSFS2MQTT

  1. Clone the repository:
git clone https://github.com/bendechrai/msfs2mqtt.git
cd msfs2mqtt
  1. Build the project:
dotnet build
  1. Configure MQTT connection:

Modify the AppSettings.cs file in the Configuration folder to match your MQTT broker settings:

public MQTTSettings MQTTSettings { get; } = new MQTTSettings
{
    BrokerAddress = "localhost", // Change to your MQTT broker address
    BrokerPort = 1883,           // Change to your MQTT broker port
    ClientId = "MSFS2MQTT",
    TopicPrefix = "msfs/"         // Change to your preferred topic prefix
};
  1. Run the application:
dotnet run

Step 4: Test the Setup

  1. Start Microsoft Flight Simulator
  2. Start a flight or use an existing save
  3. Run MSFS2MQTT
  4. Verify you see "Connected to FSUIPC!" and "Connected to MQTT broker!" messages
  5. Use an MQTT client to subscribe to the topics and verify data is being published

Testing with MQTT Explorer

  1. Download and install MQTT Explorer
  2. Connect to your MQTT broker
  3. Move controls in the simulator and observe the data changes in real-time

Troubleshooting

FSUIPC Connection Issues

  • Ensure Microsoft Flight Simulator is running before starting MSFS2MQTT
  • Check that FSUIPC7 is correctly installed and registered
  • Try restarting both MSFS and MSFS2MQTT

MQTT Connection Issues

  • Verify your MQTT broker is running (netstat -an | findstr 1883 on Windows)
  • Check firewall settings if connecting to a remote broker
  • Ensure broker credentials are correct if authentication is required

Application Error Messages

  • Error reading FSUIPC data: Check FSUIPC installation and ensure MSFS is running
  • MQTT client not connected: Check MQTT broker status and connection settings
  • Error extracting data from block: This might indicate FSUIPC version incompatibility

Architecture

This application uses an efficient approach to reading data from FSUIPC by using memory blocks instead of individual offsets. This reduces overhead and improves performance.

Design Principles

  1. Single Responsibility: Each extractor is responsible for processing data from exactly one memory block
  2. Clear Boundaries: Memory blocks are defined to align with logical groupings of simulator data
  3. Separation of Concerns: Data extraction is separated from data publishing

Data Flow

  1. MSFS2MQTT connects to FSUIPC to access simulator data
  2. Data is read in efficient memory blocks
  3. Specialized extractors process each data type from its designated memory block
  4. Data is published to MQTT topics
  5. MQTT clients (like Telegraf) can subscribe to these topics

Data Categories

The bridge extracts the following categories of data:

  • Flight Data: Position, altitude, attitude
  • Speed Data: Ground speed, true/indicated airspeeds, vertical speed
  • Engine Data: N1/N2, temperatures, pressures, fuel flow
  • Controls: Trim, flaps, gear, spoilers
  • Autopilot: Modes, settings, targets
  • Environment: Atmospheric conditions, warnings
  • Lights: Aircraft lighting systems
  • Navigation: VOR, ILS, and radio data
  • Fuel: Quantities and consumption

Documentation

Contributing

Contributions are welcome! Feel free to submit pull requests or open issues for bugs and feature requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Get data from FSUIPC and push it to MQTT

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages