Day 14- Wifi CAR, Wifi Motorized Curtain

 Day 14- Wifi CAR, Wifi  Motorized Curtain


In this article, we're creating the esp8266-powered smart vehicle. This car with a WiFi remote operates with the ESP8266 Module, also called NodeMCU. This module is much more powerful than the traditional Arduino UNO Board. The module has significantly more RAM, and additionally, greater processing power. Most important is that it comes with a built-in WiFi Module. The small NodeMCUhas a Micro USB port and is capable of operating using 7-12V. You are able to program it using the Arduino IDE.


NodeMcu ESP8266

L298N motor driver module

Car chassis


Step 1: What Is WiFi Car?

This is a basic automobile made from simple parts. The WiFi-controlled robot operates on the WiFi signal. Let me explain in detail.

When we first connect the entire circuit using the Power Supply, then the NodeMCU creates a server using the provided SSID and Password. Then, we need to connect to the Hotspot and then connect to that same address. (i.e. 192.168.4.1) (i.e. 192.168.4.1) an indication to the browser address bar, but it's not professional looking.

The ESP8266 is a Smart Car:

Let's say you want to allow the Robot an ESP the to follow the Forward command. Then, you must enter the URL of the browser bar and enter 192.168.4.1/F (We need to declare F to forward within the program.) to connect your car to WiFi using NodeMCU. Similar to the manner, we must declare all preferred directions within the esp8266 WiFi control code. Then, one by one writing all the IP addresses is not an ideal solution in my opinion.

Therefore, instead of typing each time into the address field, here we'll use an Android app and, using the app, we'll send the signal for the microcontroller. By following the instructions the microcontroller sends information to the motor driver via the connection to the RC connection. connection.



Step 2: ESP8266 Remote Control Car Schematics:


Here are the schematics and circuit diagram of this ESP8266 Wireless Remote Control Car. To drive the motor, I chose L298N. It is a powerful motor driver, which can operate a between 5V and 35V DC Motor with a up to 25W.
We will use 3S 12V Li-Po Battery so the maximum output per channel will be approximately 2A. This is enough to power the TT Motors.


assemble car chassis and mount the ESP8266 module and L298n as shown in the photo.
You can use any chassis for this project.





Step 4: Code Upload





copy this URL:

http://arduino.esp8266.com/stable/package_esp8266com_index.json

and paste it in Files -> Preferance


Then go there: Tools > Board > Boards Manager

Look up ' ESP8266' and then install the most recent version.

After installation, you can go into the Tools > board and select that ESP-12E Module . That's it, the Board is now selected.

Next, choose the appropriate Com Port.

Compile your Programme First and then Upload to NodeMCU. After a short time the program is compiled, and later uploaded to the NodeMCU Car.

 --------------------------------------------------------------------------------------

#define ENA   14          // Enable/speed motors Right        GPIO14(D5)
#define ENB   12          // Enable/speed motors Left         GPIO12(D6)
#define IN_1  15          // L298N in1 motors Rightx          GPIO15(D8)
#define IN_2  13          // L298N in2 motors Right           GPIO13(D7)
#define IN_3  2           // L298N in3 motors Left            GPIO2(D4)
#define IN_4  0           // L298N in4 motors Left            GPIO0(D3)

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

String command;             //String to store app command state.
int speedCar = 800;         // 400 - 1023.
int speed_Coeff = 3;

const char* ssid = "Make DIY";
ESP8266WebServer server(80);

void setup() {
 
 pinMode(ENA, OUTPUT);
 pinMode(ENB, OUTPUT);  
 pinMode(IN_1, OUTPUT);
 pinMode(IN_2, OUTPUT);
 pinMode(IN_3, OUTPUT);
 pinMode(IN_4, OUTPUT);
 
  Serial.begin(115200);
 
// Connecting WiFi

  WiFi.mode(WIFI_AP);
  WiFi.softAP(ssid);

  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
 
 // Starting WEB-server
     server.on ( "/", HTTP_handleRoot );
     server.onNotFound ( HTTP_handleRoot );
     server.begin();    
}

void goAhead(){

      digitalWrite(IN_1, LOW);
      digitalWrite(IN_2, HIGH);
      analogWrite(ENA, speedCar);

      digitalWrite(IN_3, LOW);
      digitalWrite(IN_4, HIGH);
      analogWrite(ENB, speedCar);
  }

