SMALL - espritmodel.com SMALL - Telemetry SMALL - Radio
Reply
Thread Tools
Old Sep 14, 2014, 01:13 PM
Registered User
pawelsky's Avatar
Polska
Joined Jan 2012
1,680 Posts
Discussion
FrSky S-Port telemetry library - easy to use and configurable

Hi,

for those having Tarains radios or other system capable of receiving FrSky S-Port telemetry data I've created a library, that allows to emulate the FrSky S-Port sensors using Arduino compatible Teensy 3.x board or 328P based boards (e.g. ProMini, Nano, Uno).

The library was mainly created to work together with the NazaDecoder or NazaCanDecoder libraries that read telemetry data coming out of DJI Naza Lite/v1/v2 controllers (examples can be found in post #36), but it can be used for other purposes as well.

The main goals that I had when creating this library was to have it:
1) easy to use
2) easy to configure
3) easy to add new sensors

The library consists of 3 main classes:
  1. FrSkySportTelemetry - which is the main class responsible for collecting the data and sending it via one of the Teensy serial ports or SoftwareSerial ports on 328P based borads.
  2. FrSkySportSingleWireSerial - which is responsible for S-Port-like single wire serial transmission
  3. FrSkySportSensor - which is a base class for all the sensors. So far following sensors have been implemented:
    • FrSkySportSensorFcs - which emulates FCS-40A/FCS-150A current sensors
    • FrSkySportSensotFlvss - which emulates FLVSS LiPo voltage monitor sensor
    • FrskySportSensorGps - which emulates the GPS v2 sensor
    • FrskySportSensorRpm - which emulates the RPM/temperature sensor
    • FrskySportSensorVario - which emulates the high precision variometer sensor

The library is very easy to use, you can define which sensors to include, you can change their default IDs (e.g. to avoid conflicts or to use 2 FLVSS sensors to 12S batteries). The library makes sure that the sensors respond to correct ID being polled (not just any ID or a fixed list of IDs as in some of the existing libraries) so you can even mix the virtual sensors with the real ones without conflicts. You can also define which of the Teensy serial ports to use. In fact you can send different data on different ports bu creating multiple telemetry objects.

Here is a quick example on how the library is used

Code:
#include "FrSkySportSensor.h"
#include "FrSkySportSensorFlvss.h"
#include "FrSkySportSensorFcs.h"
#include "FrSkySportSingleWireSerial.h"
#include "FrSkySportTelemetry.h"

FrSkySportSensorFlvss flvss1;
FrSkySportSensorFlvss flvss2(FrSkySportSensor::ID15);
FrSkySportSensorFcs fcs;
FrSkySportTelemetry telemetry;

void setup()
{
  telemetry.begin(FrSkySportSingleWireSerial::SERIAL_3, &flvss1, &flvss2, &fcs);
}

void loop()
{

  /* DO YOUR STUFF HERE */

  flvss1.setData(4.10, 4.11, 4.12, 4.13, 4.14, 4.15);
  flvss2.setData(3.10, 3.11, 3.12, 3.13, 3.14, 3.15);
  fcs.setData(25.3, 12.6);
  telemetry.send();
}
As you can see it is super simple, all you need to do is to:
1) create the sensors you want to use and the telemetry object
2) call the begin method of the telemetry object defining the port and pointers to used sensors (up to 10)
3) update the sensor data when necessary
4) call the send method of the telemetry object periodically

Attached you'll find the library itself and a picture showing the above code in action. As you can see the data displayed for FCS and FLVSS sensor matches the data set in code.

For simplicity I did not add configurable data send frequency which every sensor has defined, but maybe I'll include that in future revisions for completeness.

Have a look at the FrSkySportTelemetryExample included in the library to have a better understanding on what parameters can set for each of the sensors.

You can also find attached a connection diagrams. Pick one of the TX connections (one that is not used for other purposes) and tell the library to use it in telemetry.begin function. Depending on the board used you should chose:
  • SERIAL_1, SERIAL_2 or SERIAL_3 for Teensy 3.x boards (note that the additional SERIAL_USB shall only be used for debug purposes if you know what you are doing)
  • SOFT_SERIAL_PIN_2 to SOFT_SERIAL_PIN_12 for 328P based boards (e.g. Pro Mini, Nano, Uno)
Note that for 328P based boards you need to include the SoftwareSerial library in your main sketch:
Code:
#include "SoftwareSerial.h"
Also note that to avoid interrupt conflict with the mentioned SoftwareSerial library you need to disable attitude (roll/pitch) sensing in the NazaDecoder library by uncommenting the following line in NazaDecoder.h file:
Code:
//#define ATTITUDE_SENSING_DISABLED
Make sure you understand Teensy 3.x/328P based board powering options before choosing how to power your board!

When creating my library I used some of the information that I found on this webpage:
https://code.google.com/p/telemetry-...ySPortProtocol


FrSkySportTelemetry library changelog
--------------------------------------
Version 20141120
[NEW] added support for 328P based boards (e.g. Pro Mini, Nano, Uno)
[NEW] added connection diagrams

