WiFi Controlled Smart Car Using NodeMCU (ESP8266) and ESP 12E Motor Driver Shield

by cyrixninja in Circuits > Microcontrollers

26 Views, 0 Favorites, 0 Comments

WiFi Controlled Smart Car Using NodeMCU (ESP8266) and ESP 12E Motor Driver Shield

53288dab-234f-4da9-b7e6-0ceb2205a989.jpg

In this project, we have designed and built a WiFi-controlled smart car using the NodeMCU (ESP8266-12E) microcontroller and an ESP-12E Motor Shield. This project demonstrates how IoT (Internet of Things) technology can be integrated with robotics to create a wireless car that can be controlled via a smartphone or computer through a simple web interface.

The car creates its own WiFi hotspot, allowing the user to connect directly without the need for an external router or internet connection. Once connected, the user can control the movement of the car — including forward, backward, left, and right directions — from a web-based control panel.

Supplies

nodemcu-esp8266-esp12e-motor-shield-pinout.jpg
617T2JKnxiL._AC_UF1000,1000_QL80_.jpg
product-jpeg.jpg
IMAGE1565178803.jpg
  1. ESP8266-12E Module (NodeMCU)
  2. ESP-12E Motor Shield
  3. 4 × BO Motors
  4. 4 × BO Motor Wheels
  5. MDF Board or Any Other Chassis
  6. 12V Battery
  7. Wires
  8. Screws

Make the Chassis

image.png
  1. Cut the MDF board into a rectangular shape that will serve as the base for your car. Recommended dimensions are approximately 15cm x 20cm, but you can adjust based on your preference.
  2. Mark four spots on the underside of the MDF board where you'll mount the BO motors - two on each side, positioned symmetrically for balance.
  3. Drill holes at the marked positions to allow for mounting screws.
  4. Place the BO motors in position, with two motors on the left side and two on the right side. Make sure all motors are oriented in the same direction on each side.
  5. Use small screws to secure the motors to the MDF board through the mounting holes.
  6. Connect the two motors on each side with jumper wires - connect the positive terminal of one motor to the positive terminal of the other motor on the same side, and do the same for the negative terminals.
  7. Attach the wheels to each motor shaft, ensuring they're firmly secured.


Connect the Motors With the ESP 12E Motor Shield

image.png
image.png
  1. Position your ESP-12E Motor Shield on top of the NodeMCU, ensuring all pins align properly and press down gently to connect them.
  2. Identify the motor terminals on the ESP-12E Motor Shield. There should be labeled motor outputs (typically marked as Motor A, Motor B or similar).
  3. Connect the wires from your BO motors to the motor shield:
  4. Connect the two motors on the left side to one motor output (e.g., Motor A)
  5. Connect the two motors on the right side to the other motor output (e.g., Motor B)
  6. Make sure to match the polarity (+ and -) as shown in the diagram
  7. For each motor:
  8. Connect the positive (red) wire to the positive terminal
  9. Connect the negative (black) wire to the negative terminal
  10. Note: If motors run in the wrong direction later, you can swap these connections
  11. Connect your battery to the power input terminals on the motor shield:
  12. Connect the positive (red) wire from the battery to the VIN terminal
  13. Connect the negative (black) wire from the battery to the GND terminal
  14. Double-check that your battery voltage is appropriate for the motor shield (typically 7-12V)
  15. Check all connections to ensure they're secure and that there are no loose wires or short circuits.
  16. If your motor shield has jumpers or switches for selecting power modes, ensure they're set correctly according to your power supply.
  17. Organize and secure all wires with zip ties or tape to prevent them from getting tangled or disconnected while the car is moving.


Program the NodeMCU With Following Code

