Mxtvs
Mxtvs

Reputation: 23

UART data reception from happymodel ep1 ELRS

The topic of my work is to build a drone controlled by RPI 5 RC, using ELRS - Crossfire. I have a problem reading data on gpio pins 14, 15, tx/rx. I am using a Radiomaster pocket apparatus, it is bundled with a HappyModel ep1 receiver, then connected to the RPI via UART. Unfortunately whether using python or minicom to read data with baudrate = 115200 or 420000 no data comes in. I have the interfaces in the rpi running, additional uarts also tested - 2,3,4 too, bluetooth disabled. I tested the receiver on an arduino uno with the following result, I got some junk data, I think related to telemetry, but I know it is receiving something though, I then connected the arduino to the RPI and again silence. I believe the fault lies with the rpi uart port, however I would like to get anything to confirm that the port is working after all, do you have any ideas ?

and result: Dekodowanie danych CRSF: Kanał 1: 1792 // kanał means channel etc. Kanał 2: 767 Kanał 3: 1650 Kanał 4: 939 Kanał 5: 1792 Kanał 6: 698 Kanał 7: 991 Kanał 8: 59 Kanał 9: 687 Kanał 10: 1193 Kanał 11: 955 Kanał 12: 406 Kanał 13: 766 Kanał 14: 2042 Kanał 15: 939 Kanał 16: 1792 Dekodowanie zakończone. Przepełnienie bufora! Przepełnienie bufora! Przepełnienie bufora! Przepełnienie bufora! Przepełnienie bufora! Dekodowanie danych CRSF: Kanał 1: 757 Kanał 2: 1775 Kanał 3: 862 Kanał 4: 1376 Kanał 5: 1978 Kanał 6: 1774 Kanał 7: 59 Kanał 8: 763 Kanał 9: 1775 Kanał 10: 1630 Kanał 11: 1536 Kanał 12: 767 Kanał 13: 1801 Kanał 14: 859 Kanał 15: 406 Kanał 16: 767 Dekodowanie zakończone.


#define RX_PIN 2
#define TX_PIN 3

SoftwareSerial ReceiverSerial(RX_PIN, TX_PIN);

#define BUFFER_SIZE 64
uint8_t buffer[BUFFER_SIZE];
uint8_t bufferIndex = 0;

// Funkcja do wyświetlania danych kanałów
void parseCRSF(uint8_t *data, uint8_t length) {
  if (length < 22) {
    Serial.println("Pakiet za krótki");
    return;
  }

  Serial.println("Dekodowanie danych CRSF:");

  // Kanały są przesyłane od 3. bajtu (0-indexed)
  uint16_t channels[16];
  for (int i = 0; i < 16; i++) {
    channels[i] = ((data[3 + i * 2] | (data[4 + i * 2] << 8)) & 0x07FF);
    Serial.print("Kanał ");
    Serial.print(i + 1);
    Serial.print(": ");
    Serial.println(channels[i]);
  }

  Serial.println("Dekodowanie zakończone.");
}

// Funkcja do odczytu i dekodowania danych UART
void readCRSF() {
  while (ReceiverSerial.available() > 0) {
    uint8_t byteRead = ReceiverSerial.read();

   
    if (bufferIndex < BUFFER_SIZE) {
      buffer[bufferIndex++] = byteRead;

      if (bufferIndex >= 3 && bufferIndex == buffer[1] + 2) {
        // Sprawdzamy CRC (na razie pomijamy szczegóły)
        parseCRSF(buffer, bufferIndex);
        bufferIndex = 0; // Reset bufora
      }
    } else {
      Serial.println("Przepełnienie bufora!");
      bufferIndex = 0;
    }
  }
}

void setup() {
  Serial.begin(115200); // UART to PC
  ReceiverSerial.begin(115200); // UART do receiver (SoftwareSerial)
  Serial.println("Dekoder CRSF ready.");
}

void loop() {
  readCRSF(); 
}```

Upvotes: 0

Views: 30

Answers (0)

Related Questions