Version 20140914
initial version of the library
pawelsky is online now Find More Posts by pawelsky
Last edited by pawelsky; Nov 21, 2014 at 09:10 AM.
Reply With Quote
Sign up now
to remove ads between posts
Old Sep 14, 2014, 01:35 PM
Registered User
United States, CA, Los Angeles
Joined May 2005
1,058 Posts
Subscribed! Awesome!
balbs is offline Find More Posts by balbs
Reply With Quote
Old Sep 15, 2014, 01:46 AM
Flying Wood For Fun
irun4fundotca's Avatar
Canada, ON, Harrowsmith
Joined Jan 2012
7,251 Posts
Great Stuff Man Thanks
hope to tinker soon just ordered the dual temp and rpm sensor
irun4fundotca is online now Find More Posts by irun4fundotca
RCG Plus Member
Reply With Quote
Old Sep 15, 2014, 04:20 AM
Registered User
pawelsky's Avatar
Polska
Joined Jan 2012
1,680 Posts
Quote:
Originally Posted by irun4fundotca View Post
Great Stuff Man Thanks
hope to tinker soon just ordered the dual temp and rpm sensor
Thanks!

Let me know once you have it. I may have some questions about this particular sensor.
pawelsky is online now Find More Posts by pawelsky
Reply With Quote
Old Sep 15, 2014, 08:04 AM
Flying Wood For Fun
irun4fundotca's Avatar
Canada, ON, Harrowsmith
Joined Jan 2012
7,251 Posts
Quote:
Originally Posted by pawelsky View Post
Thanks!

Let me know once you have it. I may have some questions about this particular sensor.
no probs, I already have the gps v2, lipo cell checker, 40a current sensor that's one I didn't have yet so I figured what the heck, I would never use a vario though at least I don't think so

ill tell you, it would be a large craft to have them all connected at once, to bad they weren't all one module
irun4fundotca is online now Find More Posts by irun4fundotca
RCG Plus Member
Reply With Quote
Old Sep 15, 2014, 08:09 AM
Registered User
pawelsky's Avatar
Polska
Joined Jan 2012
1,680 Posts
Quote:
Originally Posted by irun4fundotca View Post
no probs, I already have the gps v2, lipo cell checker, 40a current sensor that's one I didn't have yet so I figured what the heck, I would never use a vario though at least I don't think so

ill tell you, it would be a large craft to have them all connected at once, to bad they weren't all one module
Nice, they are all S-Port sensor, right?
pawelsky is online now Find More Posts by pawelsky
Reply With Quote
Old Sep 15, 2014, 09:39 AM
Flying Wood For Fun
irun4fundotca's Avatar
Canada, ON, Harrowsmith
Joined Jan 2012
7,251 Posts
Quote:
Originally Posted by pawelsky View Post
Nice, they are all S-Port sensor, right?
yeah correct, I still want an airspeed sensor
was thinking on using an apm type airspeed sensor but its analog so I didn't go for it

they will all fit nicely on my 90" piper cub
irun4fundotca is online now Find More Posts by irun4fundotca
RCG Plus Member
Reply With Quote
Old Sep 16, 2014, 06:07 PM
Registered User
pawelsky's Avatar
Polska
Joined Jan 2012
1,680 Posts
Got some logs from real sensors from irun4fundotca (thanks for that) and this confirms my understanding of the data rates and the defaults as written on the attached picture from FrSky.

Interesting thing is that COG is by default disabled and not reported by the GPS sensor.

Next version of the library will have the data rates implemented and configurable. I'll also add option for enabling/disabling particular messages.
pawelsky is online now Find More Posts by pawelsky
Reply With Quote
Old Sep 22, 2014, 08:49 AM
Registered User
pawelsky's Avatar
Polska
Joined Jan 2012
1,680 Posts
Joined the FrSky Developing Union to get access to the S.Port protocol specification. Looks like the implementation is pretty close to what is expected so other than enabling the data rates and enabling/disabling of particular messages only minor corrections will be necessary.
pawelsky is online now Find More Posts by pawelsky
Reply With Quote
Old Sep 25, 2014, 05:33 AM
Registered User
United Kingdom, England, Leeds
Joined Jul 2014
11 Posts
Fantastic work again, Pawelsky!

What would happen if you sent data to the telemetry hub with a PHY_ID that isn't listed in the table? Would the data still be sent over the telemetry link, and how would it appear on the receiver? Can a sensor name label be programmed in, or does the telemetry receiver simply map the PHY_IDs to sensor names?

The reason I ask is that I have some custom sensors that I intend to read and log via a serial port on my Teensy. I'd like to be able to send the values from those sensors over the telemetry link to my receiver. If using a PHY_ID > 7 won't work, I guess I could just send the information with one of the existing PHY_IDs and live with the fact that the label is wrong!
monty_mcmont is offline Find More Posts by monty_mcmont
Reply With Quote
Old Sep 25, 2014, 05:49 AM
Registered User
pawelsky's Avatar
Polska
Joined Jan 2012
1,680 Posts
Quote:
Originally Posted by monty_mcmont View Post
Fantastic work again, Pawelsky!

