Simplest Wifi Car Using ESP8266 Motorshield

16,109

57

21

Introduction: Simplest Wifi Car Using ESP8266 Motorshield

I found very simple way to make a wifi car. You actually need 4 things: NodeMcu esp8266 Amica, esp motorshield, chassis and your smartphone. So that's it, let's get started!

Step 1: ESP Motorshield

There's not so much information on the Internet about this board. First of all this shield for ESP-12E Dev Kit and NodeMcu boards and not for all, because width between pins is 25mm and that's not enough for some boards like LoLin. In my project I used NodeMcu Amica.

This shield board is driven by the special excent large power full-bridge chip L293DD from the famous Stmicroelectronics company, which can directly drive 2-channels DC motors or one-channel stepper motor. The driven current can be arrived at 1.2A.
Motor power: can be up to 36V.

ESP power: can be up to 9V. Because it goes straight to the esp without any voltage regulators.

Also these pins have common ground, you can connect voltage supply to one pin and use shortcut for other(if voltage less than 9V).

Board uses 4 pins to control motors. PWMA, PWMB- speed of motors. DA, DB-direction of motors(0-straight;1-reverse).

Here pinout for NodeMcu Amica.

  • PWMA-GPIO5.
  • PWMB-GPIO4.
  • DA-GPIO0.
  • DB-GPIO2.

Step 2: Circuit

That's how I connected all this stuff. For power supply I use 2 Samsung INR18650-30Q connected in series. About motors, I connect 2 motors in parallel to each motor outputs- PWMA(Left side), PWMB(Right side).Make sure that motors will rotate in one direction when you connect it.

Step 3: Blynk Application

In Blynk application we need only joystick.

Set joystick to merge mode for work with Virtual pins. Values for both axis from (-1) to 1.

Step 4: ESP Code

Esp code is default Blynk project with handling data from joystick at Virtual pin- 1.

Nothing complicated, data handling is done by if-else if...

#define BLYNK_PRINT Serial 
#include  <ESP8266WiFi.h>
#include  <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App. 
// Go to the Project Settings (nut icon). 
char auth[] = "YourAuthToken"; 

// Your WiFi credentials. 
// Set password to "" for open networks. 
char ssid[] = "YourNetworkName"; 
char pass[] = "YourPassword"; 

int PWMA=5;//Right side 
int PWMB=4;//Left side 
int DA=0;//Right reverse 
int DB=2;//Left reverse 

void setup(){ 
 // Debug console 
 Serial.begin(9600); 
 Blynk.begin(auth, ssid, pass); 
 pinMode(PWMA, OUTPUT); 
 pinMode(PWMB, OUTPUT); 
 pinMode(DA, OUTPUT); 
 pinMode(DB, OUTPUT); 
} 

void loop(){ 
Blynk.run(); 
  
} 

// Handling Joystick data 
BLYNK_WRITE(V1){ 
int x = param[0].asInt(); 
int y = param[1].asInt();  
if(x==-1 && y==-1){             //Backward and Left     
     digitalWrite(PWMA, LOW); 
     digitalWrite(DA, LOW); 
     
     digitalWrite(PWMB, HIGH); 
     digitalWrite(DB, HIGH); 
}else if(x==-1 && y==0){        //Left Turn 
     digitalWrite(PWMA, 450); 
     digitalWrite(DA, HIGH); 
    
     digitalWrite(PWMB, 450); 
     digitalWrite(DB, LOW); 
}else if(x==-1 && y==1){        //Forward and Left     
     digitalWrite(PWMA, LOW); 
     digitalWrite(DA, LOW); 
    
     digitalWrite(PWMB, HIGH); 
     digitalWrite(DB, LOW); 
}else if(x==0 && y==-1){        //Backward     
     digitalWrite(PWMA, HIGH); 
     digitalWrite(DA, HIGH); 
     
     digitalWrite(PWMB, HIGH); 
     digitalWrite(DB, HIGH);
}else if(x==0 && y==0){        //Stay 
     digitalWrite(PWMA, LOW); 
     digitalWrite(DA, LOW); 
     
     digitalWrite(PWMB, LOW); 
     digitalWrite(DB, LOW); 
}else if(x==0 && y==1){        //Forward 
     digitalWrite(PWMA, HIGH); 
     digitalWrite(DA, LOW); 
    
     digitalWrite(PWMB, HIGH); 
     digitalWrite(DB, LOW); 
}else if(x==1 && y==-1){        //Backward and Right     
     digitalWrite(PWMA, HIGH); 
     digitalWrite(DA, HIGH); 
     
     digitalWrite(PWMB, LOW); 
     digitalWrite(DB, LOW); 
}else if(x==1 && y==0){        //Right turn 
     digitalWrite(PWMA, 450); 
     digitalWrite(DA, LOW); 
     
     digitalWrite(PWMB, 450); 
     digitalWrite(DB, HIGH); 
}else if(x==1 && y==1){        //Forward and Right 
     digitalWrite(PWMA, HIGH); 
     digitalWrite(DA, LOW); 
     
     digitalWrite(PWMB, LOW); 
     digitalWrite(DB, LOW);
 } 
} 

