This project consists of an electric longboard that retains the route with the help of a raspberry pi. These sessions are kept in a mySQL database and are displayed on my website that was made with the microframework 'Flask'.
(This is a school project that's made in 3 weeks)
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Materials and Tools
This project requires solder skills and it will cost around €500.
All the materials and links to the suppliers are in the Bill Of Material sheet.
- Soldering iron + tin
- Hot glue gun
- Screwdrivers and allen key set
- A pincet might come in handy sometimes
- Wire cutter/stripper
A lathe, laser cutter and 3D printer are used in this project!
Step 2: Changing the Wheels and Preparing the Truck
First of all, I took those small white wheels off my longboard. Then I removed the ball bearings and put them in the orange 90mm wheels.
The truck on which the motor will be mounted needs a small adjustment. The wheel with the gear wheel does not fit on the truck of the longboard that I had bought, so I had to cut about 1 cm with a lathe.
and mounted them on the trucks, except the wheel with the gear (I randomly chose the right, backside).
Step 3: Cutting and Welding Motor Mount
I made the aluminum motor mount with a lasercutter at the dimensions from the picture above.
The positioning of the mount is important. It needs to be angled down as much as possible without touching the board and since I a have a big motor, is the angle not that big. I happen to know a welder so at first he welded it a little bit and then to test the positioning, I pushed the trucks from side to side to see if it touched the board.
After my whole board was finished, I did a test ride and the motor mount broke loose so that explains why my motor will look damaged in the upcoming photo's ;) After that I asked my acquaintance to weld it completely.
Step 4: Mounting the Motor and Belt
Use 4 of the M4*14 bolds to mount the motor to the mount.
After that you have to fasten the 12 teeth motor pulley on the motor shaft. Make sure that the tiny bold is on the flat part of the shaft!
Now can you take one of the belts and put it around the pulley, take the wheel with the gear and turn it around until the whole belt is around the gear.
Tighten the nut to the truck so your wheel won't fall off and that's it.
Step 5: Wiring Diagrams
The electronics components were connected according to the diagrams above.
The first one is a complete schematic of te electronics.
The second diagram shows all the connections of the electric longboard part, the 6s UBEC to 12V goes to the next diagram. That diagram shows the circuit of the lights and sensors that are controlled by the raspberry Pi.
As you have probably already seen, the tft screen has a female header that takes up many pins. Pins that we need for serial communication with the GPS module. So I soldered the wires at the pins we need (Picture 4-6) to a female header that plugs into the Pi.
Step 6: Hooking Up the BMS
I used comsa42 his intructables for the connection diagram.
I used a BMS (battery management system) Balance board to charge my lipo's so I could leave them into my housing and charge them with a 'smart charger' via a waterproof DC jack
I soldered two cables for a charging port on the BMS, One on the P- (black) and the other one on the P+ (red).(These cables don't need to be so thick since there wil only go 2 Amps through the charge port)
NOTE: In the beginning I used a DC jack with screws, but I replaced it with the waterproof DC jack from the BOM later. Don't solder the plug yet or you will have a problem once you want to put it in your housing.
I connected the two batteries in series with one of the 'XT60 2 pack in series plug' I bought. I plugged that male header into a female one and I soldered a thick red and black wire to it. The red wire goes to B+ an the BMS and the black one goes to the B-.
Then the balance cables for the batteries. I used two of the bought balance cables and unplugged the red balance wire for battery one and the last black wire for battery two on both sides. We don't need those because these are the same as the thick battery wires, which we already connected. Then solder it in the right order like the diagram.
NOTE: In the middle I connected the ground with the positive from the next battery, but that's not really necessary, because the series connector already does that.
Step 7: On/off Switch (loop Key)
Instead of buying a 60 dollar anti-spark switch, I made a loop key. The principle is simple. You make an interruption in the circuit and to turn the board on, plug in the XT90 anti-spark connector and the circuit is closed, without any sparks.
First I soldered a wire to the male plug (picture 2-4) and then some 3.5mm bullet connectors to the female XT90 plug.
To connect it to the batteries, I used a male XT60 connecter to a female XT60 connector but with an interruption in the red wire. Then I soldered bullet connectors to the ends where i cut the wire in half, so I can plug the female XT90 header instead of soldering it directly to the cable. So plug it in and voila, the on/off switch is done.
Step 8: VESC, Battery Indicator and UBEC Connecor
I made my own '3 in parallel to 1 connector' by sticking 3 XT60 headers together (pic 1) and soldering a wire to the tree positives and a wire to the tree negatives (pic 2-6). Next I soldered a male connector to it and protected the bare cables with some black tape. (pic 7-9)
VESC & Indicator
Solder a male XT60 plug to the VESC power cables and to the cables of the battery percentage/voltage indicator.
Unplug2 balance cables and solder of the male end to a male XT60 plug. The female ends connect to the input side of the uBEC (voltage converter).
NOTE: I had cut the balance wires a 'bit' shorter, but that was a mistake so leave them intact ;)
Step 9: Motor Sensor to Vesc
Use two of the stepper cables to connect the sensor of the motor to the VESC. The motor has 5 pins, 2 for power en tree for the hall sensors (1 pin per hall sensor).
Pull out the four cables out the 4pin side and take an extra wire from a second stepper cable, cut them a bit shorter and solder some male pins onto the end. Put them in the correct order like in the pictures
Use heat shrink tubes and tape to make everything secure! When that's done, the only thing left to do is just put them in the right order from the VESC to the motor.
Step 10: Power Supply Raspberry Pi
We need a 12V to 5V converter which will power the raspberry pi via USB, so I immediately thought of a car charger. It's a cheap and practical solution.
NOTE: Before we open it, you should make sure that you remember which one is the port that can deliver 2.1 Amps, because the Pi needs it.
So remove the sticker and unscrew the top of the car charge, then loosen the pin on the bottom. Afterwards it will go open easily, solder the spring (+12V) and the metal curved object (GND) loose and replace them with 2 of those balance wires (solder the male side to the PCB).
When that was done, I checked if everything was correct by connecting a DC jack to the wires en plugged it into a power supply of my LED stip and measured the USB output voltage (The two outer ones are +5V and GND).
If everything is correct, you can hide the bare metal parts with some heat shrink tubes and tape.
NOTE: Dubbelcheck the polarity on the charger, because it can be different.
Step 11: Wiring the Pi, Lights and GPS
Now the power for the lights.
We receive 12V from our uBEC and we need that for our front lights, tail light and car charger. The raspberry pi can't deliver enough current nor voltage to feed the LEDs so we will have to use a transistor. The 12V will be used as power supply and the raspberry pi will switch them on and off by controlling the Base of the NPN transistor (2N222: pic 2) so let's solder that to a prototyping board.
First off all the tail light is as the back of the longboard and the raspberry pi will come in the front so the cable will have to be extended (pic 3-5). The tail light has 3 wires. Black (negative), yellow (running/tail Light), red (brake/stop Light). But because there is only a very small difference between the brake and running light, I choose to use the red wire and let the yellow one alone. Put a long male wire in the provided metal of the rear light and bend it together until the wire can no longer come loose. Do this for the black and red wire.
For the rear lights, solder them in parallel. Then the prototyping board. Solder the female ends of the two balance wires to the board en use a copper wire to spreid the 12V over the whole board. Then add the transistors, one for the front lights and one for the rear lights. Collector -> 12V, emitter -> GND en the base to a resistor and then to a wire with a female end, which will fit on the raspberry pi GPIO pins (pin 20&21). The car charger can be power by the 12V, then put a usb cable in the correct USB input and put the micro usb end in the raspberry pi.
3.3V -> Vin
GND -> GND
RX -> TX
TX -> RX
NOTE: Only the 2 base pins from the transistor need an external resistor to limit the current. The lights don't need those because they are built into the leds.
Step 12: Housing
I wrapped the parts that belong together in plastic foils to make sure that all the wire were secure and it's easier to put i in the housing afterwards. I designed all the parts in inventor and printed them with my 3d printer. All the inventor (.ipt) files and printer/slicer files (.stl) are provided. The designs are very basic.
Back side (electric longboard parts)
You can put the battery indicator in and the female XT90 plug and then place the plastic box. Once the housing was stuck, I fixed the XT90 plug with hot glue so that it stays stuck when the switch is pulled in and out. I also added a screw at the inside of the housing right next to the wall where the XT90 plug is attached so the wall can't be pressed in when plugging in the loop key.
The antenna from the gps module is long, very long. So I kept the two ends out the box and folded the wire into this part of the case.
NOTE: Use little screws that aren't longer then the longboard is thick!
Once that was good, I replaced my test DC jack with a waterproof one. I soldered some wires with female bullet connectors to the wires and male bullet connectors on the wires that are attached to the BMS board. One again, the wires don't have to be so thick because the charger only delivers around 2 amps. It will also be easier to plug the jack in the case with some smaller wires...
Front side (raspberry pi with GPS and lights)
Slide the screen into the back of the case. Place al the cables inside the housing and screw it down. You also might want to put some foil or something between the antenna and the raspberry Pi, because it was very magnetic and computers don't always like that.
NOTE: Be careful when you slide the tft screen into the housing, so you don't damage any cables that control the touch. It happened to me...
Step 13: Basic Setup Pi
First of all, we need an SD card with Raspbian. You can download raspbian from here. Once that's downloaded, we can install raspbian on the SD card. You can install the software using Win32Discmanager or etcher on your computer.
When it's installed you will have to add a file called 'ssh' without extention to enable the SSH on the pi. Once that's done, you can boot your raspberry and add it to your network.
The pi won't have connection to your network so you will have to set an APIPA address, this is the IP address that the pi will have when he doesn't have connection to a network. Open the file 'cmdline.txt' on the SD card and add a APIPI address. For example: 'ip=169.254.10.5'.
NOTE: Make sure everything stands on one line or it won't work!
Put the SD in the PI, add a network cable from your pi to your computer and then plug in the power.
Afterwards you can use Putty or if you use a mac, just use the terminal to create an SSH connection.
Adding a wireless connection:
To add a new network to your pi you can type this command:
echo ENTER_ YOUR_PASSWORD | wpa_passphrase ENTER_YOUR_SSID >> /etc/wpa_supplicant/wpa_supplicant.conf
After a reboot you should be able to find your IP address on your router and connect to your pi via ssh with that ip address.
Always finding your ip is a bit annoying so let's set up a hostname so we can use that instead (bonjour installation is required on windown PC for this).
sudo raspi-config nonint do_hostname CHOOSE_A_HOSTNAME
NOTE: To use the hostname in the future u should type the SSH rule like this:
We should be sure that the pi's system and packages are up to date:
Enter the following command to realise that:
sudo apt-get update && sudo apt-get upgrade
Step 14: Put the Project on Your Pi
I created a new user 'longboard' for this project:
We will need to go to the root for this
> sudo -i > Adduser longboard New password: > l0ngb0@rd Full name: > electric longboard
You can leave the rest empty. As next we will need to give the user 'longboard' the rights of sudo
> adduser longboard sudo
Afterwards we will go back to our longboard user
> su longboard
Installing some packages for the project. Packages for hosting the website an database
> python3 -m pip install --user --upgrade pip==9.0.3 > sudo apt install -y python3-mysqldb mysql-server uwsgi nginx uwsgi-plugin-python3 rabbitmq-server
Connector database, packages website en libraries voor GPS/tijdzone detectie
> python -m pip install mysql-connector-python argon2-cffi Flask Flask-HTTPAuth Flask-MySQL mysql-connector-python passlib argon2 libgeos-dev pytz tzwhere
Check the status of mysql
> sudo systemctl status mysql
By entering this command, you can see that MySQL only listens on 127.0.0.1 -> not accessible from the network, only local (on pi the self).
> ss -lt | grep mysql
Start client as roo
> sudo mysql
> CREATE USER 'project-admin’@‘localhost' IDENTIFIED BY ‘@min_l0ngb0@rd’; > CREATE USER 'project-longboard’@‘localhost' IDENTIFIED BY ’l0ngb0@rd’;
Creating database and setting privileges:
> CREATE DATABASE longboard_db; > GRANT ALL PRIVILEGES ON longboard_db.* to 'project-admin'@'localhost' WITH GRANT OPTION; > GRANT SELECT, INSERT, UPDATE, DELETE ON longboard_db.* TO 'project-longboard'@'localhost'; > FLUSH PRIVILEGES;
Run the sql script to create the tables, it will also create a default user for the website:
(username: longboard, password: test):
> source \home\logboard\longboard\longboard_db.sql; > exit
Test if running the file worked:
> echo 'show tables;' | mysql longboard_db -t -u project-admin -p
Create a directory 'longboard' and clone my project from github
> mkdir longboard && cd longboard > git clone https://github.com/ThomasVantricht/electricLongboard.git
If you used the same directory name and user as me, then you shouldn't adjust the files in the conf directory.
If you didn't you should adjust the files (> sudo nano conf/filename.extension)
Once the paths are correct, you have to copy the files to the system directory. There are tree services.
- One for the kiosk site on the localhost.
- One for the gps module with database connection
- One for the site available on your network
> sudo cp conf/project1-*.service /etc/systemd/system/ > sudo systemctl daemon-reload > sudo systemctl start project1-* > sudo systemctl status project1-*
When everything is okay, you should enable them so they will start automatically when the pi boots:
(If the previous step fails, then you should checkt the paths in the config files)
> sudo systemctl enable project1-*
Configuring the nginx service:
- copy conf/nginx to 'sites-available' (and give it a better name)
- remove the link to the default-config
- link to the new config/nginx
- restart to activate the changes
> sudo cp conf/nginx /etc/nginx/sites-available/project1 > sudo rm /etc/nginx/sites-enabled/default > sudo ln -s /etc/nginx/sites-available/project1 /etc/nginx/sites-enabled/project1 > sudo systemctl restart nginx.service
Check if nginx survived:
> sudo systemctl status nginx.service
Once that's done you should have a webserver on the ip of your pi available on your network and a site on the localhost to start and stop session offline.
Step 15: Setting Up Kiosk Mode Raspberry Pi
> sudo apt-get install chromium-browser x11-xserver-utils unclutter
Enter the autostart file of the pi user:
> sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
You will have to comment out (put a # in front of the line) the existing rule:
Next add these lines underneath the screensaver line
@xset s off @xset -dpms @xset s noblank @chromium-browser --noerrdialogs --kiosk http://127.0.0.1:8080/ --overscroll-history-navigation=0 --incognito --disable-pinch
Hit ctrl-O and then ctrl-X to write out and exit the file and now type:
> sudo raspi-config
From there navigate down to boot_behaviour and change this setting to boot in desktop mode and login as user pi by default.
NOTE: to get out of the kiosk mode, you can type in
> sudo killall chromium-browser.
This will close all the chromium browser instances.
Step 16: How It Works
When the pi boots, you will see the ip address on the tft screen together with a list of all the users of the board.
You can start a session offline via this screen. You can also control your lights. If you type the ip address in your browser, you will come at the login screen. You can login with the default user 'board' (password: test). or you can create a new account. One that's done, you will see your dashboard. Here you can see your trip route and total distance, travel time. If you go to the tab longboard, you can see the current location of the board, you can toggle your lights and you can start recording a session. Once you click at 'start session' the PI will constantly determine the location and save it in the database until you press 'stop session'. If the GPS doesn't have a fix, the session can not be started, you will receive an alert at the top of the screen. Your sessions will be displayed on a google map.
Runner Up in the
Make it Move Contest