Problem:
If (tank1_aircontent is LOW or 0) activate tank2 then send SMS message that tank1 is empty and need for replacement
If (tank2_aircontent is LOW or 0) activate tank 1 then send SMS message that tank2 is empty and need for replacement
Have you done any programming on GSM sheilds??
If not
Let us know which shield you are using??
Here is example code.try it out . put snap shot of serial monitor.
@Sir AMPS-N, thanks a lot for your quick reply, i really appreciate your help
one thing I found in the example you've given is that: it used Serial Monitor, if you don't mind can you help me showing an automatic sending of sms when the pressure meter/sensor read a 0 (zero) value or LOW? (also based on the hardware I've mentioned above)
Since in data sheet w.r.t analog voltage output they not mentioned expected air pressure,It is difficult to write code
so you can do one thing since you have module with you just check output voltage @ various pressure w.r.t analog voltage. Create table
for 0.5 v analog note pressure you got
similarly for 2.5V, 5V,
create for at least 2-3 reading more.
connection diagram is already given in datasheet. page 7
The TinySine shield is a nice one. Nice long pins to keep it away from the Arduino! If you've not already been told use pins 2 & 3 to communicate with it (jumpers to software position). I don't know how quickly the tanks are likely to empty but the SIM900 has a built in clock so you can use that to check when you need to query the sensors.
I've created this code, the switching of tank is working BUT the problem is the alarm, it did not stop when I press the pull-up switch (tact switch) and it did NOT send an SMS message to the number I assigned.
Please Help me, I will really appreciate any help. Thanks in advanced
Here's the Code:
#include<SoftwareSerial.h>
SoftwareSerial SIM900(1,2); // configure software serial port
const int switchpin = 4;
int SensePin1=5;
int SensePin2=6;
int Tank1Driver=8;
int AlarmDriver=9;
int Tank1Monitor=10;
int Tank2Monitor=11;
int Tank1State=0;
int Tank2State=0;
int switchstate = 0;
int alarmstate = 0;
void setup()
{
pinMode(switchpin,INPUT);
pinMode(SensePin1,INPUT);
pinMode(SensePin2,INPUT);
pinMode(Tank1Driver,OUTPUT);
pinMode(AlarmDriver,OUTPUT);
pinMode(Tank1Monitor,OUTPUT);
pinMode(Tank2Monitor,OUTPUT);
SIM900.begin(19200);
SIM900power();
delay(2000); // give time to log on to network
}
void SIM900power() // software equivalent of pressing the GSM shield "power" button
{
digitalWrite(3,HIGH);
delay(1000);
digitalWrite(3,LOW);
delay(5000);
}
void sendSMS1() //send this message if tank 1 is empty
{
SIM900.print("AT+CMFG=1\r"); // AT command to send SMS message
delay(100);
SIM900.println("AT+CMGS = \"+639331927173\""); // (recipient's mobile number)
delay(100);
SIM900.println("TANK 1 should be replaced immediately!"); // message to send
delay(100);
SIM900.println();
delay(5000); // give module time to send SMS
SIM900power(); // turn off module
}
void sendSMS2() //send this message if tank 2 is empty
{
SIM900.print("AT+CMFG=1\r"); // AT command to send SMS message
delay(100);
SIM900.println("AT+CMGS = \"+639331927173\""); // (recipient's mobile number)
delay(100);
SIM900.println("TANK 2 should be replaced immediately!"); // message to send
delay(100);
SIM900.println();
delay(5000); // give module time to send SMS
SIM900power(); // turn off module
}
void sendSMS3() //send this message if both tank 1 and 2 is empty
{
SIM900.print("AT+CMFG=1\r"); // AT command to send SMS message
delay(100);
SIM900.println("AT+CMGS = \"+639331927173\""); //(recipient's mobile number)
delay(100);
SIM900.println("CRITICAL CONDITION! BOTH TANK IS EMPTY!"); // message to send
delay(100);
SIM900.println();
delay(5000); // give module time to send SMS
SIM900power(); // turn off module
}
void loop()
{
Tank1State=digitalRead(SensePin1);
Tank2State=digitalRead(SensePin2);
switchstate = digitalRead(switchpin);
if (Tank1State==1 && Tank2State==1) //both tank full
{
digitalWrite(Tank1Driver,LOW); //set tank1 as default
digitalWrite(AlarmDriver,LOW);
digitalWrite(Tank1Monitor,HIGH);
digitalWrite(Tank2Monitor,HIGH);
}
else if (Tank1State==0 && Tank2State==1) //tank1 empty, tank2 full
{
digitalWrite(Tank1Driver,HIGH); //switch to tank2
digitalWrite(Tank1Monitor,LOW);
digitalWrite(Tank2Monitor,HIGH);
//Send_SMS()
sendSMS1();
do { } while(1); // do nothing
//activate alarm
digitalWrite(AlarmDriver,HIGH);
if (switchstate == LOW)
{
stopalarm();
}
}
else if (Tank1State== 1 && Tank2State==0) //tank1 full, tank2 empty
{
digitalWrite(Tank1Driver,LOW); //switch to tank1
digitalWrite(Tank1Monitor,HIGH);
digitalWrite(Tank2Monitor,LOW);
//Send_SMS()
sendSMS2();
do { } while(1); // do nothing
//activate alarm
digitalWrite(AlarmDriver,HIGH);
if (switchstate == LOW)
{
stopalarm();
}
}
else //both tank empty (Tank1State== 0 && Tank2State==0)
{
digitalWrite(Tank1Driver,LOW); //set tank1 as default
digitalWrite(Tank1Monitor,LOW);
digitalWrite(Tank2Monitor,LOW);
//Send_SMS()
sendSMS3();
do { } while(1); // do nothing
//activate alarm
digitalWrite(AlarmDriver,HIGH);
if (switchstate == LOW)
{
stopalarm();
}
}
}
void stopalarm()
{
while (digitalRead(switchpin) == 0);
{
if (alarmstate == 0)
{
while(alarmstate == 0)
{
digitalWrite(AlarmDriver, LOW);
}
}
}
}