Wi-Fi Controlled Robot using NodeMCU

Components Required

  1. NodeMCU (ESP-12e)
  2. L293D or L298 motor driver IC
  3. 2 x DC motors
  4. Ultrasonic Sensors (HC-SR04)
  5. 12v Battery
  6. 5v Power supply (optional)

L298D motor driver module has an inbuilt 5v supply but if you are using L293D IC, then you have to make a 5v power supply circuit using 7805 IC.

Circuit Diagram

Complete circuit diagram Wi-Fi controlled car using NodeMCU is given below:

Wi-Fi controlled Robot Circuit Diagram

Connections for the circuit is given below:

IN1 pin of L298 -> D6 of NodeMCU

IN2 pin of L298 -> D7 of NodeMCU

IN3 pin of L298 -> D1 of NodeMCU

IN4 pin of L298 -> D3 of NodeMCU

Trig pin of sensor -> D4 of NodeMCU

Echo pin of sensor -> D8 of NodeMCU

Vin of NodeMCU -> 12v battery

5v and GND of sensor -> 5v and GND of L298 module.

12v of L298 module -> 12v battery

To adjust the speed of the motor, use enables pins of a driver module and connect them to the PWM pin of NodeMCU (D2, D5) otherwise connect them to 5v using a jumper.

The final setup for Web controlled Robot will look like this

Wi-Fi controlled Robot using NodeMCU

Code and Explanation

To program NodeMCU with Arduino IDE go to File–>Perferences–>Settings.

Programing NodeMCU with Arduino IDE for IoT based Temperature and Humidity Monitor

 

Enter http:// arduino.esp8266.com/stable/package_esp8266com_index.json into ‘Additional Board Manager URL’ field and click ‘Ok’.

Add URL to Arduino IDE for IoT based Temperature and Humidity Monitor

 

Now go to Tools > Board > Boards Manager.

Manage Board in Arduino IDE for IoT based Temperature and Humidity Monitor

 

In Boards Manager window, Type esp in the search box, esp8266 will be listed there below. Now select latest version of board and click on install.

Install ESP8266 Library to Arduino IDE for IoT based Temperature and Humidity Monitor