Arduino UNO-Based GPS and GSM Controlled Motor System with LED Indicators
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit integrates an Arduino UNO microcontroller with various components including a 12V 200Ah battery, a SIM800L GSM module, a Neo 6M GPS module, multiple LEDs, a buzzer, a DC motor, and an L298N DC motor driver. The Arduino UNO controls the components based on received GSM messages and GPS data. The circuit is designed to perform actions such as turning on/off the motor and LEDs, and sending location data via SMS.
Component List
Arduino UNO
- Description: Microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
12V 200Ah Battery
- Description: Power source for the circuit.
- Pins: GND, 12V
SIM800L GSM Module
- Description: GSM module for sending and receiving SMS.
- Pins: NFT, RING, VCC, DTR, RST, MIC +, RXD, MIC-, TXD, SPK+, GND, SPK-
Neo 6M GPS Module
- Description: GPS module for obtaining location data.
- Pins: GND, TX, RX, VCC
LED: Two Pin (red)
- Description: Red LED for visual indication.
- Pins: cathode, anode
Buzzer
- Description: Buzzer for audio indication.
- Pins: PIN, GND
DC Motor
- Description: DC motor for mechanical movement.
- Pins: pin 1, pin 2
L298N DC Motor Driver
- Description: Motor driver for controlling the DC motor.
- 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
Wiring Details
Arduino UNO
- 3.3V connected to VCC of Neo 6M GPS Module
- 5V connected to VCC of SIM800L GSM Module
- GND connected to:
- GND of SIM800L GSM Module
- GND of Neo 6M GPS Module
- GND of L298N DC Motor Driver
- Vin connected to 5V of L298N DC Motor Driver
- D12 connected to RX of Neo 6M GPS Module
- D10 connected to ENA of L298N DC Motor Driver
- D9 connected to IN1 of L298N DC Motor Driver
- D8 connected to IN2 of L298N DC Motor Driver
- D7 connected to RXD of SIM800L GSM Module
- D6 connected to TXD of SIM800L GSM Module
- D5 connected to PIN of Buzzer
- D4 connected to cathode of LED (red)
- D3 connected to cathode of LED (red)
- D2 connected to TX of Neo 6M GPS Module
12V 200Ah Battery
- GND connected to GND of L298N DC Motor Driver
- 12V connected to 12V of L298N DC Motor Driver
SIM800L GSM Module
- VCC connected to 5V of Arduino UNO
- GND connected to GND of Arduino UNO
- RXD connected to D7 of Arduino UNO
- TXD connected to D6 of Arduino UNO
Neo 6M GPS Module
- VCC connected to 3.3V of Arduino UNO
- GND connected to GND of Arduino UNO
- TX connected to D2 of Arduino UNO
- RX connected to D12 of Arduino UNO
LED: Two Pin (red)
- anode connected to GND of Arduino UNO
- cathode connected to D4 of Arduino UNO
Buzzer
- PIN connected to D5 of Arduino UNO
- GND connected to GND of Arduino UNO
DC Motor
- pin 2 connected to OUT3 of L298N DC Motor Driver
L298N DC Motor Driver
- GND connected to GND of Arduino UNO
- 5V connected to Vin of Arduino UNO
- ENA connected to D10 of Arduino UNO
- IN1 connected to D9 of Arduino UNO
- IN2 connected to D8 of Arduino UNO
- 12V connected to 12V of 12V 200Ah Battery
Code Documentation
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
SoftwareSerial gsmSerial(6, 7); // TX for GSM, RX for GSM
SoftwareSerial neo(2, 12); // TX for GPS, RX for GPS
TinyGPSPlus gps;
// Motor and LED pins
int led1 = 11;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int motorEN = 10;
int motorIN1 = 9;
int motorIN2 = 8;
String textMessage = "";
String lati = "";
String longi = "";
// Variables for non-blocking blinking
unsigned long lastBlinkTime = 0;
bool isBlinking = false;
void setup() {
Serial.begin(9600);
gsmSerial.begin(9600);
delay(5000);
Serial.println("Initializing GSM...");
gsmSerial.println("AT");
checkGSMResponse();
gsmSerial.println("AT+CMGF=1");
checkGSMResponse();
gsmSerial.println("AT+CNMI=2,2,0,0,0");
checkGSMResponse();
neo.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(motorEN, OUTPUT);
pinMode(motorIN1, OUTPUT);
pinMode(motorIN2, OUTPUT);
analogWrite(motorEN, 0);
digitalWrite(motorIN1, LOW);
digitalWrite(motorIN2, LOW);
Serial.println("System initialized.");
}
void loop() {
gsmSerial.listen();
delay(2);
if (gsmSerial.available() > 0) {
textMessage = gsmSerial.readString();
textMessage.trim();
Serial.println("Received message: " + textMessage);
if (textMessage.indexOf("ON") != -1) {
handleOnMessage();
} else if (textMessage.indexOf("OFF") != -1) {
handleOffMessage();
} else if (textMessage.indexOf("GETLOC") != -1) {
handleGetLocMessage();
}
textMessage = "";
}
blinkLeds34Continuously();
}
void handleOnMessage() {
Serial.println("Executing ON command");
digitalWrite(led1, HIGH);
digitalWrite(motorIN1, HIGH);
digitalWrite(motorIN2, LOW);
analogWrite(motorEN, 255);
stopBlinkingLeds34();
}
void handleOffMessage() {
Serial.println("Executing OFF command");
digitalWrite(led1, LOW);
blinkLED2();
reduceMotorSpeed();
startBlinkingLeds34();
}
void blinkLED2() {
for (int i = 0; i < 5; i++) {
digitalWrite(led2, HIGH);
delay(300);
digitalWrite(led2, LOW);
delay(300);
}
}
void reduceMotorSpeed() {
int reductionDelay = 100;
int steps = 255 / (10000 / reductionDelay);
for (int speed = 255; speed >= 0; speed -= steps) {
analogWrite(motorEN, speed);
delay(reductionDelay);
}
analogWrite(motorEN, 0);
}
void blinkLeds34Continuously() {
if (!isBlinking) return;
unsigned long currentMillis = millis();
if (currentMillis - lastBlinkTime >= 100) {
lastBlinkTime = currentMillis;
digitalWrite(led3, !digitalRead(led