Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

AAO+Arduino+Gauges?

Featured Replies

I'm a bit confused. If I want to create a real life gauge with a stepper motor or servo, would AAO be the right program for it, or would I use another program for that?

I can't find anything about Arduino in the manual, is it possible to hook up an Arduino directly to AAO, and which Arduinos would be supported? Any other card type? I've got two Arduino Uno, and also got a card with an ATMega128A. Would love to be able to experiment with what I have.

Otherwise, are there any program that I could use together with AAO for a simpler experience, e.g. a program handling the Arduino and sending the inputs to Windows so that AAO can pick them up, or a program that takes the information from MSFS and sends them to the Arduino to handle real life gauges?

  • Commercial Member

AAO is the core program that talks to the simulator. You can only "attach" DirectX controllers (=Joystick interfaces of all kinds) and MIDI devices to it natively. 

But AAO has a web based API built in, that you can use to make other programs access the simulator. As hobby projects I've implemented a couple of example programs that use this principle  - the "Bridge" programs that are available as free downloads on the axisandohs Weebly website. Each Bridge handles different types of hardware and utilizes said Web API. One of those Bridges is for Arduino Mega and Nano boards. I don't have an Uno, so I couldn't make a Sketch for it - Mega and Nano are what you are stuck with at the moment. 

Unless you have a Wifi or LAN shield and write a Sketch to access the AAO WebAPI directly. I already did that too and it wasn't too hard.

Edited by Lorby_SI

LORBY-SI

  • Commercial Member

This is my Arduino Sketch that I used to test the Ethernet Shield with the AAO API. It is basically the Ethernet example with the added HttpRequest. The description of the WebAPI JSON protocol is in the AAO manual.
 

#include <SPI.h>
#include <Ethernet.h>

// assign a MAC address for the ethernet controller.
// fill in your address here:
byte mac[] = {

  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
// Set the static IP address to use if the DHCP fails to assign

IPAddress ip(192, 168, 0, 177);

IPAddress myDns(192, 168, 0, 1);

// initialize the library instance:

EthernetClient client;

byte server[] = { 192, 168, 178, 41 };

int currentState = 0;
int lastState = -1;

void setup() {

  // You can use Ethernet.init(pin) to configure the CS pin
  //Ethernet.init(10);  // Most Arduino shields
  //Ethernet.init(5);   // MKR ETH shield
  //Ethernet.init(0);   // Teensy 2.0
  //Ethernet.init(20);  // Teensy++ 2.0
  //Ethernet.init(15);  // ESP8266 with Adafruit Featherwing Ethernet
  //Ethernet.init(33);  // ESP32 with Adafruit Featherwing Ethernet
  // start serial port:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");

    // Check for Ethernet hardware present
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
      while (true) {
        delay(1); // do nothing, no point running without Ethernet hardware
      }
    }
    if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip, myDns);
    Serial.print("My IP address: ");
    Serial.println(Ethernet.localIP());
  } else {
    Serial.print("  DHCP assigned IP ");
    Serial.println(Ethernet.localIP());
  }

  // give the Ethernet shield a second to initialize:
  delay(10000);

  // initialize the buttons
  pinMode(51, INPUT_PULLUP);
}

void loop() {
  currentState = digitalRead(51);
  if(lastState != currentState){
    if (currentState == HIGH){
        httpRequest(127);   
    }
    else{
        httpRequest(0);   
    }
   lastState = currentState; 
  }
}

// this method makes a HTTP connection to the server:
void httpRequest(int state) {
  // close any connection before send a new request.
  // This will free the socket on the WiFi shield
  client.stop();

  // if there's a successful connection:
  if (client.connect(server, 9080)) {
    Serial.println("connecting...");
    String queryString = String("?dev=101&chn=1&btn=5&bval=") + String(state);
    client.println("GET /webapi" + queryString + " HTTP/1.1");
    client.println("Host: 192.168.178.41");
    client.println("User-Agent: arduino-ethernet");
    client.println("Connection: close");
    client.println();
  } else {
    // if you couldn't make a connection:
    Serial.println("connection failed");
  }
}

 

Edited by Lorby_SI

LORBY-SI

  • Author

That's awesome!

Is there anything about the Uno I could help with so that it would work with the bridge? I don't have money for another board or parts right now, would be awesome to be able to use what I have. I do have some programming background if that helps, but not too much. Some Ada and C.

How is the performance with the webAPI? Or is it just that it communicates over that type of "communication channel", but still directly from Arduino to Bridge to AAO?

  • Commercial Member
18 hours ago, Jackiie said:

That's awesome!

Is there anything about the Uno I could help with so that it would work with the bridge? I don't have money for another board or parts right now, would be awesome to be able to use what I have. I do have some programming background if that helps, but not too much. Some Ada and C.

How is the performance with the webAPI? Or is it just that it communicates over that type of "communication channel", but still directly from Arduino to Bridge to AAO?

When you use the WebAPI you don't need the Bridge. The AAO WebAPI can be used like any JSON webservive, by any program or hardware. You just have to figure out how to configure your network security so the connection can actually happen.
The performance will depend on how powerful the Arduino hardware is - the protocol itself is very basic JSON wrappen in Http Requests.

