Sunday, September 8, 2024

Motor Controller Utilizing Webserial | Full Electronics Challenge


Remark errors or corrections discovered for this circuit, and get the prospect to win massive!

Controlling two DC motors utilizing Internet Serial entails organising an ESP8266 or ESP32 microcontroller with motor drivers and an internet server. The microcontroller serves net pages and handles instructions despatched through Internet Serial from a browser. Motor management is achieved by capabilities that interpret instructions like “ahead”, “backward”, and “cease”. Every motor requires devoted GPIO pins for course management (utilizing H-Bridge motor drivers) and PWM pins for velocity management. The system ensures strong energy administration to deal with motor currents and maintains communication integrity between the microcontroller and net browser for real-time management and monitoring.

Creator’s Prototype

Software

This setup allows distant operation and automation of DC motors, making it appropriate for robotics, residence automation, and industrial purposes the place exact motor management through an internet interface is useful.

Invoice of Supplies (BoM)

Parts Description Amount
Esp32 Dev equipment V1 1
Motor Driver L293D 1
Motor 9V Dc Motor 2
Battery 9V 1
Zumper Wire As required

Coding

#embrace <Arduino.h>

#if outlined(ESP8266)

  #embrace <ESP8266WiFi.h>

– Commercial –

  #embrace <ESPAsyncTCP.h>

#elif outlined(ESP32)

  #embrace <WiFi.h>

– Commercial –

  #embrace <AsyncTCP.h>

#endif

#embrace <ESPAsyncWebServer.h>

#embrace <WebSerial.h>

AsyncWebServer server(80);

const char* ssid = “Webserial”; // Your WiFi AP SSID

const char* password = “lkjhgfdsa2”; // Your WiFi Password

// Outline motor management pins

const int motorPin1 = 4; // IN1

const int motorPin2 = 5; // IN2

const int enablePin = 27; // Allow pin (PWM)

const int motorPin3 = 14; // IN3

const int motorPin4 = 12; // IN4

const int enablePin2 = 13; // Allow pin for second motor (PWM)

// Message callback of WebSerial

void recvMsg(uint8_t *knowledge, size_t len) {

  WebSerial.println(“Obtained Information…”);

  String command = “”;

  for (int i = 0; i < len; i++) {

    command += char(knowledge[i]);

  }

  WebSerial.println(command);

  processCommand(command);

}

void processCommand(String command) {

  if (command == “F”) {

    moveForward();

  } else if (command == “B”) {

    moveBackward();

  } else if (command == “S”) {

    stopMotor();

  } else {

    WebSerial.println(“Unknown command”);

  }

}

void moveForward() {

  digitalWrite(motorPin1, HIGH);

  digitalWrite(motorPin2, LOW);

  analogWrite(enablePin, 255); // Set velocity to most

  digitalWrite(motorPin3, HIGH);

  digitalWrite(motorPin4, LOW);

  analogWrite(enablePin2, 255); // Set velocity to most

  WebSerial.println(“Motors shifting ahead”);

}

void moveBackward() {

  digitalWrite(motorPin1, LOW);

  digitalWrite(motorPin2, HIGH);

  analogWrite(enablePin, 255); // Set velocity to most

  digitalWrite(motorPin3, LOW);

  digitalWrite(motorPin4, HIGH);

  analogWrite(enablePin2, 255); // Set velocity to most

  WebSerial.println(“Motors shifting backward”);

}

void stopMotor() {

  digitalWrite(motorPin1, LOW);

  digitalWrite(motorPin2, LOW);

  analogWrite(enablePin, 0); // Cease the primary motor

  digitalWrite(motorPin3, LOW);

  digitalWrite(motorPin4, LOW);

  analogWrite(enablePin2, 0); // Cease the second motor

  WebSerial.println(“Motors stopped”);

}

 void setup() {

  Serial.start(115200);

  // Initialize motor management pins

  pinMode(motorPin1, OUTPUT);

  pinMode(motorPin2, OUTPUT);

  pinMode(enablePin, OUTPUT);

  pinMode(motorPin3, OUTPUT);

  pinMode(motorPin4, OUTPUT);

  pinMode(enablePin2, OUTPUT);

  // Initialize WiFi AP

  WiFi.softAP(ssid, password);

  IPAddress IP = WiFi.softAPIP();

  Serial.print(“AP IP deal with: “);

  Serial.println(IP);

  // Initialize WebSerial

  WebSerial.start(&server);

  WebSerial.msgCallback(recvMsg);

  server.start();

}

void loop() {

  delay(2000);

  WebSerial.print(F(“IP deal with: “));

  WebSerial.println(WiFi.localIP());

  WebSerial.printf(“Millis=%lun”, millis());

  WebSerial.printf(“Free heap=[%u]n”, ESP.getFreeHeap());

}

Connection

Circuit Diagram

Testing

Join all of the parts as per the given connections after which join the ESP32 to your pc utilizing a USB cable. Add the code and join your telephone wifi with webserial then open an internet browser in your cellular or laptop computer. Kind (192.168.4.1/webserial) and enter the instructions within the webserial interface.

Use the next instructions:

  • “F” to maneuver ahead
  • “B” to maneuver backward
  • “S” to cease the motors
Testing

Creator: Manjeet Vishwakarma, He’s a B.Tech Electronics and Communication Engineering scholar at GJUS&T HISAR


👇Observe extra 👇
👉 bdphone.com
👉 ultraactivation.com
👉 trainingreferral.com
👉 shaplafood.com
👉 bangladeshi.assist
👉 www.forexdhaka.com
👉 uncommunication.com
👉 ultra-sim.com
👉 forexdhaka.com
👉 ultrafxfund.com
👉 ultractivation.com
👉 bdphoneonline.com

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles