Archive for June, 2012


14 June 2012 21 comments


I’ve Made Some Special Modifications Myself

My current mode of transportation is a quasi-beat up, hot red Kymco ZX50 scooter.  Let’s face it – if it doesn’t look like much on the outside, you’d better make some special modifications yourself.  In comes Bluition.


The Run Down

Bluition is a bluetooth ignition device that allows me to control my scooter from my Android phone.  Here’s the run down:

  • My Droid 4 runs a program called Tasker.  Tasker is an AMAZING program that can run applications or other actions given specific events or states.  I’ve put instructions for it to call a specific Python script given a specific gesture is detected.
  • Python for Android provides a very simple scripting system.  It was amazing how few lines of code were needed to open up a Bluetooth connection and send commands to the bluetooth module on the scooter.
  • An RN-42 Bluetooth module from SparkFun receives the commands from the Android phone.  The commands include instructions to set GPIO pins high or low.
  • The RN-42 outputs are then connected to MOSFET drivers, which in turn drive mechanical relays.  Again, SparkFun parts.
  • The mechanical relays are connected into the scooter ignition, starter as well as a solenoid that pops opens the seat lid.
  • The solenoid was purchased from SparkFun also.  While it provides precious little force, I managed to eek just enough out of it to pop the scooter seat lid (which encloses the glove/helmet storage compartment) by connecting the solenoid plunger to the connector up through a bowden cable.
  • And foot bone is connected to the knee bone…

The setup was pretty simple and done dirt cheap – see the bill of materials below.  My favorite part was that I didn’t have to use a microcontroller.  As much as I love microcontrollers (my day job is firmware programming), it was nice for a change to be able to just focus on electronics and wiring.

This setup could be used for just about anything that just needs an on/off relay with the actual programming to a smart phone.  I’m sure if Han had one, he’d totally be scripting his droid to automatically control a mog feeder on the Falcon.

In the interest of time, I’m not going to fully comment how I made it.  If there’s enough interest (leave a note in the comments), I’ll draw up an Instructables tutorial on how to connect it and possibly even make pre-assembled kits.  Hopefully I’ll give you enough info below that if you have some experience you should be able to put it together without much trouble.


Bill of Materials

Let’s start with a BOM.  Links provided where available.  Some components were just lying around.  My SparkFun order for the parts I didn’t have was only $50, but the total is probably around $75-$100.



  • Socket wrench and set
  • Socket drivers
  • Pliers (regular and needle nose)
  • Wire cutters & strippers
  • Crimp tool
  • Soldering iron
  • A butane soldering iron was particularly handy when soldering on the scooter itself (but there are other ways)
  • Phillips and Flathead Screwdrivers
  • Allen wrench set
  • Power drill and bits, preferably with a step drill



All told, I spent about three full weekends on this.  Now that it’s all figured out, if I had a PCB already built and the wiring diagram it would probably only take a rainy Saturday to do.


Build Pictures

Here are a few pictures that I took throughout the build process.  I have more, but these are a decent overview.


Build Notes

A few notes about individual items.

The Scooter

The goal was to keep the original scooter electrical setup intact so I’m not screwed if (when?) the electronics get a bad spike, water shooting into the console, etc. and blow up.  I mostly succeeded – at least I know I could use the scooter without the Bluition module if necessary.

Over half of the scooter exterior had to be removed in order to get access to all the wiring needed.  Things that came off: The front, the handlebar covers (still hanging there by control cables and wires, but all screws & bolts were out), the seat, storage compartment, carrier rack, and seat latch.


The wiring was pretty straightforward, except for the ignition.  I’m no grease monkey, so this is my simple interpretation of the mechanic’s manual and various forum postings:  +12V gets connected, obviously.  But there was another connection that was grounded when the ignition switch was in the off position, then left floating when in the on position.

My (frail) understanding is that it grounds the Capacitor Discharge Igniter, which removes sparkability from the spark plugs and forces the engine to die.  If I didn’t connect this, I could start the scooter but the engine kept running when the ignition signal was removed.  You’ll notice there’s an extra relay in the pictures that looks like it was added haphazardly as an afterthought – bingo.

The starter was simple – there’s a starter switch on the handlebars.  Simply used tap splices, and connected both sides to a relay in parallel with the starter switch.

The solenoid relay just sucked power from the +12V rail.  Easy peasy.

