[Help]How to Detect/Sense an Air Pressure with Arduino?

Good day to everyone, I'm new here and newbie as well,

I would like to ask any help regarding on this problem:

How can I send an SMS message as notification if the air pressure/sensor detected that the air is low or 0 value?

I mean like this: TANK1 and TANK2

if (TANK1_airpressure == 0 or LOW) then send SMS to notify that the tank1 with air is empty now and need for replacement or refill?

and also...

if (TANK2_airpressure == 0 or LOW) then send SMS to notify that the tank2 with air is empty now and need for replacement or refill?

Thanks in advanced to all! :slight_smile:
@mods, If my post is in wrong section, I'm sorry :cold_sweat: and please move my post to the right section... Thanks a lot

Do you have http://arduino.cc/en/Main/ArduinoGSMShield sheild with you.
let us know which pressure sensor your using . share us data sheet.

depend upon your sensor we continue in writing code'

if (TANK1_airpressure == 0 or LOW) then send SMS to notify that the tank1 with air is empty now and need for replacement or refill?

and also...

if (TANK2_airpressure == 0 or LOW) then send SMS to notify that the tank2 with air is empty now and need for replacement or refill?

As AMPS-N says you need a GSM shield of your choice to send the SMS.

And given that 0 is very low indeed you only need to check if the pressure is below a certain thereshold. No ORs involved.

Thanks to all replies, :slight_smile:

Here's the list of hardware that I will use in my thesis in school as student:

  1. Arduino Uno
  2. GSM/GPRS Shield
  3. SUNX - DP2-22Z DS (air pressure meter/sensor)
    link:
    Search Panasonic Products By Series | Ramco Innovations

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

Thanks for the help, I really appreciate it.

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.

AMPS-N:
Let us know which shield you are using??

Thanks for the quick reply,

Here's the shield I will use: http://store.tinkbox.ph/products?search_api_views_fulltext=gsm+shield

i have shared you link already . just try simple code. sending & receiving messages
http://www.cooking-hacks.com/documentation/tutorials/arduino-gprs-gsm-quadband-sim900

Simple code to send sms.

#include <GSM.h>

#define PINNUMBER ""

// initialize the library instance
GSM gsmAccess;
GSM_SMS sms;

void setup()
{
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  
  Serial.println("SMS Messages Sender");

  // connection state
  boolean notConnected = true;

  // Start GSM shield
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while(notConnected)
  {
    if(gsmAccess.begin(PINNUMBER)==GSM_READY)
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }
  
  Serial.println("GSM initialized");
}

void loop()
{

  Serial.print("Enter a mobile number: ");
  char remoteNum[20];  // telephone number to send sms
  readSerial(remoteNum);
  Serial.println(remoteNum);
    
  // sms text
  Serial.print("Now, enter SMS content: ");
  char txtMsg[200];
  readSerial(txtMsg);
  Serial.println("SENDING");
  Serial.println();
  Serial.println("Message:");
  Serial.println(txtMsg);
  
  // send the message
  sms.beginSMS(remoteNum);
  sms.print(txtMsg);
  sms.endSMS(); 
  Serial.println("\nCOMPLETE!\n");
}

/*
  Read input serial
 */
int readSerial(char result[])
{
  int i = 0;
  while(1)
  {
    while (Serial.available() > 0)
    {
      char inChar = Serial.read();
      if (inChar == '\n')
      {
        result[i] = '\0';
        Serial.flush();
        return 0;
      }
      if(inChar!='\r')
      {
        result[i] = inChar;
        i++;
      }
    }
  }
}

@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)

Thank you so much!

I don't want to write code for you. First make ensure your basic interface working fine.

Note: Here no one write code for you. If you have written they make correction,or changes.

we follow these step

  1. make ensure GSM sheild working fine.
  2. write code to interface SUNX - DP2-22Z DS (air pressure meter/sensor) for getting analog read values. & convert it to pressure .
  3. create condition where

pressure meter/sensor read a 0 (zero) value or LOW?

output it on serial monitor.don't add GSM shield here.
4)Then combine both code. let me know what are the problem you gets.

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.

thanks for the help, for now I will try to write codes and present it here and please guide me if I'm doing it right

thanks again! cheers! XD

Hi to all and Happy Holidays too,

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);
    }
  }
 }
}