Current SPAD.neXt Release: 0.9.10.0

Who's using Arduino's

Discussion about special hardware
Redscouse
Flight Attendant
Posts: 36
Joined: 22 Aug 2020, 17:05
Contact:
Status: Offline

Re: Who's using Arduino's

Post by Redscouse » 03 Jun 2021, 18:32

Thanks dt for the reply.

I might just take you up on that offer. I'm off to Amazon now to purchase the required bits n bobs. :D
I have the complete edition of SpadNext so I'm comfortable setting up profiles/commands etc. my home cockpit is already half decent, I'm just itching to code/build something and see what I can dream up.

Thanks again for the offer/assistance. I'm sure I'll be in touch in the near future.
Pete.

Happy flying. 8-)
I'm Pete, AKA: Redscouse, owner and creator of Scouse Airlines.
Since MS2000, I've been tinkering with liveries, missions and scenery etc.

Check out the download section of my website and grab some free stuff!

Redscouse
Flight Attendant
Posts: 36
Joined: 22 Aug 2020, 17:05
Contact:
Status: Offline

Re: Who's using Arduino's

Post by Redscouse » 06 Jun 2021, 14:45

Update:
I purchased a couple of Arduino boards. (First one being an UNO before I read some more and realized I needed a Leonardo)
I've dug out my 'box of bits' and have amongst other things, a 4 line LCD.

Can SpadNext send back readable data I can capture and display on this screen. Things like outside temperature. Dew points etc.?
I'm comfortable writing the code to display the data. I just need a little nudge in the right direction to get the data.

I've just stumbled upon the SpadNext serial connection library which I've uploaded the demo sketch. I'm a bit stumped from there..
Any help greatly appreciated.

Pete.
I'm Pete, AKA: Redscouse, owner and creator of Scouse Airlines.
Since MS2000, I've been tinkering with liveries, missions and scenery etc.

Check out the download section of my website and grab some free stuff!

dt3585
Passenger
Posts: 9
Joined: 03 Jun 2021, 03:00
Status: Offline

Re: Who's using Arduino's

Post by dt3585 » 07 Jun 2021, 05:50

Pete unfortunately I have not figured out how to extract a value from the simulator through spad and send that information to the Arduino for physical digital display. I'm glad that you got a handle on the Arduino programming and spad interface. The information and data ref Library used bye spad is still a mystery to me. Honestly it sounds like you have made more progress than I. Keep me posted on your progress and maybe later we can help each other to extract and display values needed for the Simpit. I have been looking for answers to exactly your problem because as of now my simpit is very basic with a yoke and rudder with a few basic buttons to control radio frequency battery avionics and alternator along with parking brake and landing gear position. I have been trying to figure out how to extract and send Comm frequency nav frequency and a d f frequencies to a seven segment display. This is as of right now my biggest struggle

Redscouse
Flight Attendant
Posts: 36
Joined: 22 Aug 2020, 17:05
Contact:
Status: Offline

Re: Who's using Arduino's

Post by Redscouse » 07 Jun 2021, 16:00

Update 2:

I needed to have a little tinker with an Arduino to really appreciate it so I decided to cobble together a simple button box. (switches really)
Fast forward a couple of days and this is where I'm at.

Concept:
Five switches and corresponding LEDs that illuminate when on.
IMG_20210606_225728.jpg
Prototype: (excuse my soldering! :mrgreen: )
IMG_20210607_134227.jpg


