bolderflight / sbus

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

Using hardware inverter with ESP8266 UART RX/TX pins #57

Closed fiechr closed 2 years ago

fiechr commented 2 years ago

I'm basically running the example code (without the TX part) with a hardware serial inverter (built from a NPN transistor and a couple resistors), but while it works with a Raspberry Pico (with two different Arduino cores), it doesn't work with an ESP8266 NodeMCU dev board.

I'm not using the USB/Serial input/output, besides programming the device, of course, and have the output of the serial inverter connected to the RX pin of the ESP8266. I know that there is something coming in, since esptool.py can't connect, until I unplug the RX pin.

It seems, that sbus_rx.Read() is never true and therefore the code inside the if statement (toggling some LEDs based on the channel data) never runs.

I've also tried without USB cable at all, just powered by an external power supply on VIN. Everything seems to work (receiver and radio connect, buttons show PWM output on the radio), but the data isn't received or read correctly.

As I initially mentioned, if I connect the same hardware to a Pico, only changing the Pin numbers, the same sketch works (can toggle LEDs on/off by pressing the assigned buttons on the radio). Of course the latter has a separated USB/serial connection. But shouldn't it still work with a ESP8266, if the UART1 isn't used by anything else? Does maybe the serial bridge IC somehow interfere?

fiechr commented 2 years ago

I found out, that I need to set bfs::SbusRx sbus_rx(&Serial); I've tried Serial0, which doesn't exist, so I thought, Serial1 had to be the first (and only) UART. Later I realized, that there is also a Serial without any number. Now it works!