SIM900 programming problems, help needed
i working on controlling arduino sim900, have problems giving commands true sms, send sms true sim900 works.
can 1 me?
i want controll led sms command, led connected pin 10.
void receivetextmessage1()
{
// code here led on
}
void receivetextmessage2()
{
// code here led off
}
can 1 me?
i want controll led sms command, led connected pin 10.
void receivetextmessage1()
{
// code here led on
}
void receivetextmessage2()
{
// code here led off
}
code: [select]
// http://wiki.epalsite.com/index.php?title=sim900_quad-band_gprs_shield_with_micro_sd_card_slot#purchasing_this_module
#include <softwareserial.h>
softwareserial sim900serial(2, 3);
int data = 0;
const int buttona = 22;
const int buttonb = 23;
const int sim = 40; // on current sim900 card pwm pin 7 controll pwrkey sim900 chip
const int buttonc = 42; // manual set sim900 on/off button
const int led = 10; // led output, controlled sms
boolean lastbuttona = low;
boolean lastbuttonb = low;
boolean lastbuttonc = low;
boolean currentbuttona = low;
boolean currentbuttonb = low;
boolean currentbuttonc = low;
void setup() {
{
pinmode (buttona, input);
pinmode (buttonb, input);
pinmode (buttonc, input);
pinmode (led, output);
pinmode (sim, output);
}
// starting sim900
delay(2000); // delay give sim900 time power up
digitalwrite(sim, high);
delay(3000);
digitalwrite(sim, low);
delay(8000);
// sim900 setup
sim900serial.begin(115200); // gprs baud rate
delay(500);
sim900serial.println("at+ipr=19200");
delay(500);
sim900serial.begin(19200); // gprs baud rate
delay(1000);
sim900serial.println("at+cmgd=1,4"); // delete sms
serial.begin(115200); // hardware serial rate
serial.println("please type '1 true 3' send sms");
}
// button a
boolean debounce(boolean last)
{
boolean currenta = digitalread(buttona);
if (last != currenta)
{
delay(5);
currenta = digitalread(buttona);
}
return currenta;
}
// button b
boolean debounceb(boolean lastb)
{
boolean currentb = digitalread(buttonb);
if (lastb != currentb)
{
delay(5);
currentb = digitalread(buttonb);
}
return currentb;
}
// button c - on/off
boolean debouncec(boolean lastc)
{
boolean currentc = digitalread(buttonc);
if (lastc != currentc)
{
delay(5);
currentc = digitalread(buttonc);
}
return currentc;
}
void loop()
{
data=serial.read();
// sms code nr 1
if (data==0x31)
{
sendtextmessage1();
}
currentbuttona = debounce(lastbuttona);
if (lastbuttona == low && currentbuttona == high)
{
sendtextmessage1();
}
lastbuttona = currentbuttona;
// sms code nr 2
if (data==0x32)
{
sendtextmessage2();
}
currentbuttonb = debounceb(lastbuttonb);
if (lastbuttonb == low && currentbuttonb == high)
{
sendtextmessage2();
}
lastbuttonb = currentbuttonb;
// sms code nr 3
if (data==0x33)
{
sendtextmessage3();
}
// sim on/off button
currentbuttonc = debouncec(lastbuttonc);
if (lastbuttonc == low && currentbuttonc == high)
{
digitalwrite (sim, high);
delay(3000);
digitalwrite (sim, low);
}
lastbuttonc = currentbuttonc;
if (sim900serial.available())
serial.write(sim900serial.read());
}
void sendtextmessage1()
{
sim900serial.print("at+cmgf=1\r"); //sending sms in text mode
delay(100);
sim900serial.println("at + cmgs = \"********\"");//the target phone number
delay(100);
sim900serial.println("hallo,1");//the content of message
delay(100);
sim900serial.println((char)26);//the ascii code of ctrl+z 26
delay(100);
sim900serial.println();
}
void sendtextmessage2()
{
int sensor1 = analogread(a0);
float power = sensor1 * (5 / 1023.0) * 2;
sim900serial.print("at+cmgf=1\r"); //sending sms in text mode
delay(100);
sim900serial.println("at + cmgs = \"********\"");//the target phone number
delay(100);
sim900serial.print("this automated message. ");
sim900serial.println("battery voltage low. ");
sim900serial.print("battery voltage: ");
sim900serial.print(power, 2);
sim900serial.println(" vdc");
delay(100);
sim900serial.println((char)26);//the ascii code of ctrl+z 26
delay(100);
sim900serial.println();
}
void sendtextmessage3()
{
sim900serial.print("at+cmgf=1\r"); //sending sms in text mode
delay(100);
sim900serial.println("at + cmgs = \"********\"");//the target phone number
delay(100);
sim900serial.println("hallo,3");//the content of message
delay(100);
sim900serial.println((char)26);//the ascii code of ctrl+z 26
delay(100);
sim900serial.println();
}
void receivetextmessage1()
{
// code here
}
void receivetextmessage2()
{
// code here
}
i got sim900 , arduino mega 2560.
i want sim900 read sms , depending on sms send sms in return.
like: sim900 receives "hello", sim900 sends "hello too" in return.
and when sim900 reveives ledon turns on led on pin 10.
and when sim900 reveives ledoff turns off led on pin 10.
the sim900 connected serial 1 , baud 19200.
can 1 me?
i want sim900 read sms , depending on sms send sms in return.
like: sim900 receives "hello", sim900 sends "hello too" in return.
and when sim900 reveives ledon turns on led on pin 10.
and when sim900 reveives ledoff turns off led on pin 10.
the sim900 connected serial 1 , baud 19200.
can 1 me?
Arduino Forum > Using Arduino > Programming Questions > SIM900 programming problems, help needed
arduino
Comments
Post a Comment