Guide: How to set up the Softserial UART
What is Softserial?
Softserial is the abbreviation from “Software Serial” and it is software emulated serial port. In softserial port all the communication control: sending/receiving bytes is performed by software versus the hardware serial ports that have built in hardware for communication control. This means softserial ports adds heavier load on the MCU. However some of the peripherals don’t need constant communication with the flight controller and sends/receives the data occasionally. A perfect example is SmartAudio VTX control, that is used to change the VTX settings only when aircraft is disarmed.
Advantages of the Softserial
The one advantage of soft serial is the possibility to invert the signal via software. This is useful for SmartPort, as you no longer have to hack the signal wire to the inverted output on the receiver.
The other advantage of the software serial is the possibility to setup the port on flight controllers unused pads. You can increase the number of serial ports and connect additional devices.
Also worth mentioning that Softserial can be configured only on one signal line for output or input (TX or RX). For instance SmartAudio uses only one wire (TX) to communicate with the FC, so you need only the one additional pad to connect the VTX SmartAudio control.
Disadvantages of the Softserial
With all those great advantages, software serial has some limitations and downsides. First of all the softserial does not work on all flight controller outputs. And it varies from one flight controller to another. You need to try the sofserial on the desired FC output in order to know if it works with your FC. Usually motor5-8 or PWM5-8 or also called S5-S8 and PPM outputs work without problems with softserial, but you need to try.
Another disadvantage is the limitation of the bandwidth. Software serial works pretty good on 9600 baud, but probably will not on 115200 baud.
Running software serial is a heavy load on MCU so you should watch the MCU load percentage indicator when you are setting softserial port.
How to setup the Softserial port?
First you need to enable the softserial feature in Betaflight configurator.
Then you need to find out the flight controllers output pin that is mapped to the specific resource. In you example we will reassign the MOTOR 5 output to the softserial pin. Type the resource
command in the Betaflight Configurator CLI.
Find the MOTOR 5 output pin name. In out case it is B03. Now you need to assign the resource to softserial.
CLI commands for assigning the softserial port:
resource serial_tx 11 <pin>
– assigns MCU pin resource as the softserial 1 TX output
resource serial_rx 11 <pin>
– assigns MCU pin resource as the softserial 1 RX output
resource serial_tx 12 <pin>
– assigns MCU pin resource as the softserial 2 TX output
resource serial_rx 12 <pin>
– assigns MCU pin resource as the softserial 2 RX output.
As you see the “11” is the identifier for SOFTSERIAL1. For SOFTSERIAL2, use “12“.
You need first to free the resource before assign it to another purpose. This is done by issuing command resource MOTOR 5 none
.
Then assign the freed B03 pin as Softserial1 TX output by issuing the command resource serial_tx 11 B03
. Dont forget to save
the settings.
After these steps you’ll see the SOFTSERIAL1 option in the Betaflight Configurator Ports tab. You can set it to SmartAudio/IRC Tramp output to control the VTX settings.
Thanks for the writeup!
Where can I get more information on the following commands? I try to understand them as don’t seem to to be able to use them verbatim in iNAV on a Matek 405 board… I want to be able to switch the bluetooth boar on and off.
set pinio_config = 129,1,1,1
set pinio_box = 0,255,255,255
resource MOTOR 5 none
resource PINIO 1 A15
ref: https://www.speedybee.com/product_images/download/manual/SB-BUA-manual-EN.pdf
More info on PINIO can be found @ Betaflight GitHUB: https://github.com/betaflight/betaflight/wiki/Pinio-and-PinioBox .
I guess you need to find the free output (e.g. Motor 5 or S5), then find the MCU pin name for that resource with
RESOURCE MOTOR 5
command (RESOURCE LIST
command list all the resources). Ten remap this MCU to the PINIO resource.