void goBack(){

      digitalWrite(IN_1, HIGH);
      digitalWrite(IN_2, LOW);
      analogWrite(ENA, speedCar);

      digitalWrite(IN_3, HIGH);
      digitalWrite(IN_4, LOW);
      analogWrite(ENB, speedCar);
  }

void goRight(){

      digitalWrite(IN_1, HIGH);
      digitalWrite(IN_2, LOW);
      analogWrite(ENA, speedCar);

      digitalWrite(IN_3, LOW);
      digitalWrite(IN_4, HIGH);
      analogWrite(ENB, speedCar);
  }

void goLeft(){

      digitalWrite(IN_1, LOW);
      digitalWrite(IN_2, HIGH);
      analogWrite(ENA, speedCar);

      digitalWrite(IN_3, HIGH);
      digitalWrite(IN_4, LOW);
      analogWrite(ENB, speedCar);
  }

void goAheadRight(){
     
      digitalWrite(IN_1, LOW);
      digitalWrite(IN_2, HIGH);
      analogWrite(ENA, speedCar/speed_Coeff);
 
      digitalWrite(IN_3, LOW);
      digitalWrite(IN_4, HIGH);
      analogWrite(ENB, speedCar);
   }

void goAheadLeft(){
     
      digitalWrite(IN_1, LOW);
      digitalWrite(IN_2, HIGH);
      analogWrite(ENA, speedCar);

      digitalWrite(IN_3, LOW);
      digitalWrite(IN_4, HIGH);
      analogWrite(ENB, speedCar/speed_Coeff);
  }

void goBackRight(){

      digitalWrite(IN_1, HIGH);
      digitalWrite(IN_2, LOW);
      analogWrite(ENA, speedCar/speed_Coeff);

      digitalWrite(IN_3, HIGH);
      digitalWrite(IN_4, LOW);
      analogWrite(ENB, speedCar);
  }

void goBackLeft(){

      digitalWrite(IN_1, HIGH);
      digitalWrite(IN_2, LOW);
      analogWrite(ENA, speedCar);

      digitalWrite(IN_3, HIGH);
      digitalWrite(IN_4, LOW);
      analogWrite(ENB, speedCar/speed_Coeff);
  }

void stopRobot(){  

      digitalWrite(IN_1, LOW);
      digitalWrite(IN_2, LOW);
      analogWrite(ENA, speedCar);

      digitalWrite(IN_3, LOW);
      digitalWrite(IN_4, LOW);
      analogWrite(ENB, speedCar);
 }

void loop() {
    server.handleClient();
   
      command = server.arg("State");
      if (command == "F") goAhead();
      else if (command == "B") goBack();
      else if (command == "L") goLeft();
      else if (command == "R") goRight();
      else if (command == "I") goAheadRight();
      else if (command == "G") goAheadLeft();
      else if (command == "J") goBackRight();
      else if (command == "H") goBackLeft();
      else if (command == "0") speedCar = 400;
      else if (command == "1") speedCar = 470;
      else if (command == "2") speedCar = 540;
      else if (command == "3") speedCar = 610;
      else if (command == "4") speedCar = 680;
      else if (command == "5") speedCar = 750;
      else if (command == "6") speedCar = 820;
      else if (command == "7") speedCar = 890;
      else if (command == "8") speedCar = 960;
      else if (command == "9") speedCar = 1023;
      else if (command == "S") stopRobot();
}

void HTTP_handleRoot(void) {

if( server.hasArg("State") ){
       Serial.println(server.arg("State"));
  }
  server.send ( 200, "text/html", "" );
  delay(1);
}

--------------------------------------------------------------------------------------


Download   Android  APP


Step 6: Troubleshoot

Not moving in the right direction:
Imagine that you're pressing the forward button and the car is moving to the rear or is turning in the counterclockwise or clockwise directions. You must then take an easy step.
Make sure you face your car in the forward direction and then press the forward button.
Next, you should check which wheel is spinning which way.
If it's rotating incorrectly,, replace the motor wires. Your issue will be resolved.



No comments:

Post a Comment

Arduion Uno pin out