I am trying to get an OpenRB-150 board (that runs arduino code) to provide navigation commands (e.g. roll, pitch, etc.) to a flight controller (i.e. Speedybee F7 Mini) that runs BetaFlight. I am open to any way to communicate the navigation between these devices.
Currently, I have hardwired the devices so the OpenRB-150 is effectively the receiver. I am attempting to communicate via SBUS - specifically, the "Bolder Flight Systems SBUS" library. The hardwired connection is as follows:
OpenRB-150 -> Speedybee F7 Mini
Tx -> R1
Rx -> T1
V -> 5v
G -> G
I am using Serial2 on the OpenRB-150. I am providing power to each device via USB's
This is the code that I have running on the OpenRB-150:
#include "sbus.h"
/* SBUS object, reading SBUS */
bfs::SbusRx sbus_rx(&Serial2);
/* SBUS object, writing SBUS */
bfs::SbusTx sbus_tx(&Serial2);
/* SBUS data */
bfs::SbusData data;
void setup() {
Serial2.begin(115200);
while (!Serial) {}
Serial.println("Serial Monitor started.");
sbus_rx.Begin();
sbus_tx.Begin();
}
void loop () {
if (sbus_rx.Read()) {
data = sbus_rx.data();
Serial.print("Received SBUS Channels: ");
for (int8_t i = 0; i < data.NUM_CH; i++) {
Serial.print(data.ch[i]);
Serial.print("\t");
}
Serial.println();
data.ch[0] = map(data.ch[0], 1000, 2000, 172, 1811); // Aileron
data.ch[1] = map(data.ch[1], 1000, 2000, 172, 1811); // Elevator
data.ch[2] = map(data.ch[2], 1000, 2000, 172, 1811); // Throttle
data.ch[3] = map(data.ch[3], 1000, 2000, 172, 1811); // Rudder
Serial.print("Modified SBUS Channels: ");
for (int8_t i = 0; i < data.NUM_CH; i++) {
Serial.print(data.ch[i]);
Serial.print("\t");
}
Serial.println();
sbus_tx.data(data);
sbus_tx.Write();
} else {
Serial.println("Error reading SBUS data.");
}
}
The code compiles and runs fine. However, I only see the "Serial Monitor started." output in the serial monitor and the code appears to break at sbus_rx.Begin();
Any help would be greatly appreciated!