I.Objective
II.Parts and Devices
III.Hardware Installation
IV.Circuit Connection
V.Software Installation
VI.How to play


Mecanum Wheel Robot Car Full Package (with 18650 batteries)

Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES ここでご購入を!

Mecanum Wheel Robot Car  Kit Metal Chassis

Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES ここでご購入を!

18650 batteries (3.7V) x 2

Battery charger

(the metal chassis kit don’t include the batteries,click it to buy it separately)

Above robot cars are controlled by Arduino. if you have raspberry pi board, actually the robot car can also be controlled by Raspberry Pi. You can visit the following link to learn basic movement with raspberry pi.
link- https://osoyoo.com/?p=31428


In this project we will connect Robot Car to WIFI and Use an APP to control the car through Internet. This is a typical Internet of Things(IoT) Application.


OSOYOO Mecanum Wheels Robotic Car Chassis x 1 (2x left-wheels/2x right-wheels and 4x motor)
OSOYOO Mega2560 board fully compatible with Arduino
OSOYOO V1.0 WIFI Shield x 1
OSOYOO Model X motor driver x 2
OSOYOO Battery box x 1
18650 Batteries(3.7V) x 2


If you just finishes all lesson 1 (assembling the car) and lesson 4( bluetooth imitation driver), please keep all lesson connections same as it is. Then plug out bluetooth from WIFI Shield.


STEP 1. Remove the connection B_TX to D18 and B_RX to D19.

STEP 2. Connect E_RX to D18(TX1) and E_TX to D19(RX1).

(Note: You need split 2 pcs of male-to-female jumper wires from our 10-pc jumper wire bundle. Any color from the bundle will be ok. The rest of 8 pcs wires are as spare parts for potential broken or damaged wires.)


Open-source Arduino
Software(IDE)
Download Arduino IDE here:
https://www.arduino.cc/en/Main/Software?setlang=en
7 zip is a free zip
utility that un-zips zip files
Download 7zip here for free
https://www.7-zip.org/

Step 1: Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip this step). Download Arduino IDE from https://www.arduino.cc/en/Main/Software?setlang=en , then install the software.

Step 2: Please download the library zip file from WiFiEsp-master.zip .Open Arduino IDE ->click Sketch ->Include Library ->Add .ZIP library , then load above zip file into Arduino. 

Step 3: APP installation-you need search “OSOYOO WIFI UDP Robot Car Controller ” in Google Play or Apple Store, and then install this APP.

YOU CAN ALSO DOWNLOAD APP DIRECTLY FROM https://osoyoo.com/driver/arduino-udp/udp-robot.apk

Step 4:Arduino Sketch code Installation:

Download: https://osoyoo.com/driver/mecanum_metal_chassis/for_mega2560/metal-2560-lesson5-reverse.zip

