Home > General > Bluition

Bluition


 

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.

 

Tools

  • 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

 

Time

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.

Wiring

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 StartScooter.py.

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..."
droid.toggleBluetoothState(True)
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..."
droid.bluetoothWrite('$$$')
res = droid.bluetoothReadLine()
print res

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

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

print "Sending starter on command..."
droid.bluetoothWrite(STRT_ON)
res = droid.bluetoothReadLine()
print res
time.sleep(1.7)

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

droid.bluetoothStop()

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!”

.

About these ads
Categories: General
  1. 18 June 2012 at 4:42 PM

    Awesome project, Brad. If you are ever in the San Francisco area, look us up and come check out our smartphone activated scooters. A demo video is here http://bit.ly/scoot_video.

    -Michael

    • 18 June 2012 at 5:12 PM

      Great idea for a startup! Notably missing, however, was the Android compatible scooter. Not that I have a bent ;-) Hope it’s on the way.

  2. 19 June 2012 at 10:13 AM

    I’ve been considering doing something similar to automate pushing the switch for the ceiling lamp in my dorm room-like student apartment. I’m already using Tasker like crazy and use it to turn off my computer monitors when sleep mode is activated (= the phone is plugged into AC). I thought my best bet would be an Arduino to control a solenoid, which would have been a much more expensive solution that this. I would probably need about $50 worth of parts using the same parts you’re using, which isn’t too bad, but I’m not sure if it’s worth it to not push a light switch I’m going past anyways xD

    Anyways, great job, made my day seeing a project so similar to what I’ve been contemplating doing for a while.

    • 19 June 2012 at 10:22 AM

      Yeah, I’ve considered close to the same thing … I’d like to use it to turn the lights on and open the drapes as part of my morning alarm (which I’m already using Tasker with text to speech to tell me what I’m risking by sleeping in, and then turn on a playlist or Pandora).

      That’s a big part of why I posted – it’s a wall wart, the RN-42, a MOSFET, and a Relay if you just want one location. $5 + $16 + $2 + $3 = $36 project for a single relay that’s wirelessly controlled from my smartphone! You could flash the lights anytime you got a text or email. Oh, the possibilities :)

      • 20 June 2012 at 11:14 AM

        My setup would require at least one solenoid as I don’t want to risk modifying anything, and need it to physically push the wall switch. One unannounced visit from the management (they don’t know the word “privacy”) and I’m in trouble.

        Ironically it seems like our morning Tasker setups aren’t too far apart. Mine writes %TIMES to a variable when sleep mode activates and then calculates how long I’ve slept in hours when I wake up. Aside from having that as part of the text to speech, it adds “you lazy bastard” if I sleep for more than 9 hours.

    • peter Hardy
      23 June 2012 at 4:36 AM

      I’m just putting the finishing touches on something very similar to this. Ripped the guts out of a table lamp and installed a high power LED controlled by an arduino and bluetooth module. I’ve even got a similar python script being run by Tasker. It’s a lot harder to sleep through my alarm now that it’s accompanied by a light flashing on and off for a minute or so. :-)

  3. rey
    7 September 2012 at 10:28 AM

    do you have this for a Iphone 4, i could use this in my truck to open my push botton door where i have my shifter hitten, and start my street road.

    • 21 April 2013 at 10:34 AM

      Wow, missed a slew of comments here … Sorry!

      iOS unfortunately is a bit more restrictive than Android, so because of my hacking nature, I have avoided Apple products pretty completely. It’s possible, but probably would require a lot more effort and a developer account.

  4. max
    21 September 2012 at 4:50 PM

    no good at electrical schtuffs, but im very good at following diagrams or schematics, can you post a schem of how all the little electronic bits are wired together?

  5. Jesus
    12 November 2012 at 2:55 PM

    Congratulations for your project!
    For a beginner like me it is complicated to put all together (Tasker-SL4A-Python)
    I have tried to follow the steps, but I’m unable to make it work with Tasker.
    Can you attach the files or configuration you are using?
    Thanks in advance.
    Jesus.

    • 21 April 2013 at 10:40 AM

      Not aware if it’s possible to attach a Tasker configuration, but I hope this helps.

      In Tasker, I have a profile for each action: start scooter, stop scooter, and pop seat. For start scooter, the profile event is triggered by a “Shake” event, with Axis set to “Up-Down”, sensitivity set to “High”, and duration set for “Very Long”.

      Then the “Start Scooter” task that gets called is just a “Run SL4A Script”, which is pointed at StartScooter.py.

      I’m sure you’ve probably got past it by now, but if not good luck! Let me know if you get it going, I’d love to see how you implement it.

  6. Jesus
    22 April 2013 at 12:36 AM

    Hello Brad.
    I will try it and comment results.
    Thank you.

  7. Jacob
    17 December 2013 at 4:26 PM

    What was the MOSFET here used for? Was it just to take the 3.3v from the RN-42 and step it up to the 5v the relay wants?

    • 17 December 2013 at 5:27 PM

      That’s correct. I don’t recall the RN-42 GPIO current capabilities off the top of my head, but it was very low. I just used whatever transistor I found lying around, I didn’t spec it specifically for this project. Any transistor that will work with a gate voltage of 3.3V, handles 5V on the high side, and can safely push at least a couple hundred mA should work fine.

  1. 18 June 2012 at 3:03 PM
  2. 20 June 2012 at 7:01 AM
  3. 20 June 2012 at 7:15 AM
  4. 20 June 2012 at 11:21 PM
  5. 22 June 2012 at 12:56 AM
  6. 12 September 2012 at 7:30 AM
  7. 22 December 2012 at 7:18 AM
  8. 22 May 2014 at 6:30 AM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: