Once you have connected to the I2C bus and set about becoming a "Slave" you will start receiving data like any other "Slave" on the bus. So in order to get the Android App the telemetry data, we need to create a little hardware device that will connect to the Spectra module receive the data and transmit it on to the Android App. The easiest way to transmit the data to the Android App is to send it over a Bluetooth Serial link, and that is just how the App is coded.
Here is how the data flows through the system:
Spectra <- (I2C) ->Teensy (Serial Data)->Bluetooth Module (2,4GHz radio) -> RC Telemetry App
The following is my description of how I assembled a device that does what is described above. I experimented on a breadboard, but I will be soldering this together to make a little unit to connect to my radio all the time. I will include picture of that in a different post.
I have recreated this device using three different micro controller boards: Adafruit Trinket, Teensy 2.0 and the Teensy LC. Of these three boards, I really prefer the Teensy LC because it is so much fast than the other boards, so you can do much more with it. In fact, I have added a little Nokia LCD display to the device so I can display real time telemetry right on the LCD screen without the need to even have the app running.
Components
- Microcontroller board:
Teensy 2.0, running at 3V3 - $16 for board and $1 for the 3V3 regulator
Teensy LC running at 3V3 - $11.65
Adafruit Trinket 3.3V - $6.95 - Bluetooth Serial Module - $6.27 from DX.com
- Standard Servo Cable (3 conductor, keyed)
- 2 1.5K Resistors to use as pull ups
Wiring
Bluetooth
The pins of the TeensyLC and Bluetooth modules have names and are marked on the devices. We will be using the TeensyLC's hardware serial port, so we must use the specified pins. Here is the connection matrix:Teensy 2.0 | TeensyLC | Bluetooth |
GND
|
GND
|
GND
|
VCC
|
VCC
|
VCC
|
D2
|
0
|
TxD
|
D3
|
1
|
RxD
|
Spectra
The Spectra module has a port in it where a standard Servo connector can be connected. It might be covered by a small plastic cover, We will number the port from the top to the bottom. The top is the connection closest to the keyed port. In the photo the yellow line is connected at the top:Spectra to Teensy
Spectra Module with Servo Cable |
Spectra
|
TeensyLC
|
Teensy 2.0
|
1 (yellow)
|
19
|
D0
|
2 (red)
|
18
|
D1
|
3 (black)
|
GND
|
GND
|
In order to connect the servo connector to the Teensy, I used 3 pins plugged into the servo cable and that plugged into breadboard. The 1.5k resistors can be seen plugged from the pins to the 3.3V bus. These must be present to in order to pull up the I2C bus:
TeensyLC pictured with Pull ups |
Testing
Plug in your Teensy at this time, it should power up and the Bluetooth module should power up as well. On the both the Teensy and the Bluetooth module there are LEDs that light up, if you do not see any lights, unplug it and check your connections.When the Bluetooth module gets power, you will be able to bind it to your computer or your phone. It will not get any data yet, of course, but you should see it out there. After you bind to it and connect, the blinking light will change to steady on.
Programming
Install Arduino and Teensyduino in order to program the module using the Arduino interface. The program for the TeensyLC version of the program depends on the i2c_t3 library, so make sure that you install that library when given the choice while installing Teensyduino.I have written a simple program that will configure the micro-controller to be a slave on the I2C bus so that it will receive data from the Spectra module. As soon as it receives a packet of data, it immediately transmits that data out to the Bluetooth module. This program is dumb, it does not even look to see if there is a valid Bluetooth connection or anything, it just sends the data. It does have some code in there to blink the LED on the board when it is receiving data and to glow steady if no data is being received.
TeensyLC
The TeensyLC version of the program does not take any special modification to the library it uses, so just download the program and load it up in the Arduino environment and program the Teensy LC with it.Spectra_to_TeensyLC
Teensy 2.0
The program for the Teensy 2.0 depends on a modified version of the Wire library called WSWire. This modification has a set of loops that will reset the I2C hardware on the Teensy if the bus gets locked up. Be sure that you install the WSWire library, I provide a link here, but I think you can find it elsewhere too. To install the library, follow the directions on the Arduino website, there are instructions on how to install a library there.WSWire Library
Download the Arduino program below and program it onto your Teensy, it should start running immediately
Spectra_to_Teensy20
-Matt-
will be trying to build that thing to get telemetry...
ReplyDeleteThank you for your awesome work!
ReplyDeleteI'm just started to get to know these controller boards. I have a Trinket board and I would like to ask that it is the same as the Teensy 2.0 part in your post?
The trinket is not the same, but I have successfully connected a trinket to the Spectra module. You have to use a modified Wire library that has the code in it to avoid the lockups. I may have the trinket code laying around, let me know if you want it.
DeleteIf you can send me the code that would be great, thanks! The modified library is the one in the post?
DeleteYes, it is, sorry I forgot I left it there. Here is a link for the code I wrote for the trinket. Remember, you must use external pull up resistors and it has to be 3v3! Matt
Deletehttps://dl.dropboxusercontent.com/u/3582209/Trinket_I2C_Slave_Relay.zip
Thank you! Now I'm thinking about to use my Arduino UNO as a sensor board for gps speed and altitude if it is possible. (But maybe now I freeze the Uno thing until the parts for this bluetooth circuit will arrive.)
DeleteThe interface to the microprocessor in the receiver on board the aircraft is much more complex. There is some information about it on the RC Groups.
DeleteI am actually designed a board where you can mount a TeensyLC, a small Nokia LCD and the Bluetooth module on it. It will also have 2 buttons, an LED and connections for a battery and the Spectra module. I just ordered 3 prototype boards, I will let you know how they work out.
DeleteThat's awesome! I think I have to order a TeensyLC then, but in Hungary it is really rare.
DeleteThank you again for your work! :)
I just found that on RcGroups Swinn made some board for the whole thing. Do you know where could I get a board, or a design file? (I wrote to him on RcGroups but he was online about months ago.) I hope it isn't a problem that I asked you about that.
DeleteWell, Swinn might be able to sell you a board, but he is no longer doing it. He got a different type of radio that had telemetry included. I think your best bet is to use the Trinket or the TeensyLC.
DeleteOkay, thanks! Then I'll try to put together the Trinket, and if it will work I'm going to design a PCB for it, like a shield for the Trinket. Thanks for the answer!
DeleteGo man, the Trinket works great, just does not have many pins...
DeleteHi Matt,
DeleteI am from the research group on university and we try to use the Hitec Spectra to get some telemetry from APM autopilots. There are some possibilities to connect rx with APM, but the I2C data interpretation is still little bit fuzzy. Can you provide some protocol description to interpret the data received over I2C bus? It wil be really good to know the meaning of received data on microprocessor platform.
Tomáš,
DeleteThere is a good deal of information on the protocol format in the RCGroups thread located here: http://www.rcgroups.com/forums/showthread.php?t=1389908 if you send me an email at matthew.c.sargent at gmail dot com, I can send you more information.
This comment has been removed by the author.
ReplyDeleteHello.
ReplyDeleteIs the displayed level of speed and height is taken from the GPS or other sensors?
The Altitude and speed are from the GPS usually, but if you outfit the sensor unit with a pitot tube sensor and electronics, I think you can get speed and altitude from that.
DeleteAll - I have ordered a PCB board which will mount a TeensyLC, LCD panel and JY-MCU Blutooth modules on it, along with the necessary resistors, LED and buttons. I will make a new post when I get the PCB in the mail and populate it.
ReplyDeleteAll, I have received the first prototype of the interface board and it works perfectly! I will be adding a blog post with pictures and the description of the new version I have just sent to be fab'ed. Look for it!
ReplyDeleteHello.
ReplyDeleteI started my set of telemetry It works correctly.
I have a few comments and suggestions.
Airspeed does not work with the pitot tube.
Altitude does not work with vario.
These two parameters are likely to be read from the GPS. I do not have a GPS.
PTO Pres - gives readings from the Pitot tube.
When the value stated in the read in / hg divide by 256 we get the speed in km / h and further dividing by 3.6 we get the value of m / s.
And here I have a request for the introduction of both units to the program.
In my opinion, in order to improve the read speed flight parameters, you can add options for delivering messages without specifying units (airspeed 45) (altitude 450) the same way as "include the word // is"
I noted in "audible settings" two parameters of altitude and airspeed.
During the reading I've heard it in that order - // "altitude airspeed 135 46 //"
Regards
Mari, I sent you a message directly. I will get those changes in as fast as I can. Thanks!
DeleteHi ! What about using Arduino Nano instead of Teensy or Trinket ?
ReplyDeleteA Nano will work very well, but to make it easy, use a 3v3 Nano, otherwise you have to build level shifting. My code should work fine after you adjust it for the Nano device. Let me know how it goes!
DeleteThis unit from Adafruit can do the level shifting really well: https://www.adafruit.com/products/757
DeleteThat's right. I did some tests with Arduino UNO and it works fine (sniffing DATA port from SPectra is easy with your piece of code found on RCgroup). Unlike UNO that manage both 3v3 and 5v, Nano has only 5v. Not the best shield for that ...
DeleteThe code for the Teensy2.0 above in the blog post will also work on an Arduino - but you need to use the modified wire library, I think.
DeleteI did it ! Work fine with Teensy-LC :) Do you plan to make evolutions/corrections to the android part ?
DeleteThis comment has been removed by the author.
ReplyDeleteI did it ! Work fine with Teensy-LC :) Do you plan to make evolutions/corrections to the android part ?
ReplyDeleteAwesome! I have some copies of my circuit board and I can send you one if you want to use that. And yes, I have made lots of modifications to the App. Send me an email at matthew.c.sargent@gmail.com and I will add you to the beta testers.
DeleteGreat work - Thank you.
ReplyDeletePlease, let me ask for more details, cause I could not get in run.
First my specifications:
Aurora 9 - firmware 1.09
Spectra modul (v1) - firmware 3.01
Optima receiver ... however the Aurora display the telemetry data.
Tennsy LC
BT modul using 3.3 v level.
Huawei y300 Smartphone - connection to BT modul is fine - using latest RC Telemetry app 1.7.40 (512) from google play store..
Right now everything is on the table, for powering up, I use the USB of the teensy LC - by an USB Powerpack (not to PC connected).
TeensyLC LED is on all the time.
BT modul is on if connected to Huawei.
Connections are checked everything looks fine - bu no data is displayed in the app.
Perhaps - I guess, it´s the communication speed between TeensyLC and BT modul. I´m using one, which was allready used for my MWC FC. So it´s set to communication speed 115200.
Thanks for any help
Andreas
It is probably what you suspect. The code for the TeensyLC assumes a 19200 baud rate:
Delete//////////////SETUP/////////////////////////
void setup()
{
//Serial.begin(19200); // start serial for output
btModule.begin(19200); //<-- 19200
delay(3000);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin,HIGH); //start LED as ON.
Change the speed up to 115200 and it may work - it depends on if the Teensy can support that spped, I think it can. You can also follow the instructions for setting the speed of the BT Module. Just search for BT module you are using and there are lots of example ho how to change the baud rate.
Good luck!
This comment has been removed by the author.
DeleteThank you for the support.
DeleteRight now, I got it 8-)
My mistake was wrong connecting the pull-up resistors.
Thank you 8-)
Hi ça y ou reupload the program for TeensyLC please ?
ReplyDeleteDamien, sorry, the link to public files in DropBox is dead, I will fix. Matt
ReplyDeleteDoes the RC Telemetry App for Android support (or be modified to support) the Hitec variometer attached to the HTS-SS Advance sensor station? Will it work with the HTS-SS Advance?
ReplyDeleteIt did support the Variometer, but the App has not been updated so it is no longer available on the Store. If you really want to try it, I might be able to get it re-compiled again.
ReplyDeleteYou apparently still have it at APKPure.com, version 1.7.40 (Jan., 2016). Can it be installed on the Android phone from there?
DeleteMany thanks for your very quick response. I am studying the problem and will get back to you if I choose this path (it's very interesting, I'm learning a lot about Arduino, and I have an electronics marketplace just 50 metres from my home :-). I wonder whether just the Vario could not be supported by an Arduino-type unit like the I2C-Bluetooth unit equipped with sound (and headphones ;-) and perhaps an LCD display (for altitude, etc.)? There are I2C adapters for Arduino, too.I'm using an old Eclipse 7 Tx with the 2.4 GHz 2-way Spectra module and Optima 7 Rx's in my gliders. Ofcourse, I could just buy an Aurora 9X, but the possibilities with using the perfectly good old Eclipse are perhaps greater and much more flexible, and I have a newish spare Android phone to use. (Q.: Can an Android phone be used in this application without a SIM Card?)
ReplyDeleteActually, in the code, I simulate a variometer using the pressure sensor on the sensor package - I sample the pressure and then compare it to a little while ago and beep at a rate that corresponds to if it is rising on dropping. If you get the App to work, you will see the settings for it. I think I fixed the issue that got the app removed from the store, so maybe it will re-appear. I still need to recompile it with the newest libraries.
ReplyDeleteI just downloaded the app and when I try to show the map, it dies, so give me a few days to see if I can get it re-compiled.
ReplyDeleteHi Matt,
ReplyDeleteDid you release a new version, to fix the problem ?
Or, is there a way to disable the display of Google Map on the 2th screen off app ?
Thx
I have been able to fix the map display problem, but I still need to fix some additional issues with map handling. The layout also needs to be updated for all the new device sizes. I will need a bit of time to get all those done.
ReplyDeleteFine ! I can't wait to see this update ;)
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDelete