Hello everybody. For my latest project I have been experimenting with FrSky telemetry. I have a 9XR and since I did not want to risk the telemetry mod as yet, I have been trying to build an Arduino based display for telemetry data .
I have modified the code from here (http://rapellys.biz/?p=104). Credit goes to the creator of this code.
I am using a FrSky DJT module with a D8R Plus receiver along with an Arduino Uno and standard 1602 LCD module
My setup is:
- Jumper between D8R A1 and x pins
- DIY voltage sensor to D8R pin A2
- DJT Txd pin to Arduino pin A2
- DJT Rxd pin to Arduino pin A3
- standard connections for LCD display (as stated in the LiquidCrystal library)
This is my code (https://drive.google.com/file/d/0B6XjbwXPI1coRmR6Mi1MUG1weU0/view?usp=sharing)
It currently displays the internal receiver voltage, battery voltage and the uplink and downlink RSSI.
Making a voltage sensor for FrSky telemetry is simple. As a disclaimer, I take no responsibility for any damaged caused by following these instruction. These are the required parts:
- JST-XH connector (female in order to plug into the LiPo balance lead)
- 10KΩ and 2.2KΩ resistors
- Servo plug
Remove all but the signal wire from the servo plug and also remove the two middle wires from the JST-XH plug. Solder the resistors in series and then solder the 2.2K end to the negative wire of the JST-XH plug and 10K end to the positive wire. Add a tap between the resistors by soldering the signal wire in between the 2 resistors. If the receiver is being powered by the main battery, then there is no need to include a ground wire. Insulate all exposed contacts. This is the schematic:
(http://i284.photobucket.com/albums/ll36/siddharth_kumanduri1/Screen%20Shot%202015-04-15%20at%201.29.03%20pm_zpstykxluoj.png)
The theory of operation is simple. This circuit is nothing but a potential divider. The FrSky D8R can accept only up to 3.3V max so the voltage from the battery must be scaled down to below this and then scaled up again in the Arduino code or in the telemetry menu.
I plan to try and implement a current sensor using a hall effect sensor to provide a voltage directly proportional to the current. However, I would like some help in implementing due to the large currents involved. I do not think a shunt resistor would work here as the resistance would have to be very small yet it would need to be rated for a very high power.
Hi
Can you help ?
I do it, but it don't work, the lcd say "Waiting for data". Telemetry receive nothing.
I want only the volts and RSSI.
I have a DJT TX and Rx D8R II
Thx
Hi. I haven't looked at this project in a long time but your post inspired me to try it again. It is working perfectly fine, though I am using a newer version of the code adapted to run on an I2C LCD. The code I have linked to is a much older version and may have some issues. Please try this:
Quote#include <SoftwareSerial.h>
#include <LCD.h>
#define DE_BUG // Change this to #define DEBUG if needed
#define DE_BUG_HEX
#define FRS_TX_PIN A2 // not used
#define FRS_RX_PIN A3 // telemetry data
#define FRAME_SIZE 12 // max 12 bytes
#define FRAME_RVLQ 0xFE // second byte 0xFE - Remote Voltage and Link Quality
#define FRAME_USER 0xFD // second byte 0xFD - User Data
#define DISP_INTERVAL 500 // ms
SoftwareSerial FrSky = SoftwareSerial(FRS_TX_PIN, FRS_RX_PIN, true); // orig false
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte next = 0;
byte buff[FRAME_SIZE]; // frame array
byte index = 0; // index in frame array
byte link = 0; // link established, data received
byte frame = 0; // frame received indicator
byte stuff = 0; // byte stuffing indicator
int Rx[DISP_INTERVAL / 15]; // Up Link Quality RSSI
int Tx[DISP_INTERVAL / 15]; // Down Link Quality RSSI
int V1[DISP_INTERVAL / 15]; // Port 1 voltage, V * 100
int V2[DISP_INTERVAL / 15]; // Port 2 voltage, V * 100
unsigned long dispTime = 0; // time when info was updated, ms
unsigned long prevTime = 0; // time when 0xFE frame was received, ms
int frmeTime = 0; // frame period, ms (~36ms)
int nvals = 0; // number of values received since last display
const int ledPin = 13; // pin that the LED is attached to
void setup() {
FrSky.begin(9600);
Serial.begin(115200);
dispTime = millis();
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("FrSky Telemetry");
lcd.setCursor(0, 1);
lcd.print("SK1701");
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Waiting for data");
lcd.setCursor(0, 1);
while (FrSky.available() == false) {
lcd.setCursor(0, 1);
for (int thisChar = 0; thisChar < 17; thisChar++) {
delay(500);
lcd.print(".");
}
lcd.setCursor(0, 1);
for (int i = 0; i < 16; i++) {
lcd.write(' ');
}
}
frame = 0;
index = 0;
link = 0;
stuff = 0;
prevTime = millis();
}
void loop() {
if (FrSky.available()) { // reading input data
next = (byte)FrSky.read();
if (next != 0x7E)
if (next == 0x7D) // byte stuffing indicator
stuff = 1; // set the flag and discard byte
else if (stuff == 0)
buff[index++] = next; // normal byte
else {
buff[index++] = next | 0x20; // byte stuffing set, change next byte
stuff = 0; // and reset the flag
}
else {
if (index == 10 || index == 11) { // end byte
buff[index] = next;
frame = 1;
index = 0;
} else { // start byte?
index = 0;
buff[index++] = next;
}
}
if (index >= FRAME_SIZE)
index = FRAME_SIZE - 1; // prevent buffer overflow
}
if (buff[1] == FRAME_RVLQ && frame == 1) { // second byte 0xFE - Remote Voltage and Link Quality
V1[nvals] = buff[2] * 4 * 330.0 / 255; // V1 - Voltage, up to 13.2V, Internal divider 1:4
V2[nvals] = buff[3] * (22 + 100) / 22 * 330.0 / 255; // V2 - Voltage, up to 18.3V
Rx[nvals] = buff[4]; // Up Link Quality RSSI (min 36, max 116-121)
Tx[nvals] = buff[5] / 2; // Down Link Quality RSSI (min 36, max 116-121)
frmeTime = millis() - prevTime; // frame period in ms
prevTime = millis();
frame = 0;
link = 1; // valid data received
nvals++;
}
if (link == 1 && millis() > dispTime + DISP_INTERVAL && nvals > 0) {
dispTime = millis();
#ifdef DEBUG
printData();
#endif
lcd.setCursor(0, 0);
lcd.print(mode(V1, nvals) / 100.0, 2);
lcd.print("V ");
lcd.setCursor(7, 0);
lcd.print("RX=");
lcd.print(mode(Rx, nvals), 1);
lcd.print("dBc ");
lcd.setCursor(0, 1);
lcd.print(mode(V2, nvals) / 100.0, 2);
lcd.print("V ");
lcd.setCursor(7, 1);
lcd.print("TX=");
lcd.print(mode(Tx, nvals), 1);
lcd.print("dBc ");
nvals = 0;
}
}
void printData(void) {
Serial.print(prevTime / 1000.0, 4);
Serial.print(": ");
#ifdef DEBUG_HEX
for (byte i = 0; i <= 10; i++) {
Serial.print(buff, HEX);
Serial.print(" ");
}
#endif
Serial.print("V1 = ");
Serial.print(mode(V1, nvals) / 100.0, 2);
Serial.print("V, V2 = ");
Serial.print(mode(V2, nvals) / 100.0, 2);
Serial.print("V, Rx = ");
Serial.print(mode(Rx, nvals));
Serial.print("dBc, Tx = ");
Serial.print(mode(Tx, nvals));
Serial.print("dBc, packets = ");
Serial.print(nvals);
Serial.println();
}
int mode(int arr[], int asize) {
if (asize == 0) {
return 0;
}
int mode = arr[asize - 1];
int mcount = 1;
int count = 0;
for (int i = asize; i > 0; i--) {
int val = arr[i - 1];
for (int j = i; j > 0; j--) {
if (arr[j - 1] == val) count++;
}
if (count > mcount) {
mode = val;
mcount = count;
}
count = 0;
}
return mode;
}
Thanks, for your answer.
now I am out, when I get home I test it.
I also have an lcd display ic2. I change some lines to make it work.
I think my problem is in the connection between tx DJT and arduino.
Hi.
It Doesn`t work
I only changed
//#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
and
//LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal_I2C lcd(0x3f, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
My lcd is ok. It shows Waiting for data........ printing dots
I connected
frsky DJT Arduino Mega
Gnd ----------- Gnd
5v ----------- 5v
Tx ----------- A3
Rx ----------- A2
I also tried swapping A2 to A3 and it doesnt work
is that wrong?
Thanks.
Will it work with a DHT MODULE?