Controlling DC Motor From Internet

by WaqasA76 in Circuits > Arduino

713 Views, 1 Favorites, 0 Comments

Controlling DC Motor From Internet

Wifi Control of DC Motor using ESP8266
Control Arduino from Internet
Arduino DC Motor Control

DC motor is controlled using Esp8266 node mcu, Arduino Uno and IBT-2.

Supplies

Following items/parts are needed for this poject.

  1. Arduino Uno
  2. Esp 8266 node mcu.
  3. Arduino IDE to program Arduino and esp 8266
  4. A DC motor:a second hand car wiper motor can be used
  5. Power supply 12V DC;power adapter 220V AC to 12V DC will suffice
  6. A breadboard
  7. Jumper wires; male-male, and female-male
  8. IBT-2
  9. An internet connection
  10. An android phone or pc to open web page

Programming the Esp 8266 Node MCU


We shall use the digital out pins of node mcu to run the motor. Two digital out pins are used; pin 2 and pin 12. When one digital pin is high the motor moves clockwise and when the other pin is high, motor will move anticlockwise. Esp 8266 is programmed so that the two digital pins can be turned high and low from a webpage hosted on esp 8266. The program file is provided as esp-8266.ino. In order to program node mcu, connect it to a PC with Arduino IDE installed. Open Arduino IDE, go to tools--board--ESP8266 boards--Node MCU1.0.Make sure to include the library file ESP8266WiFi.h.The program file is provided as esp-8266.ino.The url to download ESP8266 library can be downloaded from github url:https://github.com/Hieromon/ESP8266.

After the program is uploaded, open the serial monitor and select baud rate 11500.When esp 8266 establishes internet connection, an ip address will be shown. Note down this ip address. This is the ip address of the webpage hosted on esp 8266, through which we control the DC motor.

Downloads

Programming the Arduino

Arduino board is programmed to perform two main functions:


  1. To read digital output signals from the pins of node mcu.
  2. Command the DC motor to run either clockwise or anticlockwise based on the signal status through IBT-2.


Arduino's two analog pins are used to read digital signals from node mcu pins 2 and 12. Based on the pin number of node mcu , one of the two pwm pins of arduino, pin 5 and pin 6 can be made high. Pwm signal from either pin 5 or pin 6(whichever is high) goes to IBT-2 amplifier which then turns the motor. The file containing the code is attached.

Basically, in our project when the digital pin 2 of node mcu is high it is read by the analog pin A0 of arduino. The arduino's pwm pin 6 then becomes low while the pwm pin 5 of arduino becomes high and the motor moves clockwise. When the digital pin 12 of node mcu provides high signal, it is read by the arduino analog pin A2.The pwm pin 5 of the arduino then becomes low while pwm pin 6 becomes high and motor moves counterclockwise. In this way, motor's rotation direction is controlled by turning on the appropriate pin of the node mcu. The program file is provided as Arduino-DC.ino.

The value of pwm can be changed. I have used a value of 44, however this value can be increased to 255 for getting maximum speed out of motor.

Downloads

Esp8266 Arduino Cicuit Connection

CicuitConnections.jpg
Arduino-esp.jpg

The connections between Arduino and esp 8266 node mcu are shown in Fig. The complete circuit diagram of project is also shown. The connections are as under:

  • Node mcu pin 2--Arduino analog pin A0
  • Node mcu pin 12---Arduino analog pin A2
  • Node mcu ground--Common ground on breadboard
  • Arduino ground---Second row from bottom on breadboard(see Fig)
  • Arduino 5V--Bottom most row on breadboard(see Fig)

Arduino IBT-2 Circuit Connections

Arduino-IBT2.jpg

The connections between Arduino and IBT-2 are shown in attached Fig as well as in circuit diagram. The connections are as follows:

  • IBT-2 pin 1---Arduino pwm pin 5
  • IBT 2 pin 2---Arduino pwm pin 6
  • IBT2 pins 3,4,7--5V on breadboard(bottom most row on breadboard)
  • IBT 2 pin 8----Ground on breadboard(second row rom bottom on breadboard)

Note: Both Arduino and Esp 8266 node mcu are powered from their programming cables. Simply connect the programming cables to 5V DC power adapters having usb ports.

Controlling the DC Motor

ServerPage.jpg

In order to control DC motor from internet, using any web browser open enter the ip address from step 1 in the address bar and a page will be opened as shown in the attached Fig above. In order to rotate motor clockwise press Move Right button once. Pressing Stop button will bring motor to stop. Similarly, pressing Move Left button will rotate the motor anticlockwise. Refer to attached video to see a demonstration of project.For basic Arduino web control tutorial using ESP8266, refer to second attached video.

Note :Two additional buttons also appear: Light ON and Light OFF, ignore these buttons.