FrSky D series arduino DIY hub with naza GPS data to openTX - RC Groups
Thread Tools
Jan 14, 2016, 04:46 PM
Registered User

FrSky D series arduino DIY hub with naza GPS data to openTX


As I have been reading a lot of Frsky series diyers making their own sensors, hubs, vario etc for frsky sport, but seems like no one is interested on the D protocol (old) Frsky anymore or the interest is fading fast.
I still have the old type fas, flvs and rpm sensors I have been using In various planes and helis, but never had the GPS data on openTX and using flysky Th9x display.

My coding skills are on newbie level, and to achieve this was way too difficult for me.

So Fred came to the rescue!

I have a setup where I want to have next sensors with arduino pro mini / nano:

Naza FC GPS data
Fas-100 voltage and current
Flvs-01 lipo cell voltage

Other sensors can be added to the code, but please as I can not test them my self, you have to figure out how to add them..

Whole code is based on flarssen and NazaDecoder library from Pawelsky@, thank you guys!

More of NazaDecoder :

Connection diagram is attached, and feel free to change the ports to what you are comfortable with.

The locked satellites are shown as T1 (TEMP1) on display, and T2(TEMP2) is fix type (3=3DFix).

If you want to use this on s.port (it should be possbile), but I unfortunately do not have chance to test it, read ahead, there is more info..
New IDE 1.6.6 might give an error when compiling, tested working with 1.0.x versions.

Respect the authors, not for commercial use!

- Pete

P.S. Thanks Fred again.
Last edited by poteroa; Feb 11, 2016 at 12:05 AM. Reason: Project update
Sign up now
to remove ads between posts
Jan 14, 2016, 10:29 PM
Registered User
I initially thought you got D-series data from the Naza somehow, but it sounds more like the data is in standard GPS format? If so, parts of the code here could be used.

Jan 15, 2016, 12:13 AM
Registered User
Hi Fred.

Thank you for the link, I will look at the code today.

Actually the gps data is not straight NMEA/UBLOX, its wrapped in frsky protocol frames, so it needs decoding..

Pawelsky has done the nazadecoder library, which works, but still the sensor data needs to be added to the pack too.

I do not know would it be easier to start with it or go some other way to achieve this. All comments are welcome. =)

Actually this should be "easily" done as both flvs and fas are chained, so only one softserial input is needed.

I know that teensy would be better in the matter of 3 hardware uarts, but the idea is to have a cheap option. Teensy is somewhat 10 times more expensive than nano/pro mini. (actually more expensive than the real hub itself). But of course has no option to get the gps data telemetry from naza gps.

One way to get it done is to bypass the gps and pull a single wire for UBX protocol, but that is not very convenient way.
Jan 15, 2016, 12:21 PM
Registered User
Originally Posted by poteroa
Actually the gps data is not straight NMEA/UBLOX, its wrapped in frsky protocol frames, so it needs decoding..

Pawelsky has done the nazadecoder library, which works, but still the sensor data needs to be added to the pack too.
So what you have is Arduino code that uses his library to read Naza on UART and output D-series GPS frames? If so, then you can just read FAS frames on software serial, and send them to the receiver in between the GPS frames. FAS update is pretty slow, every 500ms I think.

Jan 21, 2016, 01:25 AM
Registered User
I have been reading a lot of the frame protocol past week. Sadly have not had time sit down and actually do something due to long office hours.

I hope I can start this weekend and post some code here.
Jan 23, 2016, 04:29 PM
Registered User
I'm still not sure what you want to achieve. I changed the code for reading D-series data on pin 10, and passing it on to the receiver.
It processes the data value by value. Seems to work better with the LDU code.
One strange thing is that it fails with only the code commented out in loop(). Only the first value (current, 0x28) gets through. With loop() code as posted, it works fine with input from FAS-40+FLVS.

Last edited by flarssen; Jan 23, 2016 at 11:30 PM.
Jan 24, 2016, 01:18 AM
Registered User
Good Morning!

Well the only thing I am after is the NMEA (heading, sat fix, coordinates) from naza Ublox 6M.
The fas voltage and current + flvs lips cell voltages. Thats it, nothing more.
I actually did a modification to my other Naza GPS for direct Ublox sentences, so I can use it to debug easier.

Can not seem to get the frame protocol working, I am just too new to this. =)

Ok, looked at your code and it works perfectly with FAS / FLVS-01, I have tried to add decoding for naza but can not seem to get it working.

Seems I can not get the serial port free for reading the data to process it. I get nothing on the serial port.

More specific.

I try to use RX pin on arduino pro mini to read the GPS, after to send with the software serial after decoding (serialD) with code you posted

I get nothing on the display, (except the sensor data)..
Last edited by poteroa; Jan 24, 2016 at 04:08 AM.
Jan 24, 2016, 05:41 AM
Registered User

Some progress, I can get the naza messages to serial, but can not get it to software serial..