Demo: (I've set the beacon switch)
IMG_20210607_144253.jpg
Off:
IMG_20210607_144602.jpg
IMG_20210607_144256.jpg
On:
IMG_20210607_144305.jpg
IMG_20210607_144308.jpg

I appreciate this is one-way communication as a joystick.
Using an UNO connected as serial device, can I have two-way?

Pete.
You do not have the required permissions to view the files attached to this post.
I'm Pete, AKA: Redscouse, owner and creator of Scouse Airlines.
Since MS2000, I've been tinkering with liveries, missions and scenery etc.

Check out the download section of my website and grab some free stuff!

dt3585
Passenger
Posts: 9
Joined: 03 Jun 2021, 03:00
Status: Offline

Re: Who's using Arduino's

Post by dt3585 » 08 Jun 2021, 05:08

I honestly have no idea. I went straight to the joystick interface using the joystick. H library from Arduino. CC. I know the Arduino is capable of two way serial communication but whether or not it's capable of that in Spad. Next I don't know.

dt3585
Passenger
Posts: 9
Joined: 03 Jun 2021, 03:00
Status: Offline

Re: Who's using Arduino's

Post by dt3585 » 08 Jun 2021, 05:16

I am going to be experimenting with this program this weekend to see if I can send a frequency from a display to the simulator through Spade next.

Redscouse
Flight Attendant
Posts: 36
Joined: 22 Aug 2020, 17:05
Contact:
Status: Offline

Re: Who's using Arduino's

Post by Redscouse » 08 Jun 2021, 10:42

Redscouse wrote:
07 Jun 2021, 16:00
Using an UNO connected as serial device, can I have two-way?
Update 3:

I've made a bit of progress with my own question above. I'd say I'm almost there.

Concept: Use Arduino to display readouts via 4x16 LCD.

Prototype: Yep, one button. :D
IMG_20210608_085003.jpg

Result:

Ping<>Pong all good.
IMG_20210608_091927.jpg

Flick switch on: aha, there is the data. (parking brake also activates so i could visibly see something happening)
InkedIMG_20210608_091958_LI.jpg

Flick switch off: oh no! the values have reset to zero!?
InkedIMG_20210608_092022_LI.jpg

Code snippets below:
c1.PNG
c2.PNG



Problem 1:
Why did the value reset to zero?

Problem 2:
How do I extrapolate that value into a variable?

c0nnex? Dazman? anyone?

Any help/advice appreciated.
Pete.

Full Code:

Code: Select all


/*
 * Title:   LCD Display Unit. 
 * Version: 0.0.1
 * 
 * Desc:    Using an 4x16 lcd unit to display various readouts from MSFS2020 via SpadNext.
 * 
 * Author:  Redscouse (of ScouseAirlines.co.uk)
 * Licence: Free to use and modify as required.
 * Created: 07-06-2021 
 * 
 */

#include <CmdMessenger.h>  // CmdMessenger

// ------------------  S E T U P -----------------------


// Set up a flag.
bool isReady = false;
String stdtemp;
String ambtemp;
String tottemp;

int btn_pin = 12;

// Listen on serial connection for messages from the pc
CmdMessenger messenger(Serial);

// This is the list of recognized commands. These can be commands that can either be sent
// or received.
// In order to receive, attach a callback function to these events
enum {
  kRequest    =   0, // Request from SPAD.neXt
  kCommand    =   1, // Command to SPAD.neXt
  kEvent      =   2, // Events from SPAD.neXt
  kDebug      =   3, // Debug strings to SPAD.neXt Logfile
  kSimCommand =   4, // Send Event to Simulation
  kStdTemp    = 100, // My data request.
  kAmbTemp    = 101, // My data request.
  kTotTemp    = 102, // My data request.
};

void attachCommandCallbacks() {
  // Attach callback methods
  messenger.attach(onUnknownCommand);
  messenger.attach(kRequest, onIdentifyRequest);
  messenger.attach(kStdTemp, onStdTempRequest);
  messenger.attach(kAmbTemp, onAmbTempRequest);
  messenger.attach(kTotTemp, onTotTempRequest);
}


// ------------------  C A L L B A C K S -----------------------

// Called when a received command has no attached function
void onUnknownCommand()
{
  messenger.sendCmd(kDebug,"UNKNOWN COMMAND"); 
}


// Callback function to respond to indentify request. This is part of the
// Auto connection handshake.
void onIdentifyRequest() {
  //
  char *szRequest = messenger.readStringArg();

  //
  if (strcmp(szRequest, "INIT") == 0) {
    messenger.sendCmdStart(kRequest);
    messenger.sendCmdArg("SPAD");
    // Unique Device ID: Change this!
    messenger.sendCmdArg(F("{3f7b6426-8647-4695-8341-77ce407b7169}"));
    // Device Name for UI
    messenger.sendCmdArg("MSFS Temperature Monitor");
    messenger.sendCmdEnd();
    return;
  }

  if (strcmp(szRequest, "PING") == 0) {
    messenger.sendCmdStart(kRequest);
    messenger.sendCmdArg("PONG");
    messenger.sendCmdArg(messenger.readInt32Arg());
    messenger.sendCmdEnd();
    return;
  }
  
  if (strcmp(szRequest, "CONFIG") == 0) {

    // Request standard temperature updates
    messenger.sendCmdStart(kCommand);
    messenger.sendCmdArg("SUBSCRIBE");
    messenger.sendCmdArg(kStdTemp);
    messenger.sendCmdArg("SIMCONNECT:STANDARD ATM TEMPERATURE");
    messenger.sendCmdEnd();

    // Request ambient temperature updates
    messenger.sendCmdStart(kCommand);
    messenger.sendCmdArg("SUBSCRIBE");
    messenger.sendCmdArg(kAmbTemp);
    messenger.sendCmdArg("SIMCONNECT:AMBIENT TEMPERATURE");
    messenger.sendCmdEnd();

    // Request total air temperature updates
    messenger.sendCmdStart(kCommand);
    messenger.sendCmdArg("SUBSCRIBE");
    messenger.sendCmdArg(kTotTemp);
    messenger.sendCmdArg("SIMCONNECT:TOTAL AIR TEMPERATURE");
    messenger.sendCmdEnd();

    // tell SPAD.neXT we are done with config
    messenger.sendCmd(kRequest, "CONFIG");
    isReady = true;
    //return; // not sure this is required?
  }
}

// Called for standard temperature.
void onStdTempRequest() {
  stdtemp = "red"; //messenger.readInt32Arg();
  messenger.sendCmd(kDebug, "Standard Temperature: ");
  messenger.sendCmd(kDebug);
  messenger.sendCmd(kDebug, stdtemp);
}

// Called for ambient temperature.
void onAmbTempRequest() {
  ambtemp = "green"; //messenger.readInt32Arg();
  messenger.sendCmd(kDebug, "Ambient Temperature");
  messenger.sendCmd(kDebug, ambtemp);
}

// Called for total temperature.
void onTotTempRequest() {
  tottemp = "pink"; //messenger.readInt32Arg();
  messenger.sendCmd(kDebug, "Total Temperature");
  messenger.sendCmd(kDebug, tottemp);
}

// ------------------ M A I N  ----------------------

// Set up the required pins etc.
void setup() {
  
  // Initialise serial to display output in console.
  Serial.begin(115200);

  // Attach my application's user-defined callback methods
  attachCommandCallbacks();
  
  // Initialize button pins as input_pullup
  pinMode(btn_pin, INPUT_PULLUP);
}

// Last state of the button
int lastButtonState = 0;

// Run the loop.
void loop() {

  // check the button.
  int currentButtonState = !digitalRead(btn_pin);
  if (currentButtonState != lastButtonState) {
    lastButtonState = currentButtonState;

    if (currentButtonState == 1) { 
      messenger.sendCmd(kSimCommand,"SIMCONNECT:PARKING_BRAKES,36000");
    }
    if (currentButtonState == 0) { 
      messenger.sendCmd(kSimCommand,"SIMCONNECT:PARKING_BRAKES,0");
    }
  
    messenger.sendCmd(kStdTemp);
    messenger.sendCmd(kAmbTemp);
    messenger.sendCmd(kTotTemp);

  }

  // Process incoming serial data, and perform callbacks
  messenger.feedinSerialData();
}

You do not have the required permissions to view the files attached to this post.
I'm Pete, AKA: Redscouse, owner and creator of Scouse Airlines.
Since MS2000, I've been tinkering with liveries, missions and scenery etc.

Check out the download section of my website and grab some free stuff!

Redscouse
Flight Attendant
Posts: 36
Joined: 22 Aug 2020, 17:05
Contact:
Status: Offline

Re: Who's using Arduino's

Post by Redscouse » 08 Jun 2021, 16:48

Bit of a curve ball...
I fired up Visual Studio and with the help of a fantastic Youtube tutorial, I was able to get the data i needed using SimConnect! :ugeek: :ugeek:
I'd still like to figure out the above though if anyone would be so kind. :mrgreen:

Pete.

IMG_20210608_153926c.jpg
You do not have the required permissions to view the files attached to this post.
I'm Pete, AKA: Redscouse, owner and creator of Scouse Airlines.
Since MS2000, I've been tinkering with liveries, missions and scenery etc.

Check out the download section of my website and grab some free stuff!

lesoreilly
Captain
Posts: 272
Joined: 31 Jul 2015, 01:07
Status: Offline

Re: Who's using Arduino's

Post by lesoreilly » 08 Jun 2021, 18:29

I made an UNO into an Autopilot... here is a video with all the information and even a link to the sketch

https://youtu.be/piDx-6n58Hw

Redscouse
Flight Attendant
Posts: 36
Joined: 22 Aug 2020, 17:05
Contact:
Status: Offline

Re: Who's using Arduino's

Post by Redscouse » 08 Jun 2021, 18:40

Hi Les,

Thanks for the reply, appreciate the link.
Going to grab a coffee and watch it then update my code accordingly.
Will post results back sometime later.

Pete.
I'm Pete, AKA: Redscouse, owner and creator of Scouse Airlines.
Since MS2000, I've been tinkering with liveries, missions and scenery etc.

Check out the download section of my website and grab some free stuff!

Post Reply