SmartAudio for VTX Mateksys 405 WING

Hello All,

This is my first post here and I’m new to the hobby so please excuse and noobness.

I have a Mateksys 405 FC with a VTX with a Smartaudio input. The VTX I have is a pain to change the power / band / channel and I want to be able to do this outside of pressing the tiny button on the VTX and trying to understand the LED’s!

At the moment I’d be happy just to be able to control the power with a 3 point switch on the controller.

From what I can understand I have a few options as this is not supported by Ardupilot out of the box;

  1. Upgrade my FC so I can run LUA scripts and writing something that could control it. (would need to buy a F765)
  2. Build a custom firmware using the smartaudio branch on GitHub. (pain with new releases)
  3. Upgrade my RC receiver so it includes a smart audio link so I can change the settings via my Taranis qx7 (expensive?)

Any I missing something? Does anyone else have any other suggestions.

Thanks,

Craig

Trying to go down the LUA script route but I’m having issues opening the serial port. It seems that the examples say to use the following;

local port = serial:find_serial(0)
if not port then
gcs:send_text(0, “No Scripting Serial Port”)
return
end

However this just causes LUA to not run so I’m assuming the code is dodge.

Anyone know how I can send hex(hexidecimal) to a serial port in LUA?

you will need to run master branch code to use the master examples.

https://firmware.ardupilot.org/Plane/latest/

great thanks I will try that. How do I get the master examples to run in Mission Planner? I have tried downloading the latest beta build but I still get the same issue.

Ctrl + q in the load firmware page or download from the above link and upload with the custom firmware button

I don’t have my FC here at the moment so wanted to use sitl - is that possible to use the lastest Dev firmware in the simulation?

I have managed to get the latest 4.1 build onto a Matek F765-WING.

However, when running the following Lua script, it doesn’t find a serial port. How do I setup a serial port to be a ‘scripting’ serial port?

– find the serial first (0) scripting serial port instance
local port = serial:find_serial(0)

if not port or baud == 0 then
gcs:send_text(0, “No Scripting Serial Port”)
return
end

SERIALx_PROTOCOL = 28:Scripting

1 Like

Great thanks… I’m now trying to write a hexidecimal value to the port. As per the smart audio documentation, a low power command would be;

local SMARTAUDIO_V2_COMMAND_POWER_0 = { 0x05, 0x01, 0x00, 0x6B }
port:write(SMARTAUDIO_V2_COMMAND_POWER_0)

I can’t use this as the variable is a ‘table’. What is the syntax for writing that command to the port:write method?

I think I may have it…

for count = 1, #value do
port:write(value[count])
end

value being the table

This is the example,

I have not done writing myself, but it look like its one byte at a time. So you could do:
port:write(0x05)
port:write(0x01)
port:write(0x00)
port:write(0x6B)

You could write yourself a little helper to take a table and do that for each entry. That would make for a nice example.

If you have a telem connection, you can assign it to scripting rather than mavlink and then use a terminal program, such as the Arduino one, to see what your sending. I think it should also be possible to do that over the USB connection, but I have not tried, (this also means you can’t turn it off unless you have a second MAVLink connection). The H7 boards with dual USB endpoints would be great for this.

By the way we have a Scripting channel over on the AP discord if you want faster but even less well thought through advice.

1 Like

@craigy72,
What radio equipment are you using (QX7 with 2.4 receiver or crossfire on the QX7)?

You can bypass the FC and just run the smart audio pin from the vtx to the receiver if its crossfire and control all the vtx settings via the opentx built in lua scripts.

I am running a ZOHD Nano Talon with an Matek F405, TBS micro receiver and a vtx with smart audio. By wiring the vtx straight to the smart audio pin on the micro receiver I am able to control everything through the lua script on the QX7.

I decided to go down the LUA Script route and have developed the first version (which is working with Smartaudio v2.0. The instructions for anyone who is interested is below;

These are the instructions to get SmartAudio working on a Mateksys 765 and an Eachine TX805. This build has only been tested on the previously mentioned hardware. It may well work on other flight controllers and VTX’s that support Smartaudio 2.0

This LUA script allows the pilot to change the power settings of the VTX on the fly (manual mode) or it can be set to auto mode where the distance away from the home is used to increase/decrease the VTX power. At the moment this requires to be set in the code but can set via an RC channel also (available in the next build)
There are few things that need to be setup first in order to get the LUA script to run successfully;

-- Prerequisites ----------------------------------
  1. Only (currently) works in Ardupilot 4.1 (serial access is required)

  2. FC with 2MB cache for LUA Scripting

  3. Currently only works with SmartAudio 2.0

    ------------ Instructions ------------------------

  4. Set serial5 in Ardupilot to protocol 28 (scripting)

  5. Setup channel 5(or any…but be sure to update the RCchannel variable)

  6. Connect Smartaudio cable (usually green) to serial5, which for the Matek 765 us UART 8. As we will set to half duplex mode, connect to Tx8.

  7. Set Half Duplex mode on serial5 – set SERIAL_OPTIONS to ‘4’

  8. Navigate to Config > MavFTP -> APM > Scripts (create this if you don’t have it)

  9. Upload the LUA script to this folder.

  10. Setup your RC transmitter switch/dial to output on channel 5. You may need to run the calibration in Mission Planner

When working correctly you will see correct messages in Mission Planner;

Capture

YouTube Video of it Working

LUA Script on GitHub

3 Likes

is half duplex requirement? you are just using the TX pin, right?

Its not a requirement no as I’m only sending commands

see my comments on Discord docs… and I think the auto one should be a separate script…I envision adding stand alone scripts in a separate AP_Scripting dir with a wiki page for LUA applets with complete setup and use instructions…maybe make the default rc higher up so they do not have to change…like ch7 (ch5 is mode in copter/rover)…want them to only copy and go…maybe we should add an RC option for scripting input switch?

fyi, after some discussion of this idea, Peter Hall volunteered to add the binding to find an option channel and return its value…so now the script wont have to hard code a channel, it can be assigned by the user as input…it will be continuous PWM so that it can be shaped by the RC min/max/trim and used as an analog variable also…

Great look forward to playing with the end result. Let me know if you need me to do anything, happy to do some testing etc.

can you build code locally? if so, merge this and try using it … https://github.com/ArduPilot/ardupilot/pull/14777 for the RC channel input… if not, I can compile for whatever board you are using …F405-wing? let me know