# ArduinoUno-ESP8266-2WD **Repository Path**: wang-chen_chen/arduino-uno-esp8266-2wd ## Basic Information - **Project Name**: ArduinoUno-ESP8266-2WD - **Description**: 基于Arduino UNO的2WD小车:集成ESP8266的WIFI控制 / 红外控制 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2024-12-19 - **Last Updated**: 2024-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # The WIFI Controlled Car Using Arduino UNO and ESP8266 * WIFI control:forward, backward, left and right turn, acceleration and deceleration * Ultrasound obstacle avoidance * Temperature and Humidity * The OLED Display:distance of obstacle,temperature and humidity ![](img/2wd_wifi_edge_web.jpg) ## Components * Arduino UNO R3 x1 * Arduino UNO ProtoShield x1 * ESP8266-01S x1 * FT232 x1 * Motor Drive:L298N x1 * Ultrasonic Sensor:HC-SR04 x1 * HC-SR04 bracket(yellow) x1 * Temperature and Humidity Sensor: DHT11 x1 * OLED 0.96 SSD1306 x1 * MG996R servo L-shaped bracket x1 * 2WD Robot Car Chassis Kit (1 universal wheels, 2 TT Tires, 2 TT motors, and 1 chassis) x1 * Power: 2*18650 Lithium Battery x1 * 2X18650 Lithium batteries box(series) with cover and switch ## Code * Arduino UNO: [CAR_WIFI_UNO](./code/CAR_WIFI_UNO/) * ESP8266-01S WIFI: CAR_WIFI_ESP8266](./code/CAR_WIFI_ESP8266/) * Arduino UNO ann ESP8266-01S communicate with software serial * [component_softserial.h](./code/CAR_WIFI_UNO/component_softserial.h) **Modular design**: the codes of each component as a header file, make it easy to add or subtract component and adjust functionality ![](img/code_structre.jpg) ## Software ### Install the ESP8266 Arduino core * https://github.com/esp8266/Arduino Copy this URL: * https://arduino.esp8266.com/stable/package_esp8266com_index.json and paste it in `Files -> Preferance-> Additional Boards Manager URLs` 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 ESP8266 Module ![](img/ESP8266_Arduino.jpg) #### Arduino UNO packages * [SoftwareSerial](https://docs.arduino.cc/learn/built-in-libraries/software-serial/) * [ArduinoJson](https://arduinojson.org/) #### ESP8266 packages * [ESP8266WiFi](https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/readme.html) * [ESPWebServer](https://github.com/esp8266/ESPWebServer) * [ArduinoJson](https://arduinojson.org/) ## Layout ### Arduino UNO R3 ![](img/Arduino-UNO-R3.jpg) ### Ultrasonic Sensor: HC-SR04 ![](./img/hc-sr04.jpg) ```c // Ultrasonic - Arduino #define TRIG_PIN 13 // Trigger #define ECHO_PIN 12 // Echo ``` |HC-SR04 | Arduino Uno | |-------------|---------------| | VCC | +5V | | Trigger | Pin 13 green | | Echo | pin 12 blue | | GND | GND | ### Motor Driver: L298N ![](img/L298N.jpg) #### TT Motors | L298N | TT Motor | |--------------|---------------------| | OUT4 | Left Motor `+` | | OUT3 | Left Motor `-` | | OUT2 | Right Motor `+` | | OUT1 | Right Motor `-` | ![2WD Robot Car Chassis Kit](img/2WD-RobotCar-Chassis-Kit.jpg) #### Arduino UNO and Power ```c #define RightBack 9 // Motor balck - LS298N IN1-> Arduino Pin9 #define RightForward 8 // Motor red + LS298N IN2 -> Arduino Pin8 #define LeftForward 5 // Motor black - LS298N IN3 -> Arduino Pin5 #define LeftBack 4 // Motor Red + LS298N IN4 -> Arduino Pin4 #define leftPWM 10 #define rightPWM 6 ``` | L298N | Arduino/Power | |--------------|------------------| | ENA | Pin 6 orange | | IN1 | Pin 9 green | | IN2 | Pin 8 blue | | IN3 | Pin 5 yellow | | IN4 | Pin 4 blue | | ENB | Pin 10 orange | | VCC | Lithium Battery `+` | | GND | Lithium Battery `-` and Arduino GND | | +5V | Vin | ### Temperature and Humidity Sensor: DHT11 ```c #define DHTPIN 2 ``` ![](img/dht11.jpg) | DHT11 | Arduino Uno | |------------|---------------| | + | +5V | | OUT | Pin 2 purple | | - | GND | ### OLED Arduino UNO * SDA -> A4 * SCL -> A5 | OLED | Arduino UNO | |-------------|---------------| | GND | GND | | VCC | +5V | | SCL | A5 blue | | SDA | A4 yellow | ![](img/oled_096_ssd1306.jpg) ## The WIFI of ESP8266-01S and Software Serial ### ESP8266-01S ![](img/esp8266-01s_pin.jpg) ### Upload to ESP8266 Compile the programme,then upload to ESP8266 with FT232(USB to TTL) ![](img/FT232.jpg) * layout | FT232 | ESP8266 | |---------|--------------| | RXD | TX | | TXD | RX | | VCC | VCC and EN(CH_PD) | | GND | GND and IO0(GPIO_0)(pull-down: USRT Download) | Connect the VCC and GND of FT232 to the two pins of ESP8266 using a breadboard ![](img/FT232_ESP8266.jpg) ### Visiting the hotspot of ESP8266 * WIFI Hotspot : ```c const char *ssid = "ESP8266-WIFI"; const char *password = "12345678"; IPAddress ip(192, 168, 1, 1); ``` * Visit : http://192.168.1.1 ### Arduino UNO ann ESP8266-01S Communicate with Software serial ```c #define SS_RX_PIN 3 // -> ESP8266 TX #define SS_TX_PIN 11 // -> ESP8266 RX ``` * The layout of Arduino UNO and ESP8266 |ESP8266 | Arduino | |-------------|------------------| | VCC3.3 | +3.3V orange | | RX | Pin 11(soft serial TX) yellow | | TX | Pin 3 (soft serial RX) blue | | EN(CH_PD) | +5V | | GND | GND | ## The Car ### The Front Angle ![](img/2wd_wifi_front.jpg) ### The Side Angle ![](img/2wd_wifi_edge.jpg) ### Web App ![](img/web_app.jpg)