Friday, 25 April 2014

BlueFlyVario_TTL integration with the Kobo

Since I released the BlueFlyVario_TTL a few weeks ago many people have purchased one to integrate with the Kobo for use with XCSoar. The purpose of this post is to provide a few tips. It is by no means a complete tutorial for beginners. Integration with the Kobo requires careful soldering and software manipulation shills.

Step 1 - Get your Kobo

The Kobo mini is currently being sold for around $50. I understand they are no longer being produced and most stockists are getting rid of them at cost. Other devices such as the Kobo Touch can be used in a similar manner. At some stage these devices will be hard to find.

Step 2 - Make sure it works as a standard eReader

After purchasing the Kobo you should configure it like a normal eReader as per the instructions that came with it. This is important to do prior to installing XCSoar.

Step 3 - Back up the SD Card

The device has an SD card inside which includes the operating system and applications. Open up the Kobo and put the SD card into a reader. Create an image of it with win32DiskImager or your favourite sd card imaging software. Save the backup image somewhere where you will not loose it. Make sure to turn off the kobo prior to the next step.

Step 4 - Solder wires to the internal serial port

Take off the back covers and identify the serial port in the bottom left of the circuit board. The images below shows a good location for the wires and holes if you want your BlueFlyVario_TTL mounted on the front of the device. I have used a 4 port 2.54mm pitch dupont housing to plug the BlueFlyVario_TTL into. I drilled the holes from the rear and matched each size hole with the diameter of the wires. Note that the Rx from the Kobo needs to match to the Tx from the BlueFlyVario_TTL, and the Tx from the Kobo needs to match to the Rx from the BlueFlyVario TTL.


The holes were drilled from the rear. The solder residue on the serial port is from a previous installation.


The holes look pretty small from the front.

Push the wires through from the front prior to soldering.


Soldering the wires is a little tricky. I started with a dab of solder on each solder hole, tinned the trimmed wire with solder, then angled each one into the hole after reheating it with the iron. Note that the ground is much more difficult to solder as the heat is rapidly drawn away by the larger copper pour on the Kobo PCB.

Step 5 - Install XCSoar

The Kobo XCSoar image and instructions can be found here: http://www.xcsoar.org/download/.  I will not cover how to do this in great detail; there is heaps of information on the XCSoar forums and other internet resources to help you out.

Step 6 - Test the BlueFlyVario_TTL is working

After you have XCSoar working, and the Kobo is on, plug in the TTL to the front of the device. You should here it's startup beep. Next:

  • Double tap on the screen to bring up the Menu.
  • Go Config|Config 1/3|Devices
  • Ensure device A is selected and tap Edit
  • Change the following settings:
    • Port: ttymxc0
    • Baud rate: 57600
    • Driver: BlueFly Vario
    • Ignore checksum: On
  • Click ok, then Monitor to see the incoming data stream. 
Step 7 - Attach a GPS to the BlueFlyVario_TTL U1 port

Incoming GPS data (NMEA sentences) will be streamed via U1 on the BlueFlyVario_TTL and multiplexed with the BlueFlyVario output stream. XCSoar can read the combined stream from the single port. The image below shows a cheap NEO-6M module connected directly to the BlueFlyVario_TTL. The BlueFlyVario expects a 96008N1 serial input from the GPS. Read the section of the BlueFlyVario Hardware Settings Manual for more information about the second serial port. 



Step 8 - Configure the BlueFlyVario_TTL Hardware Settings

This bit was pretty tricky to work out. Thanks to Steve Nagle for his help. In fact, it was pretty much all worked out by him.