I ran a Bluition power switch (sealed rocker) up to the handlebars so that, when not in use, the Bluition module wouldn’t suck the battery dry.

Seat Latch Solenoid

This was pretty tricky.  It boiled down to lubricating the Bowden cable well with silicone grease, and getting the Bowden cable entry and exists as parallel as possible with the path of the solenoid and latch.  On the solenoid side, I removed the spring and plastic washer and put a ball of solder on the cable to hold it in place.  The extra-hot butane soldering iron was helpful with this.

On the latch end, after trying many approaches I ended up just zipper tying the cable to the existing key-triggered cable.  I also zipper tied the solenoid to the chassis outside of the storage compartment area, and zipper tied the Bowden cable itself to places where it held the cable in locations that allowed parallel entry into the sleeve.

Bluition Installation

Running wire all over and getting all the signals wasn’t too bad.  Labeling the wires as I ran them helped a ton.  It was really nice using the tap splices over soldering.

The module itself was installed in the “glove box” console area.  I mounted each component onto a plastic sheet using foam tape, and then mounted the plastic sheet onto the inside of the console.  I had every intention of using Sugru to encapsulate the module, and I may still do so.  But until I know it’s going to work reliably I’ll hold off.

RN-42 Bluetooth Module

I was blown away at how cheap this sucker was – and it worked like a charm too!  Dead bug soldering was a bit of a pain, but not too bad.  I’ll post a schematic at a later date to show which wires went where, but just look at the data sheet – any of the PIO pins 7 or below can be used.  I couldn’t get PIO pins 8-11 to work – the datasheet says some modules don’t have these, and I can only assume this is one of them.  They can provide a few milliamps each, but they work just fine driving the MOSFET gates with a 120 ohm resistor in series.


Python Environment and Code

First, let’s talk about the environment.  BTW, it was WAY easier to get things working here than it was on my laptop in Ubuntu.  Here are the Android apps that I’ve used to make things happen:

  • Tasker– This program automates your smartphone in so many ways.  I set it up so that if I shook the phone in one of three axes, a Python script that performed a specific action occurred:
    • Front to Back Shake: Start the scooter
    • Up and Down Shake: Stop the scooter
    • Left to Right Shake: Open the seat lid
  • SL4A: Scripting Layer 4 Android is a program that provides a common layer for many different scripting languages so they can be ported to Android.  Python for Android is an interpreter used by SL4A.
  • Python for Android – Python interpreter used by SL4A to let us run the scripts.

Now for the fun part – code!  I was amazed at how simple it was in the Python for Android environment.  I think you will be too.  Before starting, make sure you’ve paired your Android phone with the RN-42 module through the “Settings -> Wireless and networks -> Bluetooth” menu.

Then, you can run scripts like the following that open up a Bluetooth connection, then enters command mode, then sends a GPIO command.  Easy peasy.  The following script is called

import android
import time

droid = android.Android()

# Over-the-air commands that modify the GPIO pin states on the RN-42 module.
IGN_ON = 'S&,1808\r' 
IGN_OFF = 'S&,1810\r'
SEAT_ON = 'S&,4040\r'
SEAT_OFF = 'S&,4000\r'
STRT_ON = 'S&,9080\r' 
STRT_OFF = 'S&,9000\r'
INIT_DDR = 'S@,D8D8\r'
print "Enabling Bluetooth..."
print "Connecting to scooter RN-42 module..."
# Change the X's in the following line to match your MAC address.
droid.bluetoothConnect('00001101-0000-1000-8000-00805F9B34FB', 'XX:XX:XX:XX:XX:XX')

print "Entering command mode..."
res = droid.bluetoothReadLine()
print res

print "Initializing PIO direction..."
res = droid.bluetoothReadLine()
print res

print "Sending ignition on command..."
res = droid.bluetoothReadLine()
print res

print "Sending starter on command..."
res = droid.bluetoothReadLine()
print res

print "Sending starter off command..."
res = droid.bluetoothReadLine()
print res 


Just write up a script with the basics of the above script in it, run it in SL4A, and it will toggle GPIO pins on the RN-42 module.  See the RN-42 user’s manual for more info on the GPIO commands, and the Python for Android documentation for more info on the Android API.


In Conclusion

In the altered words of Jack Handy:”If you ever get the chance to choose between regular heaven and Bluetooth heaven, choose Bluetooth heaven.  It may be a joke, but if not, mmmm boy!”


Categories: General