Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Uno Wi-Fi Controlled Rover with Ultrasonic and PIR Sensors

View and Edit Project In Cirkit DesignerImage of Arduino Uno Wi-Fi Controlled Rover with Ultrasonic and PIR Sensors

Circuit Documentation

Summary

This document provides a detailed overview of a circuit that integrates various sensors, actuators, and a Wi-Fi module with an Arduino Uno R3 microcontroller. The circuit is designed to control a rover with functionalities such as motion detection, distance measurement, and camera panning. The rover can be controlled via a web interface hosted on the ESP8266 Wi-Fi module.

Component List

  1. Arduino Uno R3

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: D8, D9, D10, D11, D12, D13, GND, AREF, SDA, SCL, D0/RX, D1/Tx, D2, D3, D4, D5, 6, D7, A5/SCL, A4/SDA, A3, A2, A1, A0, Vin, 5V, 3.3V, RESET, IOREF, NONE, USB Jack, Power Jack
  2. HC-SR04 Ultrasonic Sensor

    • Description: A sensor used for distance measurement.
    • Pins: VCC, TRIG, ECHO, GND
  3. PIR Sensor

    • Description: A sensor used for motion detection.
    • Pins: VDD, SIG, GND
  4. Micro Servo 9G

    • Description: A small servo motor used for camera panning.
    • Pins: GND, +5V, PWM
  5. L298N DC Motor Driver

    • Description: A dual H-Bridge motor driver used to control the motors of the rover.
    • Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB
  6. Wi-Fi Module ESP8266-01

    • Description: A Wi-Fi module used to connect the rover to a wireless network.
    • Pins: RX, GPIO0, GPIO2, GND, +3V3, Reset, CH-PD Chip power down, TX
  7. OV7670 Camera Module

    • Description: A camera module used for capturing images.
    • Pins: RET, PWDN, D1, D0, D3, D2, D4, D5, D6, PLK, XLK, D7, VS, HS, SCL, SDA, 3.3V, DGND
  8. 4 x AAA Battery Mount

    • Description: A battery holder for powering the circuit.
    • Pins: -, +

Wiring Details

Arduino Uno R3

HC-SR04 Ultrasonic Sensor

PIR Sensor

Micro Servo 9G

L298N DC Motor Driver

Wi-Fi Module ESP8266-01

OV7670 Camera Module

4 x AAA Battery Mount

Documented Code

#include <ESP8266WiFi.h>
#include <Servo.h>

// Define Wi-Fi credentials
const char* ssid = "YourWiFiSSID";
const char* password = "YourWiFiPassword";

// Define pin connections
const int motorA1 = D2;
const int motorA2 = D3;
const int motorB1 = D4;
const int motorB2 = D5;
const int servoPin = D10;  // Servo motor for camera panning
const int trigPin = D7;    // HC-SR04 Trigger Pin
const int echoPin = D8;    // HC-SR04 Echo Pin
const int pirPin = D9;     // PIR sensor Pin

Servo cameraServo;  // Create Servo object

WiFiServer server(80);  // HTTP server on port 80

void setup() {
  // Start serial communication for debugging
  Serial.begin(115200);

  // Initialize the motor control pins
  pinMode(motorA1, OUTPUT);
  pinMode(motorA2, OUTPUT);
  pinMode(motorB1, OUTPUT);
  pinMode(motorB2, OUTPUT);

  // Initialize the servo motor for camera panning
  cameraServo.attach(servoPin);
  cameraServo.write(90);  // Set initial position to middle (90 degrees)

  // Initialize the HC-SR04 ultrasonic sensor
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

  // Initialize PIR sensor
  pinMode(pirPin, INPUT);

  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("WiFi connected!");

  // Start the server
  server.begin();
  Serial.println("Server started");
}

void loop() {
  // Check for incoming clients (Web browser connection)
  WiFiClient client = server.available();
  if (client) {
    String request = client.readStringUntil('\r');
    client.flush();

    // Print out the received request (for debugging)
    Serial.println(request);

    // Control the rover based on the HTTP request
    if (request.indexOf("/forward") != -1) {
      moveForward();
    }
    else if (request.indexOf("/backward") != -1) {
      moveBackward();
    }
    else if (request.indexOf("/left") != -1) {
      moveLeft();
    }
    else if (request.indexOf("/