I will receive some AT328 boards at the end of the week. Those should be similar to the Uno, right? I will test my AAO/Bridge Sketch on them and let you know how that goes. 

LORBY-SI

  • Author
22 hours ago, Lorby_SI said:

When you use the WebAPI you don't need the Bridge. The AAO WebAPI can be used like any JSON webservive, by any program or hardware. You just have to figure out how to configure your network security so the connection can actually happen.
The performance will depend on how powerful the Arduino hardware is - the protocol itself is very basic JSON wrappen in Http Requests.

I will receive some AT328 boards at the end of the week. Those should be similar to the Uno, right? I will test my AAO/Bridge Sketch on them and let you know how that goes. 

Yes, that should be the same chip. Hope it goes well! 🙂

  • Commercial Member
On 10/6/2022 at 4:14 PM, Jackiie said:

Yes, that should be the same chip. Hope it goes well! 🙂

OK, so a new build of the ArduinoBridge is available for download now (b11). This now has a sketch for Uno/AT328 boards too. I didn't have time to test it thoroughly, but the basics seem to work.

LORBY-SI

  • Author

I'm on my second evening, and I think I'm getting a basic understanding how to get the program running. I've mainly tried on the Uno, though I did a quick try on the Nano.

It seems like even touching the port menu in AAO will make the ArduinoBridge unable to connect without restarting, even without changing a value.

It seems like the card is communicating a lot, even when connected (RX/TX blinking a lot). I guess it's constantly pulling/pushing info over "webapi" or similar? (My only other reference is MobiFlight, where it would only blink once every button change).

 

I've gotten my Uno to be green in the Bridge (connected, I guess) but I can't see it anywhere in the AAO application. I've connected an ON-OFF-ON toggle switch to my Arduino, and tested it with MobiFlight where it shows inputs in the debugger. I can't bind it anywhere in AAO, though (MobiFlight closed, restarted applications, tried both add and edit button assignments). How do I know if the input is read by the Arduino?

 

The closest I've gotten to working is binding the Arduino pins in MobiFlight via vJoystick, and then using inputs in AAO, but that doesn't work all the time either. Seems like it stops after a minute or after too many inputs or something.

 

Are there any specifik information I should attach that would make it easier to look at?

  • Author

Been testing more with the Nano.

It connects faster, the Bridge application is faster overall, while loading/"thinking" much more with the Uno.

With the Nano I can easily assign a button.

When I've chosen a pin to be output as a button number, some will be a problem though. When I chose 10 and 11, button 11 worked but not 10. I changed 10 to 12 (still the same pin, the same cables) and suddenly it works.

I could assign both 10, 11, 12 and any other number I chose.

After the assignment, only some choices works, though.

  • Commercial Member
8 hours ago, Jackiie said:

It seems like even touching the port menu in AAO will make the ArduinoBridge unable to connect without restarting, even without changing a value.

When you attempt to change the port, the WebAPI is disabled. This cannot be done "on the fly"

8 hours ago, Jackiie said:

I guess it's constantly pulling/pushing info over "webapi" or similar?

Not with the API. The serial protocol between the Arduino and the Bridge is polling constantly.

8 hours ago, Jackiie said:

but I can't see it anywhere in the AAO application.

You can't, the WebAPI is hardware agnostic. It doesn't care what devices or programs are sending messages to it at any given time. You need to configure a digital input and then use "Add Button" in AAO.

8 hours ago, Jackiie said:

After the assignment, only some choices works, though.

Not sure what you mean by that. There haven't been any complaints by other users so far. The Arduino protocol in use here has been taken from the professional LWR products, and I am not aware of any issues with it. But it may well be that the Uno is not powerful enough to handle the polling protocol. 
Also, make sure that you get the pin polarity on the board and the "Pin Mode" in the Bridge right. If they don't match, button actions tend to be erratic.

Edited by Lorby_SI

LORBY-SI

  • Commercial Member
8 hours ago, Jackiie said:

The closest I've gotten to working is binding the Arduino pins in MobiFlight via vJoystick, and then using inputs in AAO, but that doesn't work all the time either. Seems like it stops after a minute or after too many inputs or something.

Here is another idea, not tested or anything. But theoretically it should work:

I'm not familiar with MobiFlight, but I assume that it can send K: Events? Then you could use the K:ROTOR_BRAKE event to send numbers to AAO where you have a script with "(LISTEN_FOR_K:ROTOR_BRAKE)" waiting for it.

For example, you set 31234/31235/31236 to ROTOR_BRAKE with Mobiflight, and in AAO you would have a script "(LISTEN_FOR_K:ROTOR_BRAKE) 31234 == if{ 1 (>K:mygroup-myscript1) } 31235 == if{ 1 (>K:mygroup-myscript2) } 31236 == if{ 1 (>K:mygroup-myscript3) } " 

You can use any numbers you like, but you have to make sure that the plane is not using ROTOR_BRAKE the same way (like PMDG does). Then you have to keep out of their value range or there will be conflicts.

 

Edited by Lorby_SI

LORBY-SI

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.