Step 5: Test

All is done! Here video with tests.

I'm currently freelancer. For hiring, you can contact me at about.prototype@gmail.com

Wheels Contest 2017

Participated in the
Wheels Contest 2017

Arduino Contest 2017

Participated in the
Arduino Contest 2017

Remote Control Contest 2017

Participated in the
Remote Control Contest 2017

3 People Made This Project!

Recommendations

  • Battery Powered Contest

    Battery Powered Contest
  • Plywood Challenge

    Plywood Challenge
  • Plastic Contest

    Plastic Contest

21 Discussions

0
melodieh1959
melodieh1959

Question 3 months ago on Step 1

I work for the Cape Town Science Centre in South Africa. I have been tasked to develop an educators hand booklet for the App Mechanic device and I have to specify the pin id's. I am battling to find somewhere that I can get a schematic with all the pin names and functions. Please can you assist here

1.1.jpg
0
ivankraljevic177
ivankraljevic177

2 months ago

Hello, i connected 7.2 battery for motors and 4.8 for ESP but motor output is 5v. What can i do to increase voltage output? And one more thing, when my car goes uphill voltage drops immediately to the 0.5 do you know why is that?

0
alexrussoeire
alexrussoeire

3 months ago on Step 1

Hi, I am a software engineer and love making stuff like this for educational purpose for my kids (7 and 10), but it is hard to find the time to build anything from scratch.

But thanks to you and this post, I was able to build, program and play with the hardware, that I had lying around for a while, in no time.

Really cool, thank you so much.

0
josemalena
josemalena

Tip 3 months ago

I bought two Lego Technic extensions cables and connected 2 motors along with the Lego Technic Battery (9V) and built a car with my son

96F985E0-8C06-4551-9A5C-A78E29E7EAA5.jpegD888550D-2E4C-4E4A-A30C-A30F4277DF4B.jpeg3C910E82-7E68-4BFA-AEE6-A94E30B67B11.jpeg
0
IswandiD
IswandiD

8 months ago

Blynk connect sucsessfully, Im using Power adaptor 12v To VM, connect Gearbox motor to Motor A, using joystic V1 -1 +1, But Motor not work, What can I do?

0
fantamax
fantamax

Question 8 months ago

Hello,
About : "digitalWrite(PWMA, 450);"
"digitalWrite" must be only LOW OR HIGH.
Whit 450 I think must be used "analogWrite".
Correct?

0
MonneratRJ
MonneratRJ

8 months ago on Introduction

Hello friend, my problem is that it TRIES to run, but my motor "beeps" like they are struggling to move the car, if i get it out of the ground and give a little tap the wheels begin spinning slowly... i think the power is not enough... i'm using 2 18650 batteries = 7,4V on the Vin and Ground and using the Jumper to use to VM too... But i think it might be something with my PWM or the Motorshield itself, can you help me out? :(

0
Jimmy Jim
Jimmy Jim

1 year ago

please make a MIT App Inventor version

0
MohammadF85
MohammadF85

1 year ago

I want to make the same project but with raspberri Pi. can you please tell me what to code in Rpi when using a joystick in blynk app
Thanks

0
CosmosL
CosmosL

2 years ago

What is power(Batter) for motors? Do you use one Batter pack for ESP?

0
Farrukh_
Farrukh_

Question 2 years ago

it works offline as well? or need internet connection?

0
Andriyf1
Andriyf1

Answer 2 years ago

Internet connection is necessary.

0
JeremyP120
JeremyP120

Question 2 years ago on Step 4

what is auth??? tnx

0
Andriyf1
Andriyf1

Answer 2 years ago

This is your personal authorization token for Blynk app.

0
ErickFloorZ
ErickFloorZ

Question 2 years ago

can you update where is A1 A2 B1 B2 wheel position on chasis?thx

0
Andriyf1
Andriyf1

Answer 2 years ago

Motors A1, A2 on the left side and B1, B2 on the right side.

0
AfikileS
AfikileS

2 years ago

Thanks mate, works like a charm.

Please add on the sketch

##include

0
Andriyf1
Andriyf1

Reply 2 years ago

I'm glad that all works.Thanks for the comment, I updated code.

0
AfikileS
AfikileS

Reply 2 years ago

I will have a look t the code, I experienced some issues with the car driving and turning at the same time.