Help with SBUS on Arduino Mega 2560

I'm using the Bolder Flight Systems library with my RadioLink R12DS receiver. I've never done this before, so not sure what I'm doing wrong. The receiver is connected from the SBUS-11 pin to pin 17 (RX2) on my Arduino. I was assuming this was Serial2 from the labels on the board. I can't get the "read()" method to return true. I'm using the code that came with the example. It never gets into the code under the if... read(). Any thoughts?

#include "sbus.h"

/* SBUS object, reading SBUS */
bfs::SbusRx sbus_rx(&Serial2);
/* SBUS data */
bfs::SbusData data;

void setup() {
  /* Serial to display data */
  Serial.begin(115200);
  while (!Serial) {}
  /* Begin the SBUS communication */
  sbus_rx.Begin();
}

void loop () {
  if (sbus_rx.Read()) {
    /* Grab the received data */
    data = sbus_rx.data();
    /* Display the received data */
    for (int8_t i = 0; i < data.NUM_CH; i++) {
      Serial.print(data.ch[i]);
      Serial.print("\t");
    }
  }
}

IF you have a serial-USB adapter, use it to validate on the PC your device is working. You can use a 3rd party terminal Prahran or just use the ArduinoIDE serial monitor to observe the characters.

I don't have one, unfortunately. I'm new to this. I also tried the library here: https://github.com/fdivitto/sbus but it's only returning 880 as a value every time. No matter where the controller's joysticks are or the switch positions.

1 Like

Then I suggest reprogramming your Mega to just show what is being sent... minimal sketch.

You will find overview and sample code here:
Arduino Mega 2560 R3 - Serial Port Basics - Arduino Project Hub

i am having the same issue. were you able to solve it later?

EDIT: Okay it works now. Turns out you can not use all the pins as this library uses Timer2 interrupt. Read the library readme.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.