The aim is to alter the BlueFlyVario hardware settings directly from the Kobo (linux) command line without having to plug the vario into a windows PC. This is how you do it:
  • Restart the Kobo with XCSoar on it.
  • Press "Network" at bottom of screen. 
  • At top of screen press the button where it says "Wifi ON" (this turns the Wifi on - button then confusingly shows text "Wifi OFF" meaning that pressing it again will have that effect)
  • Press the button "Wifi" to select a Wifi network, connect to your network (The Kobo will display 'connected' next to network name on Wifi page).
  • Once connected press Close button on the wifi page
  • Use a pc and browser to log into your router to find out what network ip address it has allocated to your Kobo (my router is accessed by typing 192.168.1.1 into the browser address box - Google your router brand to find out what it's default internal ip address (and username / password is)
  • On the Kobo press the "Telnet server" button to start telnet on kobo
  • On your PC Telnet to the ip address you found with root as username, no password. In linux use the telnet command at the command prompt, or in windows download a program called Putty and use that. 
  • You should now have a command prompt on your PC. Your PC is now the screen and keyboard for your Kobo, which runs linux. (Type ls and hit return - you should get a directory listing).

Now communicate with the BlueFly over the serial port using commands as follows:
  • stty ospeed 57600 ispeed 57600 -F /dev/ttymxc0  'changes baud settings to match BlueFlyVario.
  • stty -F /dev/ttymxc0 raw  'makes sure the terminal program in linux sends off characters as they arrive.
If you want to see the BlueFly output do this (or skip it if you like)
  • cat /dev/ttymxc0  'test to display the output from BlueFlyVario
(here is a sample of output)
$GPGGA,025704.101,,,,,0,0,,,M,,M,,*4C
PRS 18681
PRS 18680
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
PRS 18680
PRS 18681
PRS 18680

Now press ctrl C to stop that. 

Now we will adjust some settings. These are just examples. See Annex A to the the Hardware Settings Manual for a detailed technical description of the settings. 

Type the following:
  • echo '$BVL 50*'>/dev/ttymxc0  'Sets the volume on the BlueFlyVario to 50.
  • echo '$BOF 10*'>/dev/ttymxc0 'This command changes the output rate to five sentences a second (from the normal 50 (i.e. 50/10)). I think this lessens the CPU workload on the Kobo to handle so many characters over the UART. 
  • echo '$BOM 2*'>/dev/ttymxc0 'This command changes the output format to the LX protocol. Again this lessens the workload on the Kobo as vario value (rather than raw pressure value) is read from the incoming stream. You need to also change the XCSoar driver from 'BlueFly Vario' to 'LX / Colibri' if you change this setting.
  • cat /dev/ttymxc0  'Again to test the display. 
Now press ctrl C to stop that. Type exit to quit. Turn Wifi off and reboot the Kobo. 

More Pictures

Below are some more pictures from Steve's install.






Next Steps

Installing the BlueFlyVario_TTL on the Kobo with XCSoar has proven pretty popular. I am working on another version of the BlueFlyVario_TTL which includes a GPS onboard so there is no need to do that step. I am thinking the PA6H will be a good fit. The board could end up looking like this:


Note the switch so you can continue to use it as a eReader without draining power. Before I get this working I need to add a new setting in the firmware which allows configuration of the GPS when it is attached. More work to do...


54 comments:

  1. Good stuff! I'm using a PA6H with the TTL and it works well.

    ReplyDelete
  2. Solution, very tricky and requires some good hands on skills. How long the battery last with full XCsoar load in thermal conditions. I am assuming there is like 80-100mA peak power consumptions just from vario and GPS module. Anyway there is similar solution already available if somebody prefers less "dirty" approach:
    http://www.goflyinstruments.com/wp-content/uploads/store/ready_to_fly/V4_KIT/1.png

    ReplyDelete
    Replies
    1. Thanks Jaros. The power consumption from the vario when silent is 8.5mA. When beeping it jumps up to about 60mA, but it is not beeping all of the time so the average power consumption is about 20mA with in a normal flight when the sink alarm is set pretty low. The GPS generally more than doubles power consumption. The NEO6m adds 60mA, but I think the PA6H is closer to 20mA. You see that Steve below is report good life in practical conditions. A small external power pack on the USB port can add more.
      It is nice to see that you have included the BlueFly protocol in your instruments! Lets keep in contact.

      Delete
  3. Battery life - My Kobo said 60% remaining after 4 hours flight "full XCsoar load in thermal conditions". Next step is to play with GPS conditions to see if I can reduce it's power draw but I don't expect to save too much.

    ReplyDelete
  4. Another trick if you feel at home with Linux will let you turn what looks like a 2GB card into a 4GB card (and for windows users you can download a 'live' linux distribution, burn it on a CD and run it from there). At step 3, you can do the backup using linux dd commmand, assuming your sd card is at sdb (use fdisk -l to list devices):
    First make sure your sd card is not mounted
    umount /dev/sdb
    Then copy (may take a while)
    dd if=/dev/sdb of=koboimage bs=2048 count = 1024
    This does the same as Alistair's step 3 and copies the first 2GB of the sd card to a file
    Now use gparted (a linux utility) to expand the third partition to use remaining unallocated space.
    (Use the GUI - it is safer than using command line and checks the file system for you too)

    If you want to read more on that look here
    Upgrade sd card http://wiki.mobileread.com/wiki/Kobo_Mini.
    http://www.mobileread.com/forums/showthread.php?t=122701

    ReplyDelete
  5. Very exciting developments here - keep up the good work.
    One thing I'm interested in knowing is which Kobo is best suited and whether there is any potential to work on the newer Nook Aura HD.

    Do you know when the BlueFlyVario_TTL with GPS might become available for purchase?
    Thanks

    ReplyDelete
    Replies
    1. I have only tested the Kobo mini. I would expect it will work with other eReaders, but I do not have more to test. It will probably be about a month until the version with GPS is ready, and that assumes the testing all goes well.

      Delete
    2. It works on the Kobo Aura, although its a bit more fiddly to open. There are two serial ports on the pcb of the Aura, one is permanently powered and the other switches power only when the Kobo is on. The Aura is the latest hardware iteration so its likely to also work on the Aura HD.

      Delete
  6. Ceri Brown, do you have any additional info on the Aura? There does not to be much 'documented experience' on the web so far, and I'm considering trying an Aura. I want to connect a GPS source (Module or a Flarm device, swappable). What about the serial ports: Does the permanently powered one work, or will using it block the device just as it did with the Kobo Touch?

    ReplyDelete
  7. Hi!
    Are there any more of Command line to change the properties? I would love to climb and sink - Customize sound! It gives me a little too sensitive ...

    ReplyDelete
    Replies
    1. Christoph,
      See the hardware settings manual for details on all of the command line options. Download it here: http://www.blueflyvario.com/support

      Delete
    2. Thanks for the answer!
      Is it just possible that BlueFlyVario_TTL via USB isp to program or way to do this via the Kobo with Telenet and command line?

      Delete
    3. Christoph,

      You can program the device via the Kobo with Telnet and command line, or using a USB to TTL serial converter using the BFVDesktop app.

      Delete
  8. Hi
    anyone got gps and TTL working on separate ports?
    I have a touch with sugru folded gps to ttymxc0.
    When I connect TTL rx&tx to another port, the kobo screen freez...

    ReplyDelete
  9. I got so excited after reading this that I'm now trying to hunt down a Kobo mini. Darn hard to find!

    ReplyDelete
  10. Great job! Keep us posted, once you have the GPS integrated Version ready, i'll order one :-)

    ReplyDelete
    Replies
    1. I just released the GPS one: http://blueflyvario.blogspot.com.au/2014/05/blueflyvariottlgpsv9-released.html

      Delete
  11. I can get BFVDesktop app running but of course no connection if going via telnet and kobo. Is there a handy list of all the commands for command line manipulation of all the settings I can see in BFVDesktop app?

    ReplyDelete
    Replies
    1. Ah, made some progress here. I think I see how it's done with the list of codes in Annex A. However just to clarify, I should be entering the values listed under "Integer values" if going via telnet command line correct?

      Delete
    2. Stephen. Great that you found the list in Annex A of the hardware settings manual. Yes, use the integer values if setting via telnet.

      Delete
    3. Al is it possible to get an output of all the currently set values (output some sort of a list). Would be helpful in fine tuning the vario as I'm guessing I'll be adjusting it a little for the next few flights.

      Delete
    4. Yes. Use the command $BST*. It will provide a space separated list of setting codes then a space separated list of the integer values.

      Delete
    5. Hi Al,

      i'm trying to set up some codes via telnet (PuTTY on win7 64 bit, and telnet server on XCSoar), and i can, using command like:

      echo '$BVL integer*'>/dev/ttymxc0

      but i have to write down all the changes, because i cannot retrieve the current values, even using:

      echo '$BST*'>/dev/ttymxc0

      what am i doing wrong? Is possible to retrieve the current values via telnet or i have to connect to the pc using a USB-TTL cable?

      Delete
    6. Despite what I said in the earlier comment I have not managed to determine how to get a list of the current values using the command $BST*. However, it should be possible to make the connection using telnet, start cat so you can see the output, then power cycle the BlueFly. When the BlueFly powers on it sends all of the current values in the same way it would respond to $BST*. For a v10 you just need to long press the button on the Bluefly to restart it. For an earlier model you can ground the MCLR pin of the microcontroller. MCLR is programming pad #1 and GND is programming pad #2.

      Delete
    7. I incidentally saw all the values when power cycling the BFV TTL while displaying the incoming data into XCSoar, but i wasn't sure that they were reliable or not.
      I'll use this method. Thanks!

      Delete
  12. Hi Al, it took just 9 days to get my BVT over to the Netherlands and just a day to get it hook up to my Kobo mini. It works just fine :-) . That is: on the ground, since I haven't been able to test it in the air. I intent to use it for paragliding, but I think I need a few more days to master XCSoar before taking off.
    By the way, the Kobo doesn't seem to update the screen very often, so there is a lot of ghosting. Is there any setting to change this?

    ReplyDelete
    Replies
    1. Wouter, The ghosting is a common 'feature' of eInk screens. You might want to ask the question over on xcsoar forums. See this post for some previous discussion: http://forum.xcsoar.org/viewtopic.php?f=3&t=1242&start=10.

      Delete
  13. Al what would be your suggestion on getting more volume? Got the unit cranked full ball but with it in a pod, and with my enclosed hang gliding helmet I can't hear it comfortably. I'm happy to make modifications, but your advice on the best route to follow would be most welcome.

    ReplyDelete
    Replies
    1. If you want to add an additional speaker then you can just wire it in parallel with the current one. I just tested wiring in a normal earphone from an iPod and that worked fine. I would suggest cutting up an old pair of headphones and wiring one of the speakers into your harness. I just soldered the wires directly to the solder pads at the corners of the current speaker near the large diode which is in parallel with it.

      Delete
    2. Thanks Al - let me try that. Got just the speakers too (I make the radio headsets for the fellas in our club and have neat little speakers which tuck in behind the helmet padding - should be just the thing). If that works nicely I guess I can just cut the connection to the current one rather than trying to remove it altogether and risking damaging the board.

      Delete
    3. Just remembered that the electronics shop down the road sells bigger versions of the sound transducer - do you think I could connect one of those? It would be more convenient not to have a wire going from the pod on the hanglider's base bar, to the harness (lots of movement here - it's gonna break sooner or later)

      Delete
    4. I am not sure exactly what will work. Just experiment a little. With the BlueFlyVario_TTL_v8 it is easier to attach a speaker. You just solder to the two holes on either side of the diode (#4 in the image) , then remove the solder on the solder jumper (#5).

      Delete
    5. Yep, sounds great with a small (2 cm) speaker attached. The low tone for sink is much more audible now too.

      Delete
  14. BlueFlyVario_TTL_GPS_v9 Released
    is compatible in the last kobo ?

    ReplyDelete
    Replies
    1. I have not tested it with every Kobo. I have only installed it with the Mini. However, I am aware of a few pilots have got it working with the Mini, Touch, Glow and the Nook.

      Delete
    2. Can confirm works with Kobo Aura HD and Ceri posted above success on the Kobo Aura. Assume it would also work on the H20

      Delete
    3. Great! Thanks for sharing.

      Delete
  15. Hi Please help? I have Kobo Touch with Bluefly Vario. Vario sounds constantly although still sounds ascent & descent, How can I reset tone and alter sensitivity? Thanks RW

    ReplyDelete
    Replies
    1. You need to alter the hardware settings. The general procedure in Step 8 above shows you how to connect via telnet. You probably want to adjust the sinkThreshold and sinkOffThreshold. See the hardware settings manual on the support pages of the website for the commands and values. You might want to start with the $RSX* command to reset all of the settings to their default values. The equivalent telnet command is:

      echo '$RSX*'>/dev/ttymxc0

      Next, adjust the settings as described in step 8. Then to adjust the sinkThreshold and sinkOffThreshold to -2.0m/s issue the following commands:

      echo '$BFS 200*'>/dev/ttymxc0
      echo '$BOS 200*'>/dev/ttymxc0


      Delete
  16. Hi,I have problem with loging to telnet via Putty ( windows 8 )
    Same problem on another laptop, what is mistake ?
    my steps
    1 KOBO and laptop connected via wifi network
    2 ON KOBO started telnet
    3 Put ip of laptop to PUTTY -OK
    4 PUTTY asked for login - root
    5 no password
    LOGIN FAILED .
    Where's mistake ?
    thanks

    ReplyDelete
    Replies
    1. You need the ip of the kobo, not the laptop.

      Delete
  17. Still problem, Kobo's IP is ok , ping between KOBO and laptop is ok , telnet service is active , firewall ,antyvirus - off , while entering kobo's IP to PUTTY (TELNET port 23) - NETWORK ERROR - CONNECTION REFUSED
    Thanks

    ReplyDelete
    Replies
    1. I am not sure what might be wrong. Perhaps someone on the xcsoar forums could help.

      Delete
  18. Hello!
    Hardware Settings Manual said that if it uses LX protocol it will calculate baro altitude with fixed QNH
    So do I have to use GPS altitude in XCSoar in that case? Or is it actually worth to use raw data and allow XCSoar do all calculations?
    Thanks!

    ReplyDelete
    Replies
    1. It is just the altitdue which is transmitted by the BlueFly which has a fixed QNH. xcsoar will then alter the baro altitude based on its qnh settings.

      Delete
    2. Alex,
      when I use the LX/Colibri device driver it doesn't seem to get the baro values as in xcsoar doesn't seem to parse them so no Alt Baro is shown. However they are there of course & with the Blueflyvario driver you receive baro & GPS.

      How do set the system to get Baro, Vario & GPS data output by Bluefly and parsed by xcsoar?

      Stephen

      Delete
  19. Can I connect BFV TTL to a separate battery (common ground with Kobo) and connect the Tx & Rx to the Kobo in order to save the weak Kobo Battery?

    ReplyDelete
    Replies
    1. Yes, that will work. Please make sure to respect the voltage limits of the regulator.

      Delete
  20. Hi Al,
    Once you applied changes to the BFV through Telnet commands, how can you display BFV settings on your telnet window so that you can check changes where made ? Or simply to check how settings are set on your BFV if you don't know default settings ? Is there a command for that ? Like 'Display $BFS' ?

    ReplyDelete
    Replies
    1. When you start up the vario all of the settings are shown in the first few lines. You can record a nmea log, and then check the settings. See the hardware settings manual for a description of which settings are output.

      Delete
  21. Hi, I have been playing with the stty command on the kobo and its very strange, I can not set 57600 while the bluefly is connected, I require to unwire the tx. then when i set 57600 with the bluefly disconnected it then sets the required baud rate, when it is wired back in again something automatically changes the baud rate to 115200..... any ideas what is doing this ? thanks

    ReplyDelete
    Replies
    1. I do not understand if you mean that the baud rate on the BlueFly is changing, or the baud rate on the Kobo. If it is the BlueFly then the only way to change it is to send the BR2 command as described in the manual. If it is on the Kobo then I have no idea.

      Delete