Go Down

Topic: Connect arduino with sim900a send sms from smartphone (Read 210 times) previous topic - next topic

yoshiolin

any people help me ?

#include <SoftwareSerial.h>
#include <Arduino.h>
#include <String.h>

SoftwareSerial mySerial(2, 3);
char pesan1 []= "+6285756071366";

void setup() {
 
   Serial.begin(9600);
   while (!Serial){
   
   }
   Serial.println("I'M ARDUINO");
   mySerial.begin(9600);
}

void loop() {
    bacasms:

      if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
      if (Serial.available()) {
    mySerial.write(Serial.read());
  }
   Serial.println("Baca SMS");
  delay(1000);
 
  if(strstr(pesan1,"+6285756071366")==0) goto bacasms;
  //Serial.println("Nomor Ada");
   else Serial.println("Periksa Pesan");

  if(strstr(pesan1,"GetMeter1")==0) goto bacasms;
  else Serial.println("Baca ADC");
  while(1);
 
}




I've tried but at the moment sms sent to existing number on arduino there but using foreign language and not in line with what i mean ..

Please help me

PaulS

Code: [Select]
  if(strstr(pesan1,"+6285756071366")==0) goto bacasms;
WTF? You most certainly do NOT need a damned goto statement.

Code: [Select]
  while(1);
More stupidity.

What IS the problem? You posted some code that does something, but failed to tell us what it does. You expect the code to do something, but failed to tell us what you expect? How can we tell you where your expectations are wrong, without any data?
The art of getting good answers lies in asking good questions.

yoshiolin


Sorry paulS

It's a program to read sms from smartphone to arduino via sim900a and i want when there sms in with the number made in the program according then the next step read the contents of sms, if appropriate next step read the sensor that is ADC ...

So paulS ..
Can you help me, paulS?

PaulS

Quote
Can you help me, paulS?
No. I still don't know what the program actually does, or how that differs from what you want.

You REALLY need to restructure the code to deal with valid requests, and ignore invalid requests, instead of stuffing your head in the sand if an invalid request is made.
The art of getting good answers lies in asking good questions.

logans


yoshiolin


PaulS

Code: [Select]
char pesan1 []= "+6285756071366";

 if(strstr(pesan1,"+6285756071366")==0) goto bacasms;

  if(strstr(pesan1,"GetMeter1")==0) goto bacasms;

There are three places in the code where the contents of pesan1 matter. strstr() finds the first instance of string 2 in string 1, and returns a pointer to string 2 in string 1. The first call to strstr() will return a pointer, because "+6285756071366" is contained in "+6285756071366".

Since the pointer is not a NULL pointer, it is not equal to 0, so the goto doesn't happen.

Now, why you think that pesan1 should now contain "GetMeter1", when you have not assigned any new data to pesan1 is a complete mystery that you have made NO attempt to clear up.

Right now, ALL that your code does is read the data coming from the Serial port and send it to the modem, and read the data coming from the modem and send it to the serial port.

You have to do a LOT more than that if you expect to deal with the incoming data.
The art of getting good answers lies in asking good questions.

Go Up