DIY WIFI RC Car With ESP8266 and Arduino IDE

31,516

55

13

Introduction: DIY WIFI RC Car With ESP8266 and Arduino IDE

About: Software, electronics, do-it-yourself
This project is an example of remotely controlled car via WIFI. The circuit is based on ESP8266, and the software is written in the Arduino IDE. As an engine driver, I used the L298N. The vehicle's speed is controlled by PWM in the range of 0 to 1023. Digital control offers more possibilities than the usual controller. I also added a RGB LED as light and buzzer as a horn.

This article can also see here:


DIY WIFI RC car with ESP8266 and Arduino IDE

Step 1: Components

Components that I used in this project.

Step 2: Schematic

Diagram of a remote controlled car.

Step 3: Software for ESP8266

Before you upload the software to ESP8266 setup your WiFi connection.
	#define WIFI_SSID ""
	#define WIFI_PASSWORD ""
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <WiFiUdp.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <Adafruit_NeoPixel.h>

#define PIN D8
#define LICZBADIOD 1
 
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(LICZBADIOD, PIN, NEO_GRB + NEO_KHZ800);

//---------------------------------------

#define CMD_NONE 0
#define CMD_LED 1

typedef struct TRCcar{
  short speed;
  short turn;
  uint8_t flags;

  uint8_t cmd;

  uint8_t r;
  uint8_t g;
  uint8_t b;
};

//---------------------------------------

//const char COMPILED[] PROGMEM  = { __DATE__ " " __TIME__ };
#define WIFI_SSID ""
#define WIFI_PASS ""

int cnt_loop = 0;
long time_loop;

//---------------------------------------

void setup() {
  Serial.begin(115200);
  Serial.println( "\r\n\r\n--------------------------------------" );
  Serial.println( "START setup" );
  delay(500);
  
  BlinkLedSteup();
  MotroSetupA();
  MotroSetupB();

  //---------------------------------
  WiFi.mode(WIFI_STA);
  //WiFi.mode(WIFI_AP_STA);
  //Serial.print("Setting soft-AP ... ");
  //Serial.println(WiFi.softAP(GetNameDev().c_str(), "1234") ? "Ready" : "Failed!");
  //Serial.println(WiFi.softAP("ESP8266-test", "1234") ? "Ready" : "Failed!");
  
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  //WiFi.hostname( GetNameDev() );

  Serial.print("Connecting to WIFI");

  // Wait for connection
  while( WiFi.status() != WL_CONNECTED ) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println( WIFI_SSID );
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  //---------------------------------
  UDPSetup();
  BeepSetup();

  pixels.begin();
  //pixels.setPixelColor(0, 255, 0, 0);
  //pixels.show();
  
  Serial.println( "END setup" );
}


void loop() {
  time_loop = millis();
  
  BlinkLed();
  SerialEvent();
  SerialCMD();
  UDPLoop();
  BeepLoop();
}
Download source code

Step 4: Computer Control Software

The program I control wrote in C #. For PC communication with ESP8266 I used UDP protocol. All commands are executed immediately without delay. The car is driving great, I think much better than the original controller.

Step 5: Test Drive

wwwGoogle pluseTwitter

Be the First to Share

    Recommendations

    • Fandom Contest

      Fandom Contest
    • Summer Fun: Student Design Challenge

      Summer Fun: Student Design Challenge
    • Make it Fly Challenge

      Make it Fly Challenge

    13 Comments

    0
    viantd
    viantd

    11 months ago

    can this command with left and forward in the same time

    0
    fenerb
    fenerb

    Question 1 year ago

    sir could you help me? I try to download the code with smartphone and pc but i did not. Could you send me this code with e-mail?

    0
    danielv347
    danielv347

    2 years ago

    Hi. The link to the code is broken, could you fix it? I am interested in seeing how you set up the UDP connection.

    0
    MartinK238
    MartinK238

    Question 2 years ago on Step 5

    can we controll it va smartphone !? is this possible ? Or should i buy a old rc controll case ? Love to hear from you. Greetings

    0
    MartinK238
    MartinK238

    2 years ago

    bro - which rc controll case did you use

    0
    AdityaB102
    AdityaB102

    2 years ago

    is it work on the same wi-fi only or we can move car from everywhere?

    0
    HristoB
    HristoB

    3 years ago

    I've ordered a nodemcu just from pure curiosity, this looks perfect for a trial project. Thank you for sharing

    0
    amit2017
    amit2017

    3 years ago

    Bro where is the link or file to

    Computer Control Software
    0
    SUMITMDSEPFO
    SUMITMDSEPFO

    4 years ago

    can you please send the source code for Arduino uno and ESP8266 1

    0
    AhmedI44
    AhmedI44

    Reply 3 years ago

    thanks man

    i just started with nodemcu and so far only your codes seems to work

    I am not good at programming

    i need help to control it from android device using roboremo app