May 04, 2019
In this post I will cover the history of developing the hardware solution for my scooter share app.
Related Links:
Hardware repo containing all files used in this post.
Link to video guide for embedded solution coming soon…
There are two main challenges that I faced in developing my dock-less scooter hardware, tracking and security. Depending on how completely you want to solve these challenges, will determine the approach you take towards implementing a solution.
Tracking:
Security:
I can solve the challenge of tracking though the use of a combination of GPS and a cellular data connection. Below is three methods for tracking, in practice I will be using a combination of two or more of these methods.
This method uses a device embedded onto the scooter. The device requires at least a GPS module, GPS antenna, and a cellular data connection to upload the scooter’s coordinates to our server.
Pros:
Cons:
Via the HTML Geolocation API I can request the location of our users. The idea is that I would start tracking once a scooter is checked out and stop once the ride ends.
Pros:
Cons:
A device which has a cellular connection can preform a rudimentary form of tracking by triangulating it’s location in relation to nearby cell towers.
Pros:
Cons:
There are two methods for hopefully keeping the scooters a bit safer.
I want my device to be able to ask and answer this question, Is someone riding me or moving me without permission? The first requirement to answering this question is that my scooter needs to be able to detect motion.
Some methods to detect motion:
Once the device has detected motion, it will check its lock status, if unlocked do nothing, otherwise sound an alarm.
I will lock my scooter by disabling the throttle, in affect acting as a remote kill switch. For this to work, my scooter will have an embedded micro controller which will connect to the throttle of the scooter, and control access to it.
There are several methods that I can provide for a user to unlock the scooter:
Unlock via web app
Keypad Unlocking - Turning throttle on or off via keypad on scooter, user would have to enter an unlock code generated by our web app.
BLE Unlocking - Turning throttle on or off via bluetooth, in effect I would use the user’s bluetooth connection on their phone to control the throttle on the scooter.
Now that I have my solutions researched, how can I implement the solutions in practice? In the end I came up with two separate hardware solutions,
The beauty of this option is that you probably already own all the required hardware to test it out. All you will need is a cell phone, preferably one you would not mind losing. Modern cell phones are incredible devices, and they contain a multitude of sensors and processing capacity. Specifically phones provide a lot of the hardware capabilities that I am interested in for my scooter.
Phone Hardware | Specific Requirement | Project Feature |
---|---|---|
GPS radio | Location tracking | Tracking - Embedded |
Cellular connection | Data Transfer | Tracking & Security |
Battery | Remote Operation | Tracking & Security |
Processor | Handling App Logic | Tracking & Security |
Speakers | Alarm | Security - Alarm |
Accelerometers | Detecting motion | Security - Alarm |
One requirement you will not see in the table above is locking.
I can approach the locking issue in one of several ways:
After some research, I ultimately chose that I wanted to go down the route of adding another device in addition to the cell phone. figure out the locking capability. I will be using the ever popular ESP8266. I chose the ESP8266 because it is, cheap, popular, and includes WiFi connectivity.
Old, used Android phone, or cheap new one.
A water proof plastic project box and mounting hardware.
For my SIM card, I am using a spare Freedom Pop SIM. Freedom pop offers limited data plans, some which are free if you do not go over your data cap. Since my scooter’s cell phone will use very little data, I shouldn’t have a problem staying within FreedomPop’s free tier.
The first step I took was to reset the phone, so that it does not contain any personal data. I also created a throwaway email account for my scooter, because I needed an email address to be able to download apps from the play store. For tracking, I used google’s built in find my phone feature.
The next step is to install the Automate app, this app allows to you to create “programs” (they are called flows in the app) to automate different features of your phone. Using Automate’s visual flowchart interface, I made a simple flow that will handle the logic for my scooter, you can find a copy of the flow here
When it detects movement via the phone’s accelerometer:
My endpoint responds with true or false, letting our phone know if the scooter has been checked out.
If the scooter has not been checked out,
If the scooter is checked out,
The phone and esp8266 will communicate via an Ad-hoc WiFi network. The esp8266 will act as an access point which the phone will connect to. Also the esp8266 will serve up a simple web server with which the phone will be able to send requests to.
Creates a simple web server with two endpoints.
http://{esp8266’s IP address}/on
— send high power to pin SD3 (known as pin 10 in code)http://{esp8266’s IP address}/off
— send low power to pin SD3The actual model of esp8266 I used differs from the one in the diagram, so pin layout may vary. The 4n35 optoisolator needs a 470 Ohm resistor connected pin 1, the other side of the optoisolator interrupts the positive wire from the scooter’s head unit to the scooter’s throttle.
You can consider the LED as a stand in for the throttle in this setup. Since the LED is on, the scooter would be unlocked.
The scooter in the photos is a cheap kick scooter for testing purposes. To test the throttle locking function I would need use an electric scooter, and I would need to route wires from the scooter’s head unit and throttle. Both the phone and esp8266 test rig are inside of the box.
The project box is comically large because it is needed to hold my large phone. A smaller phone would be a better choice.
The minimal effort option does work, I was able to get it to detect motion, control the alarm, lock status, and communicate with my API. Not a bad result for a mostly broken phone and a $5 micro controller. However I didn’t bother thoroughly testing this solution. I assume that I would have issues with battery life, managing sleep states and software stability. This option was a fun experiment in seeing how far I could go, without out putting much effort into the setup
For the embedded option, I made a video (coming soon) explaining how I put it together. The material below is written as supplementary material for the video, rather than an overview.
Using off the shelf components, I will be putting together a custom device purpose built to work with my application. The embedded option is attempt to create a solution that would be somewhat plausible to deploy to actual customers. However there are certainly a lot of improvements that could be made.
Pros:
Cons:
Main Loop:
Check if scooter has been has been unlocked longer than the ride time limit.
Check for movement,
The particle electron is hidden to show the wiring.
I cut the traces on the bottom of the board for:
A blog about Creatures an open source scooter share project
Started by Joshua Sheridan