Arduino control wire for the rc in port

Hi
I’m doing a project where I’m trying to control the ePX4 mini from a Arduino using a wire into the RC in port on my px4 mini. I am using ArduPilot i know that the protocol is using sBus. what I’m struggling to find is the name and variables I need to change to change the pith yaw roll and throttle. i cant find a roadmap or protocol on the internet about this got as far as Opentx and AETR and I know that the msg should be in some sort of form [Ch1 , value between xx and yy] but I don’t know the exact protocol/variables this has to be for the ArduPilot to understand it.

Hello,

ive just done the opposite, getting the values out of a pixhawk and into an micro.

This was a helpful reference. The code no longer works, but it explains the protocol to a degree.

should this be found ain a few years and the links dead, heres the summery:

The SBUS protocol uses an inverted serial logic with a baud rate of 100000, 8 data bits, even parity, and 2 stop bits. The SBUS packet is 25 bytes long consisting of:

  • Byte[0]: SBUS header, 0x0F
  • Byte[1 -22]: 16 servo channels, 11 bits each
  • Byte[23]
    • Bit 7: channel 17 (0x80)
    • Bit 6: channel 18 (0x40)
    • Bit 5: frame lost (0x20)
    • Bit 4: failsafe activated (0x10)
  • Byte[24]: SBUS footer

Note that lost frame is indicated when a frame is lost between the transmitter and receiver. Failsafe activation typically requires that several frames are lost in a row and indicates that the receiver has moved into failsafe mode. Packets are sent approximately every 10 ms or 20 ms.

Hi bro

This is what I’ve been looking for. I want to drive a stepper with a pixhawk through arduino. Can you please help me out bro with you procedure

hello,
here’s what ive been using to read the sbus.i’ve moved on to pulling the data via mavlink. but this code is working as of the latest version(rover 4.2.3)

void readSBUS(){//read the output from pixhawk
static byte rxPacket[25];
static byte pointer=0;
  while (Serial4.available()) {  
    byte input=Serial4.read();
    
    //start of packet
    if (input==0x0f && pointer>24) pointer=0;

    //store byte
    if (pointer<24)rxPacket[pointer]=input;
    pointer++;
    
    //end of packet
    if (pointer==24)
    {
      //byte header=rxPacket[0];
    
      SBUSchannel[0]  = (uint16_t) ((rxPacket[1]        | rxPacket[2]  << 8)                         & 0x07FF);
      SBUSchannel[1]  = (uint16_t) ((rxPacket[2]  >> 3  | rxPacket[3]  << 5)                         & 0x07FF);
      SBUSchannel[2]  = (uint16_t) ((rxPacket[3]  >> 6  | rxPacket[4]  << 2    | rxPacket[5] << 10)  & 0x07FF);
      SBUSchannel[3]  = (uint16_t) ((rxPacket[5]  >> 1  | rxPacket[6]  << 7)                         & 0x07FF);
      SBUSchannel[4]  = (uint16_t) ((rxPacket[6]  >> 4  | rxPacket[7]  << 4)                         & 0x07FF);
      SBUSchannel[5]  = (uint16_t) ((rxPacket[7]  >> 7  | rxPacket[8]  << 1    | rxPacket[9] << 9)   & 0x07FF);
      SBUSchannel[6]  = (uint16_t) ((rxPacket[9]  >> 2  | rxPacket[10] << 6)                         & 0x07FF);
      SBUSchannel[7]  = (uint16_t) ((rxPacket[10] >> 5  | rxPacket[11] << 3)                         & 0x07FF);
      SBUSchannel[8]  = (uint16_t) ((rxPacket[12]       | rxPacket[13] << 8)                         & 0x07FF);
      SBUSchannel[9]  = (uint16_t) ((rxPacket[13] >> 3  | rxPacket[14] << 5)                         & 0x07FF);
      SBUSchannel[10] = (uint16_t) ((rxPacket[14] >> 6  | rxPacket[15] << 2    | rxPacket[16] << 10) & 0x07FF);
      SBUSchannel[11] = (uint16_t) ((rxPacket[16] >> 1  | rxPacket[17] << 7)                         & 0x07FF);
      SBUSchannel[12] = (uint16_t) ((rxPacket[17] >> 4  | rxPacket[18] << 4)                         & 0x07FF);
      SBUSchannel[13] = (uint16_t) ((rxPacket[18] >> 7  | rxPacket[19] << 1    | rxPacket[20] << 9)  & 0x07FF);
      SBUSchannel[14] = (uint16_t) ((rxPacket[20] >> 2  | rxPacket[21] << 6)                         & 0x07FF);
      SBUSchannel[15] = (uint16_t) ((rxPacket[21] >> 5  | rxPacket[22] << 3)                         & 0x07FF);
      SBUSchannel[16] = rxPacket[23] & 0x80;
      SBUSchannel[17] = rxPacket[23] & 0x40;
      //bool FrameLost = rxPacket[23] & 0x20;
      //bool failsafe = rxPacket[23] & 0x10;
      //byte footer=rxPacket[24];

    }
  }

you’ll need uint16_t SBUSchannel[18]; as a global.
and Serial4.begin(100000,SERIAL_8E2_RXINV_TXINV); in setup.
you will need a board that supports inverted serial logic, I was using a teensy 4.1.

then just call the function often enough enough to keep your buffer from overflowing.
hope that helps :slight_smile:

Hi bro

As I’ve just said bro I’m new to this thing. I tried to verify this code on my arduino uno but its giving me error. If you have an idea of how to fix this please help me bro.
the error says that ‘Serial4’ was not declared in this scope.

oohh I think I now see the problem that I need to find the microcontroller like the one you used

how did you connect it to the pixhawk and what where you driving?
you also had a code for that or you used only this code?