image.png
  1. Install the Arduino IDE if you haven't already:
  2. Download from arduino.cc
  3. Install it on your computer
  4. Set up Arduino IDE for ESP8266:
  5. Open Arduino IDE
  6. Go to File > Preferences
  7. In "Additional Boards Manager URLs", add: http://arduino.esp8266.com/stable/package_esp8266com_index.json
  8. Go to Tools > Board > Boards Manager
  9. Search for "esp8266" and install the ESP8266 package
  10. Install Required Libraries:
  11. Go to Tools > Manage Libraries
  12. Search for and install "ESP8266WiFi" and "ESP8266WebServer" libraries if they aren't already installed
  13. Configure Board Settings:
  14. Go to Tools > Board > ESP8266 Boards > NodeMCU 1.0 (ESP-12E Module)
  15. Set the appropriate port under Tools > Port (it will appear when your NodeMCU is connected)
  16. Set Upload Speed to 115200
  17. Copy and Upload the Code:
  18. Create a new sketch in Arduino IDE
  19. Copy and paste all the code from the provided file
  20. Make sure your NodeMCU is connected to your computer via USB
  21. Click the Upload button (right arrow icon) in the Arduino IDE
  22. Verify Upload Success:
  23. Open the Serial Monitor (Tools > Serial Monitor)
  24. Set the baud rate to 115200
  25. You should see messages indicating successful initialization:
[ ]

AP IP address: 192.168.4.1
HTTP server started
Robot Control Center Initialized
Connect to Wi-Fi network: RoboCar
Password: 12345678
Then navigate to <http://192.168.4.1>


Downloads

Power on the Wifi Car by Connecting Batteries

image.png

Now that your NodeMCU is programmed and all components are connected, it's time to power on your WiFi-controlled car:

  1. Prepare the 12V battery pack:
  2. Make sure your battery pack is fully charged
  3. If using rechargeable batteries, ensure they're properly inserted in the battery holder
  4. If using a LiPo battery, check that it's not damaged and is safely secured to the chassis
  5. Connect the battery to the motor shield:
  6. Connect the positive (red) wire from the battery to the VIN terminal on the motor shield
  7. Connect the negative (black) wire from the battery to the GND terminal
  8. Double-check the polarity is correct to avoid damaging the components
  9. Safety check before powering on:
  10. Ensure all wires are properly connected and insulated
  11. Check that there are no loose connections or short circuits
  12. Make sure the motors and wheels can spin freely without obstruction
  13. Place the car on a flat surface or elevated platform so the wheels don't immediately make contact with the ground
  14. Power sequence:
  15. First, connect the USB cable to the NodeMCU to power the microcontroller (optional if running on battery only)
  16. Then connect the battery to power the motors
  17. You should see the blue LED on the NodeMCU light up, indicating it's powered on
  18. After a few seconds, the NodeMCU will initialize and create the WiFi access point
  19. Verify operation:
  20. Look for the "RoboCar" WiFi network on your smartphone or laptop
  21. Connect to the network using the password "12345678"
  22. Open a web browser and navigate to http://192.168.4.1
  23. The robot control interface should appear on your screen
  24. Test basic movements:
  25. Start with low speed settings (around 400-500)
  26. Test each direction (forward, reverse, left, right) briefly to ensure motors are responding correctly
  27. If wheels spin in the wrong direction, you may need to swap the motor wire connections

Your WiFi car should now be fully operational and ready for driving! You can control it through the web interface on your phone or computer while connected to its WiFi network.

Use Your Wifi Car

NodeMCU Wifi Car Demo
  1. Power your car with the 12V battery
  2. Connect to the "RoboCar" WiFi network on your smartphone or computer
  3. Password: 12345678
  4. Open a web browser and navigate to http://192.168.4.1
  5. You'll see the control interface with two modes:
  6. Joystick mode: Drag the joystick for precise control
  7. Button mode: Use directional buttons for simpler control
  8. Use the slider to adjust maximum motor speed

If you encounter any issues during uploading, try:

  1. Checking your USB connection
  2. Pressing the reset button on the NodeMCU before uploading
  3. Making sure you've selected the correct board and port in Arduino IDE