This tutorial will teach you how to control a Robo car using any Wifi enabled device.
Components Required:
About ESP8266
FIg. 1: Image showing ESP8266 Wi-Fi Modules
Making a Breadboard adapter for ESP8266 module:
Fig. 2: Image showing components required for making breadboard adapter of ESP8266 Modem
Start by soldering the female header onto the PCB. Solder the corner pins first so that the header grips onto the PCB properly. Then solder the remaining 4 pins.
Fig. 3: Image showing Breadboard Adapter PCB soldered to fit female header of ESP8266 Modem
Fig. 4: Image showing male header placed on breadboard adapter of ESP8266 Modem
After soldering, you can remove the black plastic part attached to the male header and start soldering each male pin to its corresponding female pin. In the end you would have something like this:
Fig. 5: Image showing male header soldered on breadboard adapter of ESP8266 Modem
Here is a detailed video tutorial showing the process: http://youtu.be/GhwmgvcjRaA (Optional)
Fig. 6: Image showing Breadboard Adapter of ESP8266 Modem placed on a breadboard
Fig. 7: Image showing ESP8266 Wi-Fi Module placed over breadboard
AT Commands for ESP 8266:
Command |
Description |
AT+GMR |
To know the version of firmware |
AT+RST |
To Reset module |
AT+CWMODE |
To set the mode of operation i.e., as Access Point or Station mode or both. |
AT+CWLAP |
To see the list of APs available |
AT+CIPSERVER |
To set as server |
AT+CIPMUX |
To choose between single or multiple connections |
AT+CIPSEND |
To set the channel number, data length and send data over WiFi |
AT+CIPCLOSE |
To close the connection |
Server on ESP 8266:
Algorithm:
Hardware Setup:
Gather all the parts shown in the image.
Fig. 8: Image showing components required for making robot
Attach the motors to the chassis and then the wheels to the axle.
Fig. 9: Image showing DC motor attached metallic frame of robot
Use some screws and bolts to attach the castor wheel
Fig. 10: Image showing wheels attached to the DC motors on Robot
Fig. 11: Image of Caster Wheel attached to the front side of Robot Car
Fig. 12:
Code Explanation:
Setup Instructions
-Connect everything according to the circuit diagram and power on the whole system.
Fig. 13: Prototype of simple Robotic Car
– Wait for a few seconds for the Wifi and Arduino to initialize. After 30 seconds or so, enable Wifi on your device (mobile or tablet or laptop) and you should see few available networks.
– You can either connect to your home network (which is “Robots Reloaded” in my case and that’s what I’m going to connect to) or to the Access Point itself (which is “ESP_9F0F14” in my case. The SSID of the module is nothing but it’s name followed by last 6 characters of its MAC Address)
Fig. 14: Prototype of Arduino based control circuitry mounted on Robotic Car
– Next, open your browser and dial in the IP address
Fig. 15: Screenshot of Wi-Fi connections on Android Phone showing hotspot from ESP module
– You can either connect to your home network (which is “Robots Reloaded” in my case and that’s what I’m going to connect to) or to the Access Point itself (which is “ESP_9F0F14” in my case. The SSID of the module is nothing but it’s name followed by last 6 characters of its MAC Address)
You may also like:
Project Source Code
#define esp Serial#define in1 8#define in2 9#define in3 10#define in4 11#define BUFFER_SIZE 1000char buffer[BUFFER_SIZE];void send_at(String x){esp.println(x);}void setup(){pinMode(in1, OUTPUT);pinMode(in2, OUTPUT);pinMode(in3, OUTPUT);pinMode(in4, OUTPUT);delay(2000);esp.begin(9600);esp.println("AT");delay(1000);esp.println("AT+CWMODE=3");delay(1000);esp.println("AT+CIPMUX=1");delay(1000);esp.println("AT+CIPSERVER=1,80");delay(1000);esp.println("AT+CIFSR");delay(1000);}bool read_till_eol() {static int i=0;if(esp.available()) {char c=esp.read();buffer[i++]=c;if(i==BUFFER_SIZE) i=0;if(i>1 && buffer[i-2]==13 && buffer[i-1]==10) {buffer[i]=0;i=0;return true;}}return false;}void loop(){int ch_id, packet_len;char *pb;if(read_till_eol()) {if(strncmp(buffer, "+IPD,", 5)==0) {// request format: +IPD,ch,len:datasscanf(buffer+5, "%d,%d", &ch_id, &packet_len);if (packet_len > 0) {pb = buffer+5;while(*pb!=':') pb++;pb++;if (strncmp(pb, "GET / ", 6) == 0) {serve_homepage(ch_id,0);}else if (strncmp(pb, "GET /?fwd", 9) == 0){forward();serve_homepage(ch_id,1);}else if (strncmp(pb, "GET /?rev", 9) == 0){reverse();serve_homepage(ch_id,2);}else if (strncmp(pb, "GET /?rgt", 9) == 0){right();serve_homepage(ch_id,3);}else if (strncmp(pb, "GET /?lft", 9) == 0){left();serve_homepage(ch_id,4);}else if (strncmp(pb, "GET /?stp", 9) == 0){stop_bot();serve_homepage(ch_id,0);}}}}}void serve_homepage(int ch_id, byte state){delay(1000);esp.print(F("AT+CIPSEND="));esp.print(ch_id);esp.print(",");esp.println("512");delay(500);esp.print("HTTP/1.1 200 OKrnContent-Type:text/htmlrnrnROBOT CONTROLLER WELCOME TO THE WEB INTERFACE OF ROBOT CONTROLLER OVER WIFI
");delay(5000);esp.print(F("AT+CIPCLOSE="));esp.println(ch_id);}void forward(){digitalWrite(in1,HIGH);digitalWrite(in2,LOW);digitalWrite(in3,HIGH);digitalWrite(in4,LOW);}void reverse(){digitalWrite(in1,LOW);digitalWrite(in2,HIGH);digitalWrite(in3,LOW);digitalWrite(in4,HIGH);}void right(){digitalWrite(in1,HIGH);digitalWrite(in2,LOW);digitalWrite(in3,LOW);digitalWrite(in4,LOW);}void left(){digitalWrite(in1,LOW);digitalWrite(in2,LOW);digitalWrite(in3,HIGH);digitalWrite(in4,LOW);}void stop_bot(){digitalWrite(in1,LOW);digitalWrite(in2,LOW);digitalWrite(in3,LOW);digitalWrite(in4,LOW);}
Circuit Diagrams
Project Video
Filed Under: Electronic Projects
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.