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

  • Agree about the FrSky telemetry interfering with GPS, it certainly does here. A little space helps adequately, wrapping the case in copper foil helps some too. I don't know how to disable it...the documentation I have is extremely unreliable, different releases for the "same" items have conflicting info (in general). Par for the course.

  • I haven't been messing around with that subject jet, but Thumbs up for your effort and disclosing the code to the public!

    Cheers Kraut Rob

  • Developer

    Good work. I was trying to add review comments to your code, but for some reason I cannot on github. I sent you a PM.

  • Duh, had my FrSky for a few months, and didn't even notice it.  But, I'm old and need reading glasses, so these things don't pop out at me anymore.  Thanks Stefan! This is very useful.

  • Ellison: Not the receiver. The transmitter module receives telemetry from the receiver. So if you want to decode telemetry, you connect your Arduino to the serial port of the transmitter module. The serial port is the 4-pin connector and the pinout is printed on the label.

    IMG_20130223_234004.jpg

    Robert: True on the creative soldering, but I usually prefer not to solder inside RF-components :). A level shifter is very cheap on eBay (e.g. http://www.ebay.com/itm/261070156589) and easy to use. Besides my personal preference, it's also illegal in some countries to modify commercial (and approved/certified) RF-devices if you do not hold either a radio-amateur license or are a certified repair-technician.

  • Stefan, I have read a post which showed that the FrSky Rx, and probably the Tx, use a 232 chip to do the level shift internally.  So it's actually possible to make the comms link without buying another Max232.  Some creative soldering you can bypass the internal 232 and go direct.

    I also haven't seen much problem using FrSky telemetry with GPS.  It's a valid warning, but I haven't seen a problem yet.  Well, I had a problem with APM2.0 All-in-One with the short little wire *directly* over the GPS chip.  But other than that, no.

  • Which port on the receiver is the serial link?  Do you have a diagram?

  • Really? With what GPS-module? I have a test setup for development of my ground station project on my desk. Inside, 1.5m from the window and the cockroach-whiskers of the receiver are about 4-5cms from the GPS module (UBlox 5)... I get 3D-fixes with 6-8 satellites.

    However, the Hobby King wing camera totally kills the GPS reception when it's within 5-10cm of the antenna, even outside under the sky...

    IMG_20130223_231437.jpg

  • Developer

    Unfortunately the FrSky telemetry can interfere badly with GPS reception. I use FrSky R/C, but I always disable the FrSky telemetry as I had some bad experiences with losing GPS lock many times per flight when it was enabled.

    If you do enable it then make sure your receiver is as far from your GPS as possible.

    Cheers, Tridge

  • You mean the connection between the TX module and the Arduino? That's a serial link at RS232-levels. So you will need a level-shifter.

This reply was deleted.