Hi All!
My problem is that I am trying to initiate a call with my SIM900 GSM board based on a distance measurement using an ultrasonic sensor (HCSR04) and the call does not happen. I am using Arduino Uno.
I am not sure if this is a programming issue or a hardware issue (not enough power maybe?). Calling is working with the same hardware if I use a simple call.Call command in the loop without the sensor. So the power is enough for the GSM board if I do not use the sensor. I do not know the sensor's power consumption. I connected the sensor's VCC to the 5V pin on the Arduino.
#include <SoftwareSerial.h>
#include "SIM900.h"
#include "sms.h"
#include "call.h"
SMSGSM sms;
CallGSM call;
#define echoPin 8 // Echo Pin
#define trigPin 9 // Trigger Pin
int distance;
int safetyDistance;
long duration;
const int ledPin = 13;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
gsm.begin(9600); // for GSM shield
delay(1500);
Serial.begin(9600); // for serial monitor
delay(1500);
}
void loop() {
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
// Clears the trigPin
digitalWrite(trigPin, LOW);
delay(500);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delay(1000);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration/58.2;
safetyDistance = distance;
if (safetyDistance <= 50){
delay(8000);
digitalWrite(ledPin, HIGH);
call.Call("+36306004751");
delay(3000);
Serial.println("dialing");
delay(10000); // wait for 30 seconds...
call.HangUp();
delay(4000);
}
else
{
Serial.println("No movement");
digitalWrite(ledPin, LOW);
}
}
Please help me to resolve it. I would need it for security reasons for my remote location.
Thank you in advance.