Scooterputer

I spend a fair amount of time zipping around town on my scooter, and thought it would be cool to add a voltage monitor to warn when the battery might need recharging. Waiting until the electric starter no longer works is somehow lacking. So after an evening with an Arduino Duemilanove, I had a simple programmable voltage divider with 3 LEDs indicating battery low, good, and charging. Done.
That's when I saw Liquidware's very cool TouchShield Slide OLED display with touch screen. It was telling me it wanted to be on my scooter. It's a bit overkill for just battery status, so I added temperature and time/date readouts. I went to Sparkfun.com and found a DS18B20 temperature sensor and a DS1307 RTC chip. Perfect. Oh wait, what's this...an accelerometer? Sweet! Hey, a GPS chip...
So a few weeks later, here's what my battery voltage indicator is looking like:

You can see in the first photo that the TouchShield display is separated from the Duemilanove / Cell Module / Sensor shields. These are installed "under the hood" of my scooter and provide power and signals to the display module via a standard 8-wire ethernet cable. This keeps the sensors (accelerometer, GPS, cell module, etc.) with the scooter making it functional even without the removable external display, as we'll see later. (NOTE: this photo was taken before the display was fully mounted inside the enclosure, and is shown without the protective rubber boot.)
Features
- Battery voltage indicator
- Time and date
- Temperature
- Lean gauge with resettable max L-R indicators
- Current speed
- Resettable max speed indicator
- Odometer
- 2 resettable trip meters
- Latitude and longitude readouts
- Compass heading readout
- GSM/GPRS quad-band cellular module
Schematic

Sensor Shield
The sensors are mounted on a Proto Shield PCB from Ladyada's Adafruit Industries (which is also where I get my Duemilanoves). Most of the wiring was done using 30 gauge Kynar solid wire, with heavier gauge used for some power and ground connections. Good mechanical connections are important considering the shock and vibrations this will be subjected to.
Sensor Shield - Top

Sensor Shield - Bottom

I went with breakout boards for the surface mount chips. They take up a bit more real estate on the PCB but are very easy to solder and save a lot of construction time. Note the DS1307 RTC on the underside...the profile is still low enough to allow the parts to fit nicely in the open space between boards when stacked. I soldered a right-angle pin header directly to the pads of the GPS breakout board, and straight pin headers on the others.
GPS/RTC Breakout

You might be wondering why I even included the RTC chip since time-of-day and date can be gotten from the GPS data. The DS1307 RTC chip also has 56 bytes of non-volatile RAM. I'm using these registers for storing the trip meter and odometer values so they can be restored between power cycles.
The GPS uses pins 0 and 1 for its TxD and RxD signals to communicate to the Duemilanove. The TouchShield Slide also uses these pins for downloading sketches. The "Program Switch" is used to disconnect the TouchShield Slide from these pins when not downloading so they're free for use by the GPS. Fortunately the TouchShield Slide uses pins 2 and 3 during normal operation, which I'm driving with digital I/O pins 4 and 5 on the Duemilanove.
Three devices require serial communications (GPS, TouchShield Slide, and Cell Module), and it was a real challenge getting the Duemilanove to support these at data rates needed for the desired performance. Having the GPS, running at 9600 baud, use the hardware serial port (pins 0 and 1) proved to be the best approach. The TouchShield Slide (19200 baud) and Cell Module (4800 baud) use digital I/O pins, and Mikal Hart's NewSoftSerial library for 'software' interrupt driven serial communications was invaluable in getting these to play nicely together.
The GPS chip is powered by the 3.3v regulator. The 10k resistor and 1N914 diode circuit on the serial RxD line of the chip are used to dampen the 5v signal from the Arduino hardware TxD line used to send data to the chip. When that line is high, the diode doesn't conduct allowing the 10k pull up resistor to apply a 3.3v high to the GPS RxD input. When it's low, the diode conducts and the line sinks through the TxD driver pulling the line down. The .7 volt drop across the diode is still sufficient for a low to be recognized by the GPS RxD input. A schottky diode with a .2v drop might be an improvement here, but the 1N914 seems to work fine. The GPS is rarely receiving data anyways - data is usually sent only one time to initialize the NMEA sentences to be sent, the baud rate, and the update cycle rate.
Display
The TouchShield Slide is mounted on another Proto Shield PCB. The CAT-5 connector is wired to the PCB using solid telephone wire to provide power and ground, and to connect the RxD and TxD signals from the Duemilanove to the display. Another line is brought up to drive the beeper.
Display Shield


