ESP8266: IBus with Serial.swap()?

Hello, I’m currently attempting to build a flight controller using an ESP8266 NodeMCU board. Everything is working except for connecting my receiver (an FS-i6b) to said board.

I’m using the ibus protocol, however since the ESP8266 only has the one full UART, I can’t have the receiver hooked up to the RX as normal or else it interferes with flashing and serial debugging (I currently have pin D4 bridged to TX for Serial1 output).

Serial.swap() seems like it would solve my issue however I still cannot read any signal.

My wiring is currently:
Receiver Data pin -> D7
D4 -> TX

A snippet of my code:

IBusBM ibus;

void setup() {
    ibus.begin(Serial);
    Serial1.begin(9600);
    delay(1000);
    Serial.swap();
    delay(1000);
    Serial1.println(“Swapped!”)
}

void loop() {
    Serial1.println(String(ibus.readChannel(0)));
    delay(1000);
}

Currently the output I receive is:

Swapped!
0
0
0
0

Is there something I’m missing that’s causing my problems? Or is there a much easier way to pull off using iBus RX on the ESP8266? Any help would be super appreciated!

It seems to work but you understand the risks of connecting 2 GPIO pins that are potentially in output mode ?

It should do, are you sure there is something being sent on channel 0 ? what value are you expecting ?

Hey hold on. you said TX1 to TX and now you're saying it's TX1 to RX ?

D4 is connected to TX, sorry typo. As for the risks of bridging, I’m only using it for debugging, and if Serial.swap() does what it’s supposed to, TX should never be outputting directly. Channel 0 should be transmitting at minimum a 1000ms signal. It works when I hook it up to my arduino so I’m fairly confident it’s transmitting correctly.

It does do what it is supposed to, but there is also this. Just in case, you should bridge it through a 1K resistor.

So the sketch does work on an AVR ?

It works when I use a device with two full uart serials.

I also experimented with removing the library I was using and rolling my own rudimentary ibus protocol reader, which actually worked. So it seems there’s something in the library I was using wasn’t playing nice…

well looking at the src (the .cpp & .h) it seems that esp8266 is not really supported, doesn't this show up when you compile ?

#warning "Timing only supportted for AVR, ESP32 and STM32 architectures. Use timerid IBUSBM_NOTIMER"

and timers on an esp8266 are a bit troublesome to say the least. The timers that exist are in use by wifi connection as far as i know.
so (from IBusBM.cpp)

  // we need to process the iBUS sensor protocol handler frequently enough (at least once each ms) to ensure the response data
  // from the sensor is sent on time to the receiver
  // if timerid==IBUSBM_NOTIMER the user is responsible for calling the loop function

which means that you should call begin like this

ibus.begin(Serial, IBUSBM_NOTIMER);

and call

ibus.loop();

within loop regularly, which means you should probably get rid of the delay() and change serial1.println() into a millis() elapsed time method.

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