Skip to content

How to make electric skateboard using Wi-Fi module

How to make electric skateboard using Wi-Fi module

Components

Hardware components

x 1


x 1


Project description

Story

Hardware Materials

Skateboard Materials

34″ Cruiser Longboard Deck

Trucks

90mm Wheels

Bearings 8mm

Materials for electric skateboard

Motor

Motor Mount

44T Drive Wheel Pulley Adapter

12S 120A ESC

TorqueBoards ESC Programming Card

12S UBEC](http://diyelectricskateboard.com/product/12s-ubec/) On/Off Anti-Spark Power Switch

For more detailed information, refer to this URL.?http://www.life4iot.com/2015/10/30/electric-skateboard1-materials/?lang=en

Materials for Wi-Fi Receiver

WIZwiki-W7500ECO

How to make electric skateboard using Wi-Fi module, WIZwiki-W7500ECO

WizFi250

How to make electric skateboard using Wi-Fi module, WizFi250

Hardware Configuration for Motor control

Already you know,PWM is need to operate DC motor. So I made PWM signal using WIzwiki-W7500ECO board and this picture is configuration for motor control.

You need ESC(for controlling speed of motor) and UBEC(for input 5V to WIZwiki-W7500ECO).

Hardware Configuration for Motor control
1 / 2

If you refer to this?Link, you can get more detail information and download source code for motor test.

Hardware Configuration for Wi-Fi Receiver

Wi-Fi receiver is device for communicating control data with skateboard. I made Wi-Fi receiver using WizFi250 which is Wi-Fi module by WIZnet. This picture is configuration for Wi-Fi receiver.

Hardware Configuration for Wi-Fi Receiver

I am not hardware engineer so I couldn’t handle hardware well and this hardware may be showing some lack. But it’s operation is very well. In this device,it has 3 output pin and 2 input pin. Input pins are for getting voltage from battery and Output pins are for controlling motor.

Hardware Configuration for Wi-Fi Receiver

Wi-Fi Receiver Firmware

Source Code

Firmware of Wi-Fi receiver is operated as belows. If smartphone push “Speed Up” button, Wi-Fi receiver will increase motor speed and It it push “Speed Down” button, Wi-Fi receiver will decrease motor speed about 5 percentage.

How to make electric skateboard using Wi-Fi module, Source Code

In exception situation like disconnect Wi-Fi or socket, Wi-Fi receiver will stop motor as below. But even if motor is stopped, skateboard can’t stop because it has acceleration.

How to make electric skateboard using Wi-Fi module, Source Code

You can download source code for Wi-Fi receiver at this?Link

C++

#include "mbed.h"
#include "Servo.h"
#include "WizFi250Interface.h"
?
#define SECURE WizFi250::SEC_WPA2_MIXED
#define SSID "Kaizen_Skate"
#define PASS "qwertyuiop"
?
#define SERVER_PORT????5000
#define STOP_MOTOR???? 50
?
?
#if defined(TARGET_WIZwiki_W7500P)
????WizFi250Interface wizfi250(PC_2,PC_3,PC_13,PC_14,PC_12,NC,115200);
????Serial pc(USBTX, USBRX);
????Servo motor_speed(PC_8);??????// it used to percentage value ( 0 ~ 1 )
????DigitalOut green_led(LED2);????
????DigitalOut red_led(LED1);
????DigitalOut blue_led(LED3);
#endif
?
#define START_MSG?????? "START"
#define END_MSG???????? "ENDn"
#define CONTROL_UP??????"UPXX"
#define CONTROL_DOWN????"DOWN"
#define CONTROL_CRUISER "CRUI"
#define CONTROL_STOP????"STOP"
?
#define STATUS_CMD_OK?? "OKXX"
#define STATUS_CMD_FAIL "FAIL"
?
#define CONTROL_MSG_SIZE????19
?
// Control Pkt Format : START,CONTROL,SPEED_VALUE,END
//??????????????????????START,UPXX,500,END
// Status Pkt Format : START,CONTROL,SPEED_VALUE,STATUS,END
?
struct control_pkt{
????char start_msg[6];
????char control_msg[5];
????char speed_msg[4];
????char end_msg[4];
};
void parse(char buffer[], int *j, char *string);
?
int main() {????
????int recv_cnt,j;
????volatile float speed_value = 0.5;
????char recv_control_msg[100];
????char status_msg[100];
????control_pkt control;
?
????pc.baud(115200);
????green_led = 1; red_led = 1; blue_led = 1;
?
????wizfi250.init();
????wizfi250.setAntMode(WizFi250::PCB);
????wizfi250.setAddress("192.168.100.2","255.255.255.0","192.168.100.1");
????if ( wizfi250.connect(SECURE, SSID, PASS, WizFi250::WM_AP))
????{
????????red_led = 0;
????????return -1;
????}
????printf("IP Address is %srn", wizfi250.getIPAddress());
????green_led = 0; red_led = 0; blue_led = 0;
?
????TCPSocketServer server;
????TCPSocketConnection client;
?
????while(true)
????{
????????if( client.is_connected() == false )
????????{
????????????green_led = 1; red_led = 1; blue_led = 0;????????????
????????????client.close();
????????????server.close();
?
????????????if(speed_value == 0.5)
????????????{
????????????????server.bind(SERVER_PORT);
????????????????server.listen();
?
????????????????printf("nWait for new connection...rn");
????????????????server.accept(client);
????????????????client.set_blocking(false, 1500);
????????????}
????????????else if(speed_value <= 0.4)
????????????{
????????????????printf("Speed decrease +rn");
?
????????????????speed_value = 0.5;
????????????????motor_speed = speed_value;
????????????}
????????????else
????????????{
????????????????printf("Speed decrease -rn");
????????????????speed_value = 0.5;??motor_speed = speed_value;
????????????}
????????}
????????else
????????{
????????????motor_speed = speed_value;
?
????????????green_led = 0; red_led = 1; blue_led = 1;
????????????//recv_cnt = client.receive_all((char*)recv_control_msg, sizeof(control)-1);
????????????recv_cnt = client.receive_all((char*)recv_control_msg, sizeof(control));
?
????????????j=0;
????????????parse(recv_control_msg, &j, control.start_msg);
????????????parse(recv_control_msg, &j, control.control_msg);
????????????parse(recv_control_msg, &j, control.speed_msg);
????????????parse(recv_control_msg, &j, control.end_msg);
?
????????????if(recv_cnt > 0)
????????????{
????????????????if( (strncmp(control.start_msg,START_MSG,sizeof(control.start_msg)) != 0) || 
????????????????????(strncmp(control.end_msg,END_MSG,sizeof(control.end_msg)) != 0) )
????????????????{
????????????????????printf("TEST Errorrn");
????????????????????sprintf(status_msg,"%s,%03d,%s,%sn",START_MSG,int(speed_value*100),STATUS_CMD_FAIL,END_MSG);
????????????????????client.send_all((char*)status_msg,strlen(status_msg));
????????????????????continue;
????????????????}
?
????????????????if( strncmp(control.control_msg,CONTROL_UP,sizeof(control.control_msg)) == 0 )
????????????????{
????????????????????speed_value += 0.05; 
????????????????????motor_speed = speed_value;
????????????????????printf("TEST UP %frn",speed_value); 
????????????????}
????????????????else if( strncmp(control.control_msg,CONTROL_DOWN,sizeof(control.control_msg)) == 0)
????????????????{
????????????????????speed_value -= 0.05; 
????????????????????motor_speed = speed_value;
????????????????????printf("TEST DOWN %frn",speed_value);
????????????????}
????????????????else if( strncmp(control.control_msg,CONTROL_CRUISER,sizeof(control.control_msg)) == 0)
????????????????{
????????????????????printf("TEST CRUISERrn"); 
????????????????????speed_value = (float)(atoi(control.speed_msg)) / 100;
????????????????????motor_speed = speed_value;
????????????????}
????????????????else if( strncmp(control.control_msg,CONTROL_STOP,sizeof(control.control_msg)) == 0)
????????????????{
????????????????????printf("TEST STOPrn"); 
????????????????????speed_value = 0.5;
????????????????????motor_speed = speed_value;
????????????????}
????????????????else
????????????????{
????????????????????printf("TEST Error 1-2rn");
????????????????????sprintf(status_msg,"%s,%03d,%s,%sn",START_MSG,int(speed_value*100),STATUS_CMD_FAIL,END_MSG);
????????????????????client.send_all((char*)status_msg,strlen(status_msg));
????????????????????continue;
????????????????}
?
????????????????sprintf(status_msg,"%s,%03d,%s,%sn",START_MSG,int(speed_value*100),STATUS_CMD_OK,END_MSG);
????????????????client.send_all((char*)status_msg,strlen(status_msg));
????????????}
????????????else
????????????{
????????????????sprintf(status_msg,"%s,%03d,%s,%sn",START_MSG,int(speed_value*100),STATUS_CMD_OK,END_MSG);
????????????????client.send_all((char*)status_msg,strlen(status_msg));
????????????}
????????}
????}// while
}
?
void parse(char buffer[], int *j, char *string) {
//extracts next location string data item from buffer
????int i=0;
????for (i=0; i<=strlen(buffer); i++) {??//TOTAL SIZE OF RETURNED DATA
????????if ((buffer[*j+i] == ',')||(buffer[*j+i] == '' )) { //IF comma or end of string
????????????//comma is the string field delimiter
????????????string[i]=0; //SETS END OF SRTRING TO 0
????????????*j=*j+i+1; //UPDATES to 1 after comma seperated value
????????????break;
????????} else string[i]=buffer[*j+i]; //Keep adding to the string
????}
}

Andorid Application

How to make electric skateboard using Wi-Fi module, Source Code

Source Code

https://github.com/kaizen8501/WiFi_Skateboard

Documents

  • code

  • WIZwiki-W7500ECO

    This is schematic of WIZwki-W7500ECO

Comments

Comments