The display assembly is mounted in an enclosure I found at boxenclosures.com, part #40-12-NO-R-BL. It's a perfect size for the TouchShield Slide, once the inside bosses were removed with a Dremel tool. I cut out an opening for the display/touchscreen using a plastic cutter tool, and added a 1/16" gasket I cut from a sheet of neoprene to seal it.
Box Enclosures also has a nice protective rubber boot for the enclosure, which is shown in the scooter photos below.
Display Enclosure With Gasket

Cell Module
The SM5100B GSM/GPRS Cell Module just needs a SIM card and antenna. The antenna can be obtained from Sparkfun.com and attaches to the wire with the red cap covering the connector.
Cell Module

The Cell Module shield and Sensor shield plug in to the Duemilanove, stacked one on the other. The Duemilanove is programmed to reply to text messages made to the cell with a return text message containing latitude/longitude data, heading, speed, and a time stamp. The GPS latitude and longitude coordinates can be entered online to see the location on a map, such as using touchmap.com. I can also use this to capture my precise location when riding in an unfamiliar area. One of the spare buttons on the display could be used to tell the Scooterputer to text a cell phone with this information.
The Duemilanove is also programmed to send the text message to my cell phone when it initializes. This serves as kind of a scooter "LoJack". If the scooter is ever borrowed without permission, it will notify me each time it starts, and as long as it is running it can be texted to obtain its present location. Recovery and bad-guy-in-jail are just a text message away. Of course now my wife can text my scooter any time she wants to find out what I'm up to (note to self: add a pass phrase to the incoming message).
I also have it programmed to forward any incoming calls to my personal cell.
The display is not needed for any of these features. Also note that the Cell Module is optional. The Sensor shield can be plugged directly into the Duemilanove if the telecommunication features are not desired.
Duemilanove/Cell/Sensor

Calibrating
Very little is needed for calibration. Check out the source code to see how simple it is. Debug #defines are included to selectively send the sensor values to the Arduino serial monitor during operation. The scaling and mapping can then be tweaked as needed while observing the output.
The ranges for the accelerometer readings are easily obtained by analyzing the analog input data. I found full range to be 453 to 580 for both the X and Y axis, which is 127 units with a center around 516. I arbitrarily took 20 off each end and mapped these to -90 to +90 for the Lean Gauge values.
The Lean Gauge display is designed to show the current real time values in bright green, and the max L-R readings are maintained on the background in dark green. These can be reset by pressing the Lean button on the display.
The Battery Voltage Indicator ranges were set by varying the voltage applied from a bench power supply. The top of the indicator is calibrated to 14.0v and the bottom 10.0v, again by mapping the values coming in the analog input to the 0 - 100 range expected by the Battery Voltage Indicator. With a strong battery, at idle the indicator floats within the green zone and at speed it just gets into the orange. When the battery is weak and the indicator falls into the red zone, the red area flashes at a 500 msec rate from bright red to dark red.
Calibrating The Battery Voltage Indicator

The Haversine formula is used to calculate the distance traveled for the odometer and trip meters, using lat/lon data returned from the GPS. This seems to track the odometer on the scooter fairly close as long as I'm not riding in tight circles or zigzags. Since I don't ride while intoxicated, this should work fine for the trip meters but I have my doubts about the long term accuracy for use as an odometer. Time will tell, and I expect I'll be tweaking the algorithm to calibrate for improved accuracy.
As an alternative, I experimented some with a hall-effect sensor triggered by a magnet attached to the wheel. I'm confident this would be very effective as a speedometer and odometer, but have decided to go strictly with the GPS for now. If you're interested, let me know and I can post the hall-effect sensor circuit and sketch. (Update 08/25/2010: added link below to circuit diagram and test sketch)
Source Code and Antipasto IDE
Scooterputer.zip - sketches for Arduino Duemilanove and TouchShield Slide
Liquidware Antipasto - Antipasto Arduino IDE (supports Arduino Duemilanove and TouchShield Slide)
HallEffectSensorTest.zip - circuit and test sketch for Hall Effect sensor
Scooter
Scooterputer Mounted Under The Hood

