Changing flight modes using arduino input

Dears,
I would like to ask for your kind support in establishing a connection between an Arduino Nano board and a Mateksys WLITE flight controllers RX1/TX1 pin (SERIAL2 in ardurover). My goal is to change the flight mode on the flight controller to return to launch when a sensor connected to the Arduino trips. This is needed so the rover can return to launch when it is autonomous and outside of RC range.
-My “change flight mode” toggle is on channel 8.
-My RX on the arduino is connected to TX on the flight controller, and the TX on arduino is connected to RX on the flight controller.
-SERIAL_2 protocol is set to 23 (RCIN) under ArduRover.
-My RC transmission is going through RX6 and is working fine using a FrSky transmitter and receiver.

So far I have tried IBusBM arduino library (changed the baud rate to the required 115200), sending PWM signal using the servo library, sending PPM signals on channel 8 using the PPM_Encoder library, and all of the above with different rx/tx conenctions in case it’s reversed.
I have yet to be able to change the flight mode.
I would like to ask for your kind support in achieving this goal.
Thank you very much in advance!
Regards,
Papi

Hello Gabor, welcome to the community.

Probably it is easier to connect the serial port and talk mavlink to the flight controller.

Dear amilcarlucas,
Thank you very much for the response. I found the same answer, however mavlink for arduino is such a large library, it does not fit onto the Nano board. This is the main reason I am looking for a different solution. I will try and find a lightweight library or just copy the entirety of the packet sending code, maybe that will fit :slight_smile:
Regards,
Gabor

use the button input, then you can just set one of the pins on the flight controller assigned to RTL mode, then you just need to use arduino to pull the pin high to activate it.

https://ardupilot.org/rover/docs/common-buttons.html

1 Like

Dear geofrancis,
Thank you so much, that sounds very achievable! I’ll try it today and check back with the results.
Regards,
Gabor

Dears,
I tried to use button config but the flightmode does not seem to be changing.
I have the following params set:
BTN_ENABLE=1
BTN_FUNC1=4 (RTL)
BTN_OPTIONS1=0 (Not inverted or anything)
BTN_PIN1=56 (my arduino output pin is attached to the signal pin of servo 7 which is GPIO56)
SERVO7_FUNCTION=-1 (GPIO)

On the arduino board I am setting pinmode 10 to output and then digitalwrite HIGH on pin 10. Pin10 on the arduino is attached to servo 7 signal on flight controller. No other code is running. I also tried with A7 pin and analogWrite HIGH. I also tried directly supplying 5V instead of pin logic.

When I press the RTL button manually in Mission Planner, I get “Flight mode change failed” error (because there is no waypoint mission and no RTL point, and no GPS). So I am expecting the same error when the Arduino powers up and triggering the “button”, but the error is not shown.

I tried changing the button function to Auto instead of RTL, as the FC can be changed to Auto mode from Mission Planner successfully, but the Arduino still cannot change flight mode.

It might be the issue that I am powering on the flight controller from the USB port as a bench setup, and thus the servo pins are disabled?
Are there some specific requiremtns so I can test this without putting it on an actual vehicle? (must be powered from battery, it has to be armed, etc.)
Thank you so much in advance!
Regards,
Gabor

test it without the arduino by just pulling the pin high or low to see if its working first. have you got both a ground and signal wire connected between the Arduino and the flight controller?

1 Like

Dear GeoMuir,
thank you for highlighting my obvious mistake!
I connected the arduino ground to the servo 7 ground, and I was able to trigger the mode change using the “button”. I have set the button options to be “reversed” as Arduino starts with all pins high, and pulling the pin low now changes the flight mode as expected.
Appreciate your support, and wish you a great week ahead!
Regards,
Gabor

1 Like