ACool
Published © GPL3+

Rover for Cave Exploration

The purpose of our creation is to detect whether a cave is safe to enter without human intervention.

IntermediateFull instructions provided7,981
Rover for Cave Exploration

Things used in this project

Hardware components

Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Jumper wires (generic)
Jumper wires (generic)
×1
4WD Chassis
×1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
Li-Ion Battery 1000mAh
Li-Ion Battery 1000mAh
×4
MQ 5
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Arduino UNO
Arduino UNO
×1
MQ 135
×1

Software apps and online services

MIT App Inventor Control Data

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

Diagram

Diagram for wiring and connections.

Code

Coding for arduino

C/C++
its the code to be uploaded to the Arduino.
#include <dht.h>
#define dataPin 8 // Defines pin number to which the sensor is connected
char bt;
int trig_pin = 12;
int echo_pin = 9;
int airquality = A3 ;
dht DHT; // Creats a DHT object
long echotime; //in micro seconds
float distance; //in cm
unsigned long interval=2000;     // the time we need to wait
unsigned long previousMillis=0;  // millis() returns an unsigned long.

void setup() {
  Serial.begin (9600);
  pinMode(2,OUTPUT);   //left motors forward
  pinMode(3,OUTPUT);   //left motors reverse
  pinMode(4,OUTPUT);   //right motors forward
  pinMode(7,OUTPUT);   //right motors reverse
  pinMode(trig_pin, OUTPUT); 
  pinMode(echo_pin, INPUT);
  digitalWrite(trig_pin, LOW); //Start with trigger LOW
}

void loop() {
  if(Serial.available()){
  bt = Serial.read();
  Serial.println(bt);
}

if(bt == 'F'){            //move forward(all motors rotate in forward direction)
  digitalWrite(2,HIGH);
  digitalWrite(3,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(7,LOW);
}
 
else if(bt == 'B'){      //move reverse (all motors rotate in reverse direction)
  digitalWrite(2,LOW);
  digitalWrite(3,HIGH);
  digitalWrite(4,LOW);
  digitalWrite(7,HIGH);
}
 
else if(bt == 'L'){      //turn right (left side motors rotate in forward direction, right side motors rotate in reverse direction)
  digitalWrite(2,LOW);
  digitalWrite(3,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(7,LOW);
}
 
else if(bt == 'R'){      //turn left (right side motors rotate in forward direction, left side motors rotate in reverse direction)
  digitalWrite(2,HIGH);
  digitalWrite(3,LOW);
  digitalWrite(4,LOW);
  digitalWrite(7,HIGH);
}
 
else if(bt == 'S'){      //STOP (all motors stop)
  digitalWrite(2,LOW);
  digitalWrite(3,LOW);
  digitalWrite(4,LOW);
  digitalWrite(7,LOW);
}

unsigned long currentMillis = millis(); // grab current time
 
 // check if "interval" time has passed (2000 milliseconds)
 if ((unsigned long)(currentMillis - previousMillis) >= interval) {
 
  //trigger a pulse-echo measurement
  digitalWrite(trig_pin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig_pin, LOW);

  //get the result
  echotime= pulseIn(echo_pin, HIGH);
  distance= (0.0001*((float)echotime*340.0)/2.0);
  
  //send over Bluetooth 
  Serial.print("|");
  Serial.print(distance);

  int readData = DHT.read22(dataPin); // Reads the data from the sensor
  float t = DHT.temperature; // Gets the values of the temperature
  float h = DHT.humidity; // Gets the values of the humidity
  
  // Printing the results on the serial monitor
  Serial.print("|");
  Serial.print(t);
  Serial.print("|");
  Serial.print(h);

  //Read Analog pin 5 for sensor MQ 135 data
  int sensorValueMQ135 = analogRead(A3);

  //send over Bluetooth
  Serial.print("|");
  Serial.print(sensorValueMQ135);

  //Get MQ 5 sensor data
  float sensor_volt;
  float sensorValueMQ5;
  sensorValueMQ5 = analogRead(A4);
  
  
  //send over Bluetooth
  Serial.print("|");
  Serial.print(sensorValueMQ5);
  
  previousMillis = millis();
  }


}

Credits

ACool

ACool

0 projects • 5 followers

Comments