Scooterputer Mounted Under The Hood

Scooterputer Display with RAM Mount

Scooterputer Display

Scooter Walkaround
Links
www.arduino.cc - start here
www.adafruit.com/ - get lots of great Arduino stuff here. Ladyada rocks!
www.liquidware.com - TouchShield Slide
www.liquidware.com/antipasto_arduino_ide - Antipasto Arduino IDE
www.sparkfun.com - components: accelerometer chip, GPS chip, RTC chip, temperature sensor, cell module, and much more
www.boxenclosures.com/index.html - nice project cases
arduiniana.org - NewSoftSerial and TinyGPS libraries. Mikal rocks too.
itouchmap.com/latlong.html - mapping GPS coordinates
www.hhhh.org/wiml/proj/nmeaxor.html - NMEA sentence checksum calculator
www.movable-type.co.uk/scripts/latlong.html - useful latitude/longitude formulas
www.ram-mount.com - mounting systems for cars, motorcycles, scooters, ATVs, etc.
www.genuinescooters.com - awesome scooters!
Scooterputer is a trademark of Schulz Design
77 comments
Well done sir.
Thanks!
@Christian
Thank you. My scooter is a Buddy International from Genuine Scooters: http://www.genuinescooters.com/
How graphics is made ?
Are you using an OS ?
Thanks !
Thanks. The TouchShield Slide supports something called the SubProcessing Graphics API which has primitives for drawing lines, circles, text, etc. I used this API to draw the display.
@John Boxall
Thanks for the comments. And I sure hope I don't either. More likely that I'll find the display gone one day :(. Not that it would do anyone any good. Unless they have an Arduino....
I'm especially interested in the lean gauge, but I wonder if a lean gauge based on an accelerometer gives you correct values. If my understanding of physics is correct, the center of gravity of a two-wheeled vehicle must always be between the weels, otherwise you fall over. After all, that is why you lean in a turn.
In my theory the resulting force should always point more or less in the direction of the wheels. Only if you "hang-off" you like a racer would get a positive lean value and if you "push" the scooter you should even get a negative lean value (to the outside of the turn). I think you would need a gyroscope to get the exact angle of the scooter relative to the road. What are your observations?
I'm asking because I planned to build something similar, but dropped the idea because of this consideration.
Oh and nice scooter, by the way. ;)
The Lean Gauge is pretty bouncy right now, and seems overly sensitive. I'll be making software changes to dampen it some. It does register in the turns, but not what I expected and I hope I can make it work better after some tweaking. Ultimately you may be right in that the accelerometer is not the best solution. To be honest my true objective was to get some hands-on with the accelerometer, and not so much to make the perfect Lean Gauge as it's really not so useful.
@Gyzmau - thanks!
@QuantumRift
I haven't added up the parts cost, but should be easy to do with a run through Adafruit, Liquidware, and Sparkfun web sites where I got most of the components. Putting together the hardware was about 10% of the time - writing the code by far took the most amount of time. Lots of evenings.
@Steve
Thanks, um, a beer please. Lager or IPA. :-) I checked out thescooterscoop.com - very cool site! Thanks for linking and the write up - I owe you a beer.
Awesome! I can't wait to build one for my vespa.
I had to compute the distance between two points a while back and used the below code. With my GPS it was accurate to about 5 meters and worked in both hemispheres.
#define EARTH_RADIUS 6371.01f
#define DEG_TO_RAD 0.0174532925f
float dist = gcd( flat * DEG_TO_RAD, flon * DEG_TO_RAD, targetLat * DEG_TO_RAD, targetLon * DEG_TO_RAD );
float gcd(float lat_a, float lon_a, float lat_b, float lon_b) {
// haversine formula
// see http://en.wikipedia.org/wiki/Great-circle_distance
float d = 2*asin( sqrt( sq( sin( ( fabs( lat_a - lat_b ) ) / 2 ) ) + cos( lat_a ) * cos( lat_b ) * sq( sin( ( fabs( lon_a - lon_b ) ) / 2 ) ) ) );
return fabs( EARTH_RADIUS * d );
}
@jaybuff
I think your original comment was a casualty of the anti-spam filters - so sorry for that. I've copied the content back here. Your haversine formula is very much like mine. I just need to optimize how often to aggregate position samples to get the most accuracy. Thanks for your comments!
Good to know I'm on the right track. Thanks.
@jimmy
The DS1307 RTC chip has 56 bytes of non-volatile memory. I'm using some of this to store the odometer and trip meter values. See the specs for the Arduino Duemilanove ATmega328 for on-board FLASH, SRAM, and EEPROM.
visually, it looks pretty nice. congrats.
do you travel with the hood open or not? it may prevent the signal and rain can destroy the circuits.
The hood is always on when I ride, and it keeps everything dry and happy.
keep up the good work, and ride safe.
Thanks! Go get a Genuine Scooter! You won't be disappointed.
@axilus
Thanks man!
@Nate
Thank you sir. See my reply to QuantumRift above on the cost and time. Of course you can download my source code as a starting point, so that should save a LOT of time.
good job!!!
I don't see any import from one to another. You use the TS to send all data to the LCD but when are the graphic libraries used?
Best regards!
Eduardo
All of the parts can be found using the links provided in my post. Adafruit and Sparkfun are where most of the electronic components came from, and you can get the TouchShield Slide display from Liquidware. I've had many requests for a parts list - I will try to post one soon. Thanks for the comment!
@Eduardo
One of the cool things about the TouchShield Slide is that it has its own processor dedicated to driving the display. It runs the SubProcessor Graphics API which supports a library of graphic primitives (lines, circles, text....) you can use for drawing, It also supports two serial interfaces - one for downloading sketches and the other for exchanging data with the Arduino.
The Scooterputer_TouchShield sketch I wrote runs on that processor. The Scooterputer_Arduino sketch running on the Duemilanove periodically sends a list of all the sensor data values to the TouchShield Slide using the TS serial interface. The sketch running on the display receives that data and uses the graphics API to translate it to the display.
The Antipasto IDE from Liquidware is needed to develop sketches for both the Arduino and the TouchShield Slide.
In USA - http://www3.towerhobbies.com/cgi-bin/wti0001p?&I=LXHHS2&P=ML
In UK - http://www.cmldistribution.co.uk/cml_product.php?productId=0000004625
I have to agree with you regarding the problems of using an accelerometer for the lean gauge application. To date I haven't been successful getting the desired results and will be experimenting with a gyro. Thanks for all your input on this - much appreciated.
Please shoot me e-mail if you are making and selling these. You could make a mean profit.
Thanks!
Some modifications to the project would make it just about perfect for many ebikes, potentially as a replacement for the Cycle Analyst's display portion, if the Scooterputer could read the CA's logging output and then track/display that data in easy-to-read-on-the-go GUI format.
Most of the data the CA is designed to track is power usage of the bike's traction battery pack, and that would be handy to have some of in a GUI format rather than a text-only display (which is all the CA has).
If reading the CA's data, no external sensor is needed for wheel RPM, as the CA already has that, too.
The CA is made by Grin Technologies, at http://ebikes.ca if you want to take a look at it. Justin there is it's creator, and is very helpful if you had any questions, should you decide to pursue the idea I suggest above.
If you don't pursue it, there are likely a few members of Endless Sphere ebike forum at http://endless-sphere.com/forums/ that would be interested in doing so. That's where I found your project, linked from this thread:
http://www.endless-sphere.com/forums/viewtopic.php?uid=13812&f=2&t=19737&start=0
Adding to 'will buy' list. Thanks for stopping by!
@Michael "Amberwolf" Elliot
Thanks for the info on the eBikes. I read the links and took a look at the CA - all very interesting. With a few modifications I agree the Scooterputer could be a very useful option. I'll definitely be keeping this in mind as I work on the next version. Just waiting on parts to arrive...
You can get an idea of the cost by going to Sparkfun, Liquidware, and Adafruit and adding up the prices of the components shown on the schematic. I plan on posting a BOM with $ once I'm satisfied with the final design (is there ever a 'final' design?).
@EVERYONE
The source has been updated. Fixed: scaling problem with Heading value; improved response of Trip Meter reset button presses; tweaks to accumulated ODO and Trip Meter values. NOTE TO LIQUIDWARE - request enhancement to the touchscreen API. Need function to return touch state (touch / no touch).
I created the schematic using PaintShop Pro, with extensive use of its layer features.
Answers appreciated.
The best deals I've seen for pre-paid SIM cards are on Amazon or eBay for ~$25/90 days, no minimum usage. Try searching for something like "pre-paid AT&T SIM card GPS trackers". Hope this helps, and thanks for the feedback.
I really like protected display enclosure and the idea to separate display from the rest of electronics that keeps working without it.
What is the current draw in standby mode, without display?
I would also protect the electronics from the moisture too. Very important if you catch some rain from time to time.
What are your future plans for this project?
I got very excited when I saw your project. I am a scooter enthusiast (Yamaha Zuma) and I am currently doing some performance upgrades on my scoot. I am going to add tachometer and a cylinder temperature gauge. When I saw your project, I thought it might be possible to replace my dashboard entirely.
You seem to have a good knowledge of both scooters and electronics, so I would like to ask you if you considered using the speedometer and odometer of your scooter, which I believe are mechanical, instead of using GPS?
Thanks for the comments. Currently I'm refining this prototype design, adding features based on feedback I've received and steering it towards a more economical and manufacturable offering. I'll post more on this later, including more detailed specifications (such as power requirements).
@Stan
Thanks for the great feedback. The problem with mechanical speedos on scooters (and I understand the same is true with motorcycles) is that they're notoriously inaccurate. The indicated speed is always higher than actual, sometimes by as much as 15%. I've read (but not confirmed) that this is done intentionally - reportedly some studies have shown it reduces accident rates. Don't actually know if any of this is true, but nonetheless I'd like to know what my true speed is. BTW, the new design will have inputs for a hall effect sensor to use for Speed, ODO, and Trips as an alternative to the GPS. Also adding a tach.
Thanks for the reply.
Tach and Speedo will be great!
As for the accuracy of speed, you are right; the manufacturers are required to be in the 10% tolerance and everyone bumps up their gauges. My scooter's (Yamaha Zuma) speedo, curiously, was almost 100% in sync with a GPS speedo I used to compare the reported speed.
I think as an alternative to Hall Effect sensor you might use a magnet sensor; TrailTech has some (http://trailtech.net/vapor_vector_speed_sensors.html) -- I will be installing one soon.
Your project is truly great, and I am tempted to try to build the scooterputer (catchy name, too!) myself, even I have only used the soldering gun to patch wires.
I've heard of another reason speedos indicate high, which I believe makes some sense - apparently the DOT imposes heavy fines on imports whose indicated speed reads below actual, but they allow a certain percentage over. So 2-wheel manufacturers intentionally design their speedos to be optimistic (high) to reduce the risk of getting hit with penalty fees.
Regarding the magnet sensor, you're absolutely right. The hall effect sensor IS essentially a magnet sensor - it varies its output voltage in response to changes in magnetic field (i.e. a magnet mounted someplace on the wheel passing by it). It's what TrailTech and Acewell use. Time to get that soldering iron heated up! ;-)
The analog pins can be configured as digital I/O. Arduino has a library called Wire that implements the I2C protocol used to talk to the DS1307. Wire uses analog pin 4 for the Serial Data (SDA) connection and analog pin 5 for the Serial Clock (SCL) connection: http://www.arduino.cc/en/Reference/Wire
I have a question about the gps receiver. Do you get a good reception from the antenna inside the "body" of the vehicle, or do you have an external antenna as well?
Actually I've been amazed at how well this GPS receiver works, and how quickly it acquires, using only the built-in antenna. I've had no problems using it indoors or under the hood of my scooter. I tried a smaller unit (SUP500F) and found it does not perform nearly as well as the Locosys LS20031.
Great project!
you mention you can post the sketch and circuit for your hall sensor odometer/speedometer, can I have a copy please?
Thanks
I love the the display part. I'm workig on something similar but using 4D Systems (uLCD 32 PT) which is much cheaper solution. Anyway, my display is "connecting" through a wireless serial conn (xBee) to a 4WD robotic platform and should do almost the same things with yours + control the direction and sending back various commands for navigation, etc. I'm also using almost the same stuff like you did (accel, gps, etc)but entire project is custom made: shields, microcontroller, etc.
Anyway, great job! Very nice and well presented tutorial! Your project is really a great source of inspiration for me ^_^
Thank you. I'm going out of town now for the weekend - a scooter rally :-) - but I'll send you the Hall Effect sensor info when I get back.
@gclaudiu
Thanks for the comments! Sounds like a great project you've got going, very cool. Good luck with it!
Great project.
Send me email desso@bintoro.net or dessobs@gmail.com
Thanks
Desso
by
Zebros India
www.zebrosindia.com
Thanks man. I'll definitely notify you when the new design is complete.
@Ashok Kumar
Thanks for the feedback!
Added link to the Hall Effect sensor circuit and test sketch under the Source Code And Antipasto IDE section. The sensor is connected to digital pin 3 which supports interrupts. I'm using an Electrosport Industries Acewell Universal Speed Sensor Cable.
Thank you for sharing you work and for the hall effect post!
Elia
Reading your source I was able to understand most of what I did in my solitary experiments. You are my hero!
I'm starting now (Arduino & TouchSlide).
I would like let me ask you a question while I understand that the level is too advanced for me: how can I disable the event handler of a button?
I want to get an "multi pages" interface.
In a barbaric manner i can move buttons "out of the screen" but I'd like to understand how to use only what I need on every screen.
I realize that I'm trying to learn starting from the wrong side, I trust in your mercy:-D
For me is useful a basic indication too.
I will estimate you anyway!!!
P.S. excuse my English :-D :-D
Thank you, my friend! If I understand your question, one thing you could do is change the button handler depending on which screen the user is viewing. Buttons are instantiated in the "Screen Objects" section of the code. The event handler could be temporarily disabled by changing the ButtonObj *MouseHandler( ) member to point to a null or empty function, and reset it back to the valid handler based on the current screen. Or possibly leave the existing handlers in place but check which screen is being viewed at the beginning of each handler and return immediately if no action is desired. These assume of course that you add some way to keep track of the screen being viewed, and you'll probably want something like separate DrawScreenABC( ) and DrawScreenXYZ( ) functions. Thanks again and good luck with your project!
and what if i want to the mph to get the readings from the speed sensor that built in the scooter and to add tachometer function to it?
Yes, I'm getting the MPH from the GPS data. I haven't looked at how to interface to the speed sensor built in to the scooter. I would imagine that varies across various models of scooters. As noted in earlier posts, I've added a hall effect sensor that detects a magnet attached to the wheel, counting pulses to calculate MPH and miles traveled, which is a very common method. I've also added an ignition pulse detection circuit to get RPMs. I'll be posting on this new version soon - just waiting on PC boards.
I actually like the paint job on your Vespa. I hope you get the engine running again soon. Good luck with it!
Thanks!
Right now I'm using a SIM card from a phone I had through my cell provider. This was part of a famiily plan I still have which keeps the SIM active. The best deals I've seen for pre-paid SIM cards are on Amazon or eBay for ~$25/90 days, no minimum usage. Try searching for something like "pre-paid AT&T SIM card GPS trackers". Hope this helps, and thanks for the feedback.
http://www.sparkfun.com/products/9070
I'm really interested in displaying lean angle as well....and I have a Burgman AN650.
Interesting gyro - I like the idea of two sensitivities for faster and slower motions. Not exactly sure how to get an accurate instantaneous lean angle from a motion rate value...might have to get one of these to play with.
Thanks
Congrats,
BR,
Rany.
Comments are not allowed from anonymous visitors.