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-