What would happen if you sent data to the telemetry hub with a PHY_ID that isn't listed in the table? Would the data still be sent over the telemetry link, and how would it appear on the receiver? Can a sensor name label be programmed in, or does the telemetry receiver simply map the PHY_IDs to sensor names?

The reason I ask is that I have some custom sensors that I intend to read and log via a serial port on my Teensy. I'd like to be able to send the values from those sensors over the telemetry link to my receiver. If using a PHY_ID > 7 won't work, I guess I could just send the information with one of the existing PHY_IDs and live with the fact that the label is wrong!
First of all S.Port bus implements a pull model rather than push (receiver requests particular physical id to respond, and only then the data shall be sent).

There are 28 physical IDs available (FrSkySportSensor::IDxx), so you can use one of these that is not mentioned in the table and is shall be polled by the Taranis no problem (same way as the second FLVSS sensor that has ID15 assigned in the example code). Note that PHY_ID 0 maps to ID1, PHY_ID 1 maps to ID2 etc.

Sensor names cannot be programmed. The type of data that is being sent is determined by the so called APP_ID which is predefined by FrSky. Only these predefined APP_IDs will be understood and displayed by the receiver.
pawelsky is online now Find More Posts by pawelsky
Reply With Quote
Old Sep 25, 2014, 07:42 AM
Registered User
United Kingdom, England, Leeds
Joined Jul 2014
11 Posts
Quote:
Originally Posted by pawelsky View Post
First of all S.Port bus implements a pull model rather than push (receiver requests particular physical id to respond, and only then the data shall be sent).

There are 28 physical IDs available (FrSkySportSensor::IDxx), so you can use one of these that is not mentioned in the table and is shall be polled by the Taranis no problem (same way as the second FLVSS sensor that has ID15 assigned in the example code). Note that PHY_ID 0 maps to ID1, PHY_ID 1 maps to ID2 etc.

Sensor names cannot be programmed. The type of data that is being sent is determined by the so called APP_ID which is predefined by FrSky. Only these predefined APP_IDs will be understood and displayed by the receiver.
Great, thanks for this very useful information Pawelsky. I should be able to send the data to my receiver from my custom sensors via the Teensy and the FrSky telemetry link :-D
monty_mcmont is offline Find More Posts by monty_mcmont
Reply With Quote
Old Sep 25, 2014, 11:54 AM
Registered User
United Kingdom, England, Leeds
Joined Jul 2014
11 Posts
Me again! I was just wondering what the physical connections are. Do you simply connect ground and signal (e.g. serial port Tx) from the Teensy to the Smart Port on the receiver?

Also, does the receiver automatically include RSSI data in with the other telemetry data when it transmits it back to the ground station?
monty_mcmont is offline Find More Posts by monty_mcmont
Reply With Quote
Old Sep 25, 2014, 12:27 PM
Registered User
pawelsky's Avatar
Polska
Joined Jan 2012
1,680 Posts
Quote:
Originally Posted by monty_mcmont View Post
Me again! I was just wondering what the physical connections are. Do you simply connect ground and signal (e.g. serial port Tx) from the Teensy to the Smart Port on the receiver?
Yes.

Quote:
Originally Posted by monty_mcmont View Post
Also, does the receiver automatically include RSSI data in with the other telemetry data when it transmits it back to the ground station?
The RSSI value is sent back to the Taranis radio (which can display it), but if you are using a built in TX module I don't think you can easily get access to the S.Port telemetry stream and redirect it to your GS. You would need to use the FrSky external X series TX module.

EDIT: Correction - you can get easy access to S.Port telemetry stream on Taranis:
https://github.com/opentx/opentx/wik...is-serial-port
pawelsky is online now Find More Posts by pawelsky
Last edited by pawelsky; Sep 25, 2014 at 06:35 PM.
Reply With Quote
Old Sep 25, 2014, 05:53 PM
Registered User
United Kingdom, England, Leeds
Joined Jul 2014
11 Posts
I use a FrSky X8R telemetry enabled receiver and a FrSky DJT JR module with pins on the back, into which I can plug one of the FrSky FLD-02 telemetry displays :-)
monty_mcmont is offline Find More Posts by monty_mcmont
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion NAZA GPS to FrSky Taranis (s.Port) Telemetry converter Michel64 Multirotor Electronics 60 Yesterday 10:24 AM
Sold FrSky X8R 8/16Ch S.BUS ACCST Telemetry Receiver W/Smart Port navihawk Aircraft - General - Radio Equipment (FS/W) 5 Mar 29, 2014 11:07 AM
For Sale FrSky X8R 8/16Ch S.BUS ACCST Telemetry Receiver W/Smart Port navihawk Aircraft - Electric - Multirotor (FS/W) 0 Mar 28, 2014 07:21 PM
For Sale FrSky X8R 8/16Ch S.BUS ACCST Telemetry Receiver W/Smart Port navihawk FPV Equipment (FS/W) 0 Mar 28, 2014 07:19 PM