(or Download: https://osoyoo.com/driver/mecanum_metal_chassis/for_mega2560/metal-2560-lesson5.zip )

Unzip the downloaded file , enter the metal-2560-lesson5 folder, you will see  two sub-folder :
metal-2560-lesson5A and metal-2560-lesson5B

These two folders have program for two WIFI modes:AP mode and STA mode. The Arduino sketches for these two modes are different. Let’s explain these two modes one by one

When working in AP mode, our robot car itself will become a WIFI Hot Spot. Our cell phone can connect to Robot Car as its wifi client. The IP address of Robot is fixed as 192.168.4.1 and It is not connected to WAN.
(1)  Unzip the metal-2560-lesson5 file and you will see a folder named metal-2560-lesson5A,  upload the code into Arduino.

(2) Open your Arduino Serial monitor, and you will see a similar result as AP mode. A new WIFI SSID “osoyoo_robot” with IP address 192.168.4.1 will show up in the window. This means your Robot car has a WIFI Hot Spot name “osoyoo_robot” , its IP address is 192.168.4.1

(3)Now your Robot car become a WIFI Hot Spot and set IP address as “192.168.4.1” to your APP Setting section.

(4) Connect your cell phone to “osoyoo_robot” wifi hot_spot, and you can use Mobile phone control the robot car.

(5)You can click the ◄ ► ▲ ▼  direction keys to make the car move. Use “||” pause key to stop the car movement.
Click Obstacle to shift left side, Click Tracking to shift right side.
Click F1 to make upper-left diagonal movement, Click F3 to make upper-right diagonal movement
Click F4 to make back-left diagonal movement, Click F6 to make back-right diagonal movement.

In STA mode, robot car does not work as a wifi hotspot. Instead, it will become an internet node in your LAN. You need tell Arduino sketch what is your local router’s WIFI SSID and password, then Arduino talks to router and get its own LAN IP address from DHCP server. You can use Mobile APP to access the robot car’s IP address and control its movement.

(1) Unzip the metal-2560-lesson5 file and you will see a folder named metal-2560-lesson5B, then load the metal-2560-lesson5B.ino code into Arduino

(2) You need change the code Line 176 and Line 177 :

char ssid[] = “YOUR_ROUTER_SSID”; // replace this with your router wifi SSID

char pass[] = “YOUR_ROUTER_WIFI_PASSWORD”; // replace with your wifi  password

(3) Upload the sketch to Arduino. Finally, click the Serial monitor window in upper right corner of Arduino IDE, you will see following result:

(4)In this mode, your will see an IP address which is our LAN IP address assigned by my router. Please write down this IP address and click Setting to set up robot IP address and set this IP address to your APP Setting section (no need change default port 8888 in APP).

(5)Now your Robot car is connected to your LAN, you can use Mobile phone under same LAN to control the robot car. If your APP is in WAN, you need to go to your Router Control Panel, forward Port 80 to Robot car LAN IP address, then you can use Router IP to control the car. This feature makes our robot car A REAL INTERNET OF THING device

(6)You can click the ◄ ► ▲ ▼ direction keys to make the car move. Use “||” pause key to stop the car movement.
Click Obstacle to shift left side, Click Tracking to shift right side.
Click F1 to make upper-left diagonal movement, Click F3 to make upper-right diagonal movement.
Click F4 to make back-left diagonal movement, Click F6 to make back-right diagonal movement.

FAQ about the WIFI UDP APP and sketch Code:

Q1)How to tune the robot car speed?
A: If you want change the speed performance of the robot car, please following parameters in line 11 to 13:

#define SPEED 85
#define TURN_SPEED 90
#define SHIFT_SPEED 130

SPEED value determines forward moving speed
TURN_SPEED value determines turning speed
SHIFT_SPEED value determines parallel shifting speed

Q 2)What happened when you press  buttons in OSOYOO WiFi UDP Robot Car APP ?
A: When you press a button of the APP, APP will send a single-letter message through UDP protocol to target device (in this example, our Arduino  WIFI Shield)

Button UDP message
F1 F
F2 G
F3 H
F4 I
F5 J
F6 K
A
B
R
L
square E
obstacle O
tracking T

Q3)How does Arduino handle the UDP command?

Line 230 to line 245 in mecanum-2560-lesson5A.ino file are the codes which react to Cell phone command. For example, when ▲ is pressed, according to Q1 table, a letter “A” command was sent from Cell phone to Arduino.  Line 233 case ‘A’ …. statement will make the car make car moving forward.

      char c=packetBuffer[0];
      switch (c)    //serial control instructions
      {  
        case 'A':go_advance(SPEED);;break;
        case 'L':left_turn(TURN_SPEED);break;
        case 'R':right_turn(TURN_SPEED);break;
        case 'B':go_back(SPEED);break;
        case 'E':stop_Stop();break;
        case 'F':left_shift(0,150,0,150);break; //left ahead
        case 'H':right_shift(180,0,150,0);break; //right ahead
        case 'I':left_shift(150,0,150,0); break;//left back
        case 'K':right_shift(0,130,0,130); break;//right back
        case 'O':left_shift(200,150,150,200); break;//left shift
        case 'T':right_shift(200,200,200,200); break;//left shift
        default:break;
      }