How to: get ID-20LA RFID and SIM900 to communicate with UNO (software serials)
hello forum
i working on project have send out sms when specific rfid tag scanned. have id-20la , sim900 shield hooked arduino uno, , both of them working fine on own. both rfid reader , gsm shield communicates uno via software-serial library.
this shield
http://imall.iteadstudio.com/im120417009.html
this current sketch. should have functioned way. "when 2 known tags gets scanned, send sms" - can't scan rfid's @ all, , no sms gets send.
i've read arduino can't handle 2 software serials running @ once, , therefore have use function ".listen" before communicating either rfid or sim900. @ bottom of void setup end "myserial.listen();" able scan tags. when known tag scanned, send sms, part of sketch:
i trying use "gsm.listen();" before sending message. problem theres no ".listen" function build sim900 library , therefore can't use it. if delete line "gsm.listen();" don't receive sms.
does know how can change serial rfid sim900 can send sms?
thank much
best regards
johannes
i working on project have send out sms when specific rfid tag scanned. have id-20la , sim900 shield hooked arduino uno, , both of them working fine on own. both rfid reader , gsm shield communicates uno via software-serial library.
this shield
http://imall.iteadstudio.com/im120417009.html
this current sketch. should have functioned way. "when 2 known tags gets scanned, send sms" - can't scan rfid's @ all, , no sms gets send.
code: [select]
#include <softwareserial.h>
#include "sim900.h"
#include "sms.h"
smsgsm sms;
softwareserial myserial(4,a2); // rx, tx
int rfidresetpin = 5;
//tags tilføjes her, de kan findes seriel monitor, når et tag scannes.
char tag1[13] = "01002dc7d03b";
char tag2[13] = "01002dc6678d";
void setup(){
myserial.begin(9600);
serial.begin(9600);
gsm.begin(2400);
pinmode(rfidresetpin, output);
digitalwrite(rfidresetpin, high);
myserial.listen();
}
void loop(){
char tagstring[13];
int index = 0;
boolean reading = false;
while(myserial.available()){
int readbyte = myserial.read(); //read next available byte
if(readbyte == 2) reading = true; //begining of tag
if(readbyte == 3) reading = false; //end of tag
if(reading && readbyte != 2 && readbyte != 10 && readbyte != 13){
//store tag
tagstring[index] = readbyte;
index ++;
}
}
checktag(tagstring); //check if match
cleartag(tagstring); //clear char of value
resetreader(); //eset rfid reader
}
void checktag(char tag[]){
///////////////////////////////////
//check read tag against known tags
///////////////////////////////////
if(strlen(tag) == 0) return; //empty, no need contunue
if(comparetag(tag, tag1)){ // if matched tag1, this
sms.sendsms("12345678", "tag1"); //12345678 = phonenumber
}
else if(comparetag(tag, tag2)){ //if matched tag2, this
sms.sendsms("12345678", "tag2");
}
else{
serial.println(tag); //læs ukendte tags, og print serielt.
}
}
void resetreader(){
//reset læseren
digitalwrite(rfidresetpin, low);
digitalwrite(rfidresetpin, high);
delay(150);
}
void cleartag(char one[]){
//clear char array filling null - ascii 0
//will think same tag has been read otherwise
for(int = 0; < strlen(one); i++){
one[i] = 0;
}
}
boolean comparetag(char one[], char two[]){
//compare 2 value see if same,
if(strlen(one) == 0) return false; //empty
for(int = 0; < 12; i++){
if(one[i] != two[i]) return false;
}
return true; //no mismatches
}
i've read arduino can't handle 2 software serials running @ once, , therefore have use function ".listen" before communicating either rfid or sim900. @ bottom of void setup end "myserial.listen();" able scan tags. when known tag scanned, send sms, part of sketch:
code: [select]
if(comparetag(tag, tag1)){ // if matched tag1, this
gsm.listen();
sms.sendsms("12345678", "tag1"); //12345678 = phonenumber
i trying use "gsm.listen();" before sending message. problem theres no ".listen" function build sim900 library , therefore can't use it. if delete line "gsm.listen();" don't receive sms.
does know how can change serial rfid sim900 can send sms?
thank much
best regards
johannes
links shield details welcome. have better idea of may configurable , isn't.
Arduino Forum > Using Arduino > Programming Questions > How to: get ID-20LA RFID and SIM900 to communicate with UNO (software serials)
arduino
Comments
Post a Comment