Easy to use FrSky-library for Arduino

20111221073704890.jpgFor my Control Station project, I also started writing a bunch of decoding function for the FrSky telemetry protocol.

I have now moved those functions into their own library for Arduino. My focus while writing and expanding this library is on ease of use. There is already Arduino code available but I found that a bit complicated to integrate. With the new library, all the user needs to do, is read one char from the serial port and send it to the library via the ::update method. All the decoding is done internally. The ::update method returns 1 when a complete packet was received, otherwise it returns 0. There is (will be) a dedicated method to access every parameter. I'll also try to keep up the detailled documentation.

At the moment, the library decodes only the basic information, RX A1 & A2 ports, uplink and downlink RSSI. Additional sensors will be included as I receive the hardware (which hopefully is soon).

Find the library at GitHub.

Example use (on MEGA 2560):

#include <frsky.h>
FrSky frsky;
void setup() {
Serial.begin(9600);
Serial2.begin(9600);
}
void loop() {
if (Serial2.available()) {
char c = Serial2.read();
if (frsky.update(c)) {
Serial.print("TX RSSI: ");
Serial.println(frsky.getLink_up());
Serial.print("Telemetry RSSI: ");
Serial.println(frsky.getLink_dn());
Serial.print("RX Voltage: ");
Serial.println(frsky.getRX_a1()*0.0517647058824);
Serial.print("A2 Voltage: ");
Serial.println(frsky.getRX_a2()*0.0129411764706);
}
}
}
E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • Hi Stefan,

    I connected an arduino mega 2560 I have a FRSKY DFT module in my transmitter and a FRSKY D8R v2 receiver. I am trying to connect the DFT to the mega 2560. in between i have a max3232 TTL from sparkfun:

    https://www.sparkfun.com/products/11189

    The program compiles perfectly and uploads. When I put the serial monitor on i get a nice page displaying the tekst wit all 0.00 values. What am I doing wrong?

    Regards,

    Jarco den Dekker

    SparkFun Transceiver Breakout - MAX3232
    The 'must have' IC for TTL/CMOS projects finally has its own breakout board! This RS232 IC is capable of running at 3V and communicating with 5V logi…
  • Well, the post says "Example use (on MEGA2560)", doesn't it? :)

    The Uno has only one serial port. If you want to read the data from the TX and write via serial, you either have to use a bigger Arduino with more than one serial port or use SoftSerial.

  • Do you have a Serial2? MEGA2560?

  • Developer
    @craig: my understanding was to disable the FrSky telemetry you do it on the Tx Module by setting the switches to no telemetry (V8 mode). The Reciever then doesn't send out telemetry information. I'll try and confirm this on my setup later today.
  • Yeah it is. But you were asking what the resistors and caps on the board are for :).

  • I was just going to order the chips, I hadn't even looked that far into it yet.  This little board is definitely much easier then.

  • The MAX232 shifter needs a few external parts to work.

    See http://datasheets.maximintegrated.com/en/ds/MAX220-MAX249.pdf

  • Cool, thanks. Or even better, buy them in bulk!  :D

    http://www.amazon.ca/Mini-RS232-Converter-Module-Board/dp/B008DBDCY...

    I wonder what the little resistors or caps are for?

    Just ordered a 5-pack.

  • Ok, I put upgrading the docs on my list :D.

    As for the level shifting... That's not really a hurdle... I used those thingies. Easy to put into a 4wire cable, a bit of shrink and ready you go...

  • Well, I don't think it's real clear to readers.  I can imagine people thinking "Oh, A1 has an Vdiv already, I'll just plug this 12V into it... why is it smoking?"

    Cool that you'll bring the other messages.  The bit stuffing will get interesting.

    Your library looks pretty easy to use so far, so I should be able to implement it easily.  The only hurdle is the level shifting.  I've been thinking about hacking around the level shifter, but maybe I won't bother.

This reply was deleted.