Here is what I have now, and can read the sensor and GPS data on UART.
  Author: flarssen, 01/2016
#include <SoftwareSerial.h>
#include <NazaDecoderLib.h>

#define PIN_SerialTelemetryRX 10       // the pin to use for D series data input
#define PIN_SerialTelemetryTX 12       // the pin to use for serial data to the FrSky receiver
#define LED_PIN 13                     // the pin connected to onboard LED
#define MAX_FRAME 125

SoftwareSerial serialD(PIN_SerialTelemetryRX, PIN_SerialTelemetryTX, true);
uint32_t currentTime;
uint32_t attiTime;
uint32_t time;
byte count;

void processExternalByte (uint8_t ExternalByte) {
  static uint8_t DData[MAX_FRAME+1];
  static unsigned int index = 0;
  static byte stuffed = 0;
  if (ExternalByte == 0x5e) { // Head/Tail
    if (index == 3 + stuffed) { // Valid frame size
      digitalWrite(LED_PIN, HIGH);
      for (int i=0; i < index; i++) { 
        if (DData[i] < 0x10)
        Serial.print(DData[i], HEX);
      digitalWrite(LED_PIN, LOW);
    index = 0;
    stuffed = 0;
  if (index <  MAX_FRAME) { 
    DData[index++] = ExternalByte;
    if (ExternalByte == 0x5d)

void setup()
  pinMode(LED_PIN, OUTPUT); 


void loop() {
//  while(serialD.available() > 0)
//    processExternalByte(; 
  do {
    currentTime = millis();
    count = serialD.available();
    if (count > 0) {
      Serial.print("  ");
  } while (count);   
if(Serial.available() > 0)
    uint8_t decodedMessage = NazaDecoder.decode(;
    switch (decodedMessage)
      case NAZA_MESSAGE_GPS:
        Serial.print(NazaDecoder.getLat(), 7);
        Serial.print(NazaDecoder.getLon(), 7);
        Serial.print(NazaDecoder.getAlt(), 7);
        Serial.print(NazaDecoder.getCog(), 2);
  currentTime = millis();
  // Display attitude at 1Hz rate so every 1000 milliseconds
  if(attiTime < currentTime)
    attiTime = currentTime + 1000;
So I am close, all thanks to you Fred. =) Maybe you can give the last push
Jan 24, 2016, 07:39 AM
Registered User
This is what I get on serial port at the moment (no GPS lock though).
Code:  1
37352  5
37358  10
37365  16
37367  16


37373  15
37373  14
37374  13
37374  12
37376  11


37382  10
37382  9
37382  8
37383  7
37383  6


37389  5
37390  4
37390  3
37391  2
37391  1

Jan 24, 2016, 07:48 AM
Registered User
All references to Serial must be removed from my code. They are just there for debugging and will interfere with anything connected to Arduino serial. The Naza code needs to be inside loop(), not after it. But I can't see how the GPS data will get to the D-receiver. Seems like it reads Naza data, and sends the result back on Serial?
What you need is code that outputs Naza data to D-series RX, then add my code for the FAS part.
I will try this on my GPS code found here.

Jan 24, 2016, 07:52 AM
Registered User
Originally Posted by poteroa
This is what I get on serial port at the moment (no GPS lock though).
Yes, that's the debugging info. It's milliseconds and number of bytes available, followed by the FAS data.

Jan 24, 2016, 08:05 AM
Registered User
Ok, so at least there is light in the end of tunnel. ;D

I try to bang my head very hard on the keyboard, maybe I can get it working

I am stuck. Can not understand how to use the same soft serial port for your code and the one I try to use for GPS send.
Last edited by poteroa; Jan 24, 2016 at 01:17 PM.
Jan 28, 2016, 10:36 PM
Registered User
Got some progress with this, I can get now the fas / flvs and gps data to display, but have a serious delay / buffer overflow. As parts of the code write the same values in buffer twice and some packets are lost. Still need to figure out what parts I can leave out to get it stable.

I am using Freds "Dmerge" code and "der-fricklers " naza2frskyhub code, and the Frsky telemetry feeder part from Jani Hirvinen. etc.

As the voltage, cell and amp should be instantly displayed, there is a few second delay in it, but the gps data seem to be good and data is not lost on that part.

I try to check the code and post it here.
Jan 28, 2016, 10:43 PM
Registered User
Here is the "mess" to start with..

So this is not a working code yet, anyone who "feels a need" to modify it, please do and post suggestions / fixes to achieve a working code.

This is NOT for commercial use, respect the original coders and keep their information in the code if you post it somewhere else.
Jan 28, 2016, 11:00 PM
Registered User
It turns out that SoftwareSerial is half duplex, since writing may lead to loss of incoming data. I'm currently looking at different solutions. One might be to buffer all data, then write it some ms after last input from FAS. I'm also looking at different code for soft serial.


Thread Tools