bolderflight / sbus

Arduino and CMake library for communicating with SBUS receivers and servos.
MIT License
373 stars 132 forks source link

Using this library, there was an error running on esp32 arduino #70

Open changlin1990 opened 1 year ago

changlin1990 commented 1 year ago

When running esp32 on the arduino ide and using this library, an error occurred. Below is a screenshot of the error prompt. Please help identify and fix the problem.

image image image
flybrianfly commented 1 year ago

Compiles fine for me using Arduino 1.8.19, the latest version of the library downloaded directly from GitHub, and compiling for ESP32 Dev. Please confirm that you are using the latest version of the library downloaded directly from GitHub (Arduino's library manager sometimes doesn't catch version updates). If you're still encountering issues, please provide the Arduino version number and the exact board that you are compiling for as well as the version of the ESP32 board software.

changlin1990 commented 1 year ago

I am using the latest version, please take a screenshot, the IDE is 2.1

image
changlin1990 commented 1 year ago

Do you have these error prompts when trying out version 2.0 of the Arduino IDE?

flybrianfly commented 1 year ago

No, still compiles without errors or warnings. Again, recommend downloading and installing directly from GitHub rather than the builtin Arduino library manager.

Screenshot from 2023-06-12 19-19-26

changlin1990 commented 1 year ago

好的,谢谢,我再试一试,

OK, thank you. I'll try again.

changlin1990 commented 1 year ago

I manually installed the latest library, but there was still an error. The error message is as follows. What are the possible reasons?

image
Rytiggy commented 6 months ago

I was able to get it to compile by using the ESP32 dev module for the board.

Screenshot 2024-01-03 at 11 07 21 PM
Rytiggy commented 6 months ago

I was able to get this working, I only needed to use the RX input so the code chages to:

Note that I am using the RX 2 pin on the ESP 32. which is GPIO 16.

#include "sbus.h"

/* SBUS object, reading SBUS */
// bfs::SbusRx sbus_rx(&Serial2, 26, 27, 1, 1);
bfs::SbusRx sbus_rx(&Serial2, 16, 17, true);
/* SBUS object, writing SBUS */
// bfs::SbusTx sbus_tx(&Serial2, 26, 27, 1, 1);
/* SBUS data */
bfs::SbusData data;

void setup() {
  /* Serial to display data */
  Serial.begin(115200);
  while (!Serial) {}

  delay(2000);

  /* Begin the SBUS communication */
  Serial.println("Begin SBUS...");
  sbus_rx.Begin();
  // sbus_tx.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");
    }

    /* Display lost frames and failsafe data */
    Serial.print(data.lost_frame);
    Serial.print("\t");
    Serial.println(data.failsafe);
    /* Set the SBUS TX data to the received data */
    // sbus_tx.data(data);
    /* Write the data to the servos */
    // sbus_tx.Write();
  }
}

Example

Screenshot 2024-01-04 at 6 07 20 PM

Hope this helps

lsors commented 5 months ago

I also can work on esp32 board with Arduino IDE 2.0,but can not work for esp8266

iurycarlos commented 2 months ago

are you using a 5 to 3.3v converter?

Witty-Wizard commented 6 days ago

https://github.com/Witty-Wizard/SerialIO

Try using this library