Arduino GSM Module

Hi, guys. I’m building a fuel theft alert to send text messages to the owners phone using a gsm module.
The sensor that detects the fuel drop is the the arduino ultrasonic sensor.
In the arduino void loop i put an if function in there for when the fuel level drops to a certain value. The challenge is the fuel drops when the driver himself is dropping. Im wiring the device so it’s only activated when the ignition is turned off. I want the device to register the new fuel it comes on as the initial. Is there any code i can use.
i’ve tried saving the distance in another variable and adding a value to it in the id loop but that doesn’t work. Help please. i’m defending it on Monday

You may get more help if you post code instead of an image of code. (Also good to mention the coding language)

The coding language is arduino(C++) and also i posted an image instead of the code because i’m not close to my laptop now. I might forget when i get to it because i’ve been too busy lately.
I will add the code later. thanks

you always have more chance to receiving help if you post your code, so that it can be copied and debugged

Hi, guys. I’m building a fuel theft alert to send text messages to the owners phone using a gsm module.
The sensor that detects the fuel drop is the the arduino ultrasonic sensor.
In the arduino void loop i put an if function in there for when the fuel level drops to a certain value. The challenge is the fuel drops when the driver himself is dropping. Im wiring the device so it’s only activated when the ignition is turned off. I want the device to register the new fuel it comes on as the initial. Is there any code i can use.
i’ve tried saving the distance in another variable and adding a value to it in the id loop but that doesn’t work. Help please. i’m defending it on Monday.
Made this post yesterday. this is my code

#include <SoftwareSerial.h> 
SoftwareSerial SIM900(7, 8); 
#include <NewPing.h> 
const int trigPin = 13; 
const int echoPin = 10; 
float duration, distance; 
#include <LiquidCrystal.h> 
LiquidCrystal lcd(12,11,5,4,3,2); 
 
void setup() 
 
{  
  pinMode(trigPin, OUTPUT); 
  pinMode(echoPin, INPUT); 
  Serial.begin(19200); 
  SIM900.begin(19200); 
  delay(2000); 
  Serial.begin(19200); 
  Serial.print("Initializing..."); //setup for gsm shield 
  lcd.begin(16,2); 
  delay(2000); 
  lcd.print("Initializing..."); 
 
  delay(2000); 
  lcd.clear(); 
 
  delay(2000); 
  lcd.print("Assembling Parts..."); 
   
  delay(2000); 
  lcd.clear(); 
 
  delay(2000); 
  lcd.print("GSM Shield..."); 
 
  delay(2000); 
  lcd.clear(); 
 
 
  delay(2000); 
  lcd.print("Level Sensor..."); 
 
  delay(2000); 
  lcd.clear(); 
 
  delay(2000); 
  lcd.setCursor(0,1); 
  lcd.print("Welcome Joe!"); 
 
  delay(4500); 
  lcd.clear(); 
 
  lcd.setCursor(0,1); 
  lcd.print("STATUS:Safe"); 
   
} 
 
void loop() 
{ 
  digitalWrite(trigPin, LOW); 
  delayMicroseconds(2); 
  digitalWrite(trigPin, HIGH); 
  delayMicroseconds(10); 
  digitalWrite(trigPin, LOW); 
 
  duration = pulseIn(echoPin, HIGH); 
  distance = (duration*0.343)/2; 
 
   Serial.print("Distance: "); 
   Serial.print(distance); 
   Serial.print("cm"); 
   delay(2000);   
 
 
  if((distance>=50)&&(distance<=90 
  )) 
  { 
 
  
   lcd.setCursor(0,1); 
   lcd.print("Dist: "); 
   lcd.print(distance); 
   lcd.print("cm"); 
   delay(500); 
   lcd.setCursor(0,1); 
   lcd.print("STATUS: ALERT!!!!"); 
   delay(500); 
   lcd.clear(); 
    
    
    
   SIM900.println("ATD +233546368451;");  
   delay(10000); 
   SIM900.println(); 
   delay(1000); 
   SIM900.print("AT+CMGF=1\r");   
   delay(1000); 
   SIM900.println("AT+CMGS=\"+233546368451\"\r");  
   delay(1000); 
   SIM900.println("CHECK YOUR VEHICLE OR CALL AUTHORITIES");  
   delay(1000); 
   SIM900.println((char)26);  
   delay(1000); 
   SIM900.println(); 
   delay(5000); 
   Serial.println("SMS sent successfully"); 
   delay(1000); 
   Serial.print("Distance: "); 
   Serial.print(distance); 
   Serial.print("cm"); 
   delay(2000); 
 
   lcd.setCursor(0,1); 
   lcd.print("STATUS:Safe"); 
  } 
  else return; 
}

I merged your topics together as they are about the same thing. (In future please do not create new topics if you are just following up on something you already posted)

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.