"if" no me va con GSM Shield

Hola, estoy haciendo una aplicacion simple que lo que hace es enviar el valor de unas entradas analogicas cuando una de ellas supera un valor. Para ello leo el valor de las entradas y cuando la A0 supera un valor prefijado envia el SMS con los valores.
Bueno no se que pasa pero los envia siempre, haya el valor que haya, incluso si en la entrada hay 0V.
Os pego el codigo que es muy simple.

#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
int sensorPinA0 = 0; // value read from the pot

int sensorPin0 = A0; // select the input pin for the potentiometer
int sensorPin1 = A1; // select the input pin for the potentiometer
int sensorPin2 = A2; // select the input pin for the potentiometer
int sensorPin3 = A3; // select the input pin for the potentiometer

int sensorValue0 = 0; // variable to store the value coming from the sensor
int sensorValue1 = 0; // variable to store the value coming from the sensor
int sensorValue2 = 0; // variable to store the value coming from the sensor
int sensorValue3 = 0; // variable to store the value coming from the sensor

void setup()
{
SIM900.begin(19200);
SIM900power();
delay(20000); // give time to log on to network.
}

void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(5000);
}

void loop()
{
sensorValue0 = analogRead(sensorPin0);
sensorValue1 = analogRead(sensorPin1);
sensorValue2 = analogRead(sensorPin2);
sensorValue3 = analogRead(sensorPin3);

{
if(sensorValue0 > 800)

SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message
delay(100);
SIM900.println("AT + CMGS = "+34617516793""); // recipient's mobile number, in international format
delay(100);
SIM900.println("AGRITRONIC LA SOLANA."); // message to send
SIM900.println("ANALOG 0 = "); // message to send
SIM900.println(sensorValue0);
SIM900.println("ANALOG 1 = "); // message to send
SIM900.println(sensorValue1);
SIM900.println("ANALOG 2 = "); // message to send
SIM900.println(sensorValue2);
SIM900.println("ANALOG 3 = "); // message to send
SIM900.println(sensorValue3);

delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(5000); // give module time to send SMS
SIM900power(); // turn off module

do {} while (1);

}

}

Gracias de antemano.

zeus1971:
Hola, estoy haciendo una aplicacion simple que lo que hace es enviar el valor de unas entradas analogicas cuando una de ellas supera un valor. Para ello leo el valor de las entradas y cuando la A0 supera un valor prefijado envia el SMS con los valores.
Bueno no se que pasa pero los envia siempre, haya el valor que haya, incluso si en la entrada hay 0V.
Os pego el codigo que es muy simple.

#include <SoftwareSerial.h>

SoftwareSerial SIM900(7, 8);
const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to
int sensorPinA0 = 0;        // value read from the pot

int sensorPin0 = A0;    // select the input pin for the potentiometer
int sensorPin1 = A1;    // select the input pin for the potentiometer
int sensorPin2 = A2;    // select the input pin for the potentiometer
int sensorPin3 = A3;    // select the input pin for the potentiometer

int sensorValue0 = 0;  // variable to store the value coming from the sensor
int sensorValue1 = 0;  // variable to store the value coming from the sensor
int sensorValue2 = 0;  // variable to store the value coming from the sensor
int sensorValue3 = 0;  // variable to store the value coming from the sensor

void setup()
{
  SIM900.begin(19200);
  SIM900power(); 
  delay(20000);  // give time to log on to network.
}

void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
  digitalWrite(9, HIGH);
  delay(1000);
  digitalWrite(9, LOW);
  delay(5000);
}

void loop()
{
  sensorValue0 = analogRead(sensorPin0);
  sensorValue1 = analogRead(sensorPin1);
  sensorValue2 = analogRead(sensorPin2);
  sensorValue3 = analogRead(sensorPin3); 
 
  {
  if(sensorValue0 > 800)

SIM900.print("AT+CMGF=1\r");                                                        // AT command to send SMS message
  delay(100);
  SIM900.println("AT + CMGS = "+34617516793"");                                    // recipient's mobile number, in international format
  delay(100);
  SIM900.println("AGRITRONIC LA SOLANA.");        // message to send
  SIM900.println("ANALOG 0 = ");        // message to send 
  SIM900.println(sensorValue0); 
  SIM900.println("ANALOG 1 = ");        // message to send
  SIM900.println(sensorValue1); 
  SIM900.println("ANALOG 2 = ");        // message to send
  SIM900.println(sensorValue2); 
  SIM900.println("ANALOG 3 = ");        // message to send
  SIM900.println(sensorValue3);

delay(100);
  SIM900.println((char)26);                      // End AT command with a ^Z, ASCII code 26
  delay(100);
  SIM900.println();
  delay(5000);                                    // give module time to send SMS
  SIM900power();                                  // turn off module
 
  do {} while (1);

}

}

Mira qué bonito queda tu código metiéndolo entre etiquetas code. Además aparece un botoncito arriba para seleccionar (y poder copiar) todo que es comodísimo. Por favor; siempre que pongáis código utilizad las etiquetas code. Es muy sencillo y no duele :grin:

Ahora la respuesta:

¿No debería ir el if ANTES de la apertura de llaves?

Uf ¿Ese código te compila? :blush:

lo mismo que dijo Noter

 if(sensorValue0 > 800) {
    ///   lo que sigue.......

} // cierro llaves