Go Down

Topic: HF RFID WITH GPRS MODULE AT COMMANDS USING ARDUINO (Read 277 times) previous topic - next topic

khushboo_1

Feb 17, 2017, 11:57 am Last Edit: Feb 22, 2017, 01:37 pm by khushboo_1
HI
I'm working on gprs module with hf rfid using arduino uno.i m getting trouble in gprs AT command,where i have established my tcp connection using arduino code,but i got error in at+cipsend

my arduino code are here

plz help anyone..plz
thanks in advance

#include <SoftwareSerial.h>
#include <String.h>
#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9
 
SoftwareSerial mySerial(7, 8 );
MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance.
String result;
 
void setup()
{
  mySerial.begin(9600);               // the GPRS baud rate   
  Serial.begin(9600);    // the GPRS baud rate
  SPI.begin();      // Init SPI bus
  mfrc522.PCD_Init(); // Init MFRC522 card
//  Serial.println("Approximate your card to the reader...");
//  Serial.println();
//
//  Serial.println(F("Ready!"));
//  Serial.println(F("======================================================"));
//  Serial.println(F("Scan for Card and print UID:"));
  delay(500);
}
 
void loop()
{
  if (mySerial.available())
    Serial.write(mySerial.read());

     // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent()) {
    return;
  }

  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) {
    return;
  }
 
  // Show some details of the PICC (that is: the tag/card)
  Serial.print(F("Tagid:"));
  dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
  Serial.println(); 
}

// Helper routine to dump a byte array as hex values to Serial
void dump_byte_array(byte *buffer, byte bufferSize) {

  for (byte i = 0; i < bufferSize; i++) {
    result += String(buffer, HEX);
    Serial.print(String(buffer < 0x10 ? " 0" : " "));
    Serial.print(String(buffer, HEX));
  }
  Send2xampp();
  Serial.println();
  mfrc522.PICC_HaltA(); // Stop reading
}
 
///send2xampp()///
///this function is to send the sensor data to the pachube, you can see the new value in the pachube after execute this function///
void Send2xampp()
{
  String data;
 
  mySerial.println("AT+CGATT=1");   //Attach or Detach from GPRS Service (Result  1 = Attach , 2 = Detached )
  delay(300);
  ShowSerialData();
 
  mySerial.println("AT+CIPSHUT");  //Close TCP Connection
  delay(300);
  ShowSerialData();

  mySerial.println("AT+CIPSPRT=0");
  delay(3000);
  ShowSerialData();

  mySerial.println("AT+CIPSTART=\"TCP\",\"49.207.183.202\",\"4000\"");//start up the connection

  delay(2000);
  ShowSerialData();


  mySerial.println("\n");//here is the feed you apply from pachube
  delay(500);
  ShowSerialData();
 
 
 
 
 
  mySerial.println("AT+CIPSEND");//begin send data to remote server
  delay(4500);
  ShowSerialData();

  mySerial.print("tag_id= " + String(result) +"\"");   //DATA feed name
  delay(10);
  ShowSerialData();
 
  mySerial.print("POST  /rfid1/rest/insertrfiddata");//here is the feed you apply from pachube
  delay(500);
  ShowSerialData();

  mySerial.println("\n");//here is the feed you apply from pachube
  delay(500);
  ShowSerialData();
 
  mySerial.print(" HTTP/1.1\r\n");
  delay(500);
  ShowSerialData();

   mySerial.println("Content-Type: application/json");
  delay(100);
  ShowSerialData();
 
  mySerial.print("Host: 49.207.183.202\r\n");
  delay(500);
  ShowSerialData();
 

  //mySerial.print("Connection: keep-alive");  //working
  mySerial.print("Connection: close");         //working as well
  mySerial.print("\r\n");
  mySerial.print("\r\n");
  //mySerial.println();
  delay(500);
  ShowSerialData();


//  mySerial.println((char)26);//sending
  delay(500);//waitting for reply, important! the time is base on the condition of internet
  mySerial.println();
  ShowSerialData();

  mySerial.println("AT+CIPCLOSE");//close the connection
  delay(100);
  ShowSerialData();
 
  mySerial.println("AT+CIPSHUT=0");
  delay(100);
  ShowSerialData();
}
 
void ShowSerialData()
{
  while(mySerial.available()!=0)
    Serial.write(mySerial.read());
}

khushboo_1

#1
Feb 22, 2017, 12:37 pm Last Edit: Feb 22, 2017, 01:40 pm by khushboo_1
Hi,
   I was trying the new GPRS module(sim900a) and its works but i having an error when i want to post it in xampp server.


Thanks in advance...plz help anyone...i am trying these so many days...but i got...



My arduino is here.

#include <SoftwareSerial.h>
#include <String.h>
#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9

SoftwareSerial mySerial(7, 8);               //your pins to serial communication
MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance.
String result;
int valor;

//String token = "96307f50";      //your token to post a value
//String result = "96307f50";      //ID of your variable

void setup()
{
  mySerial.begin(9600);                                                            //the GPRS baud rate
  Serial.begin(9600);
  SPI.begin();      // Init SPI bus
  mfrc522.PCD_Init(); // Init MFRC522 card
  delay(500);//the serial communication baud rate
  Serial.println("Starting");
  delay(2000);
}

void loop()
{
  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent()) {
    return;
  }

  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) {
    return;
  }
 
  // Show some details of the PICC (that is: the tag/card)
  Serial.print(F("tag_id:"));
  dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
  Serial.println(); 
}

// Helper routine to dump a byte array as hex values to Serial
void dump_byte_array(byte *buffer, byte bufferSize) {

  for (byte i = 0; i < bufferSize; i++) {
    result += String(buffer, HEX);
    Serial.print(String(buffer < 0x10 ? " 0" : " "));
    Serial.print(String(buffer, HEX));
  }
  Serial.println();
  mfrc522.PICC_HaltA(); // Stop reading
                                                 
  Serial.println("Sending to xampp Value="+ result);
  save_value(String(result));                                                      //call the save_value function
 
  if (mySerial.available())
    Serial.write(mySerial.read());
}
//this function is to send the sensor data to Ubidots, you can see the new value in Ubidots after running this function

void save_value(String result)
{
  int num;
  String le;
  String data;
  data="tag_id = "+ result;
//  data="{\"tag_id\":"+ result + "}";
  num=data.length();
  le=String(num);

    mySerial.println("AT+CGATT?");                                                   //this is better made repeatedly because it is unstable
    delay(2000);
    ShowSerialData();
//  mySerial.println("AT+CSTT=\"www\",\"\",\"\"");                                    //start task and set the APN
//  delay(1000);
//  ShowSerialData();
//  mySerial.println("AT+CIICR");                                                      //bring up wireless connection
//  delay(3000);
//  ShowSerialData();
//  mySerial.println("AT+CIFSR");                                                      //get local IP adress
//  delay(2000);
//  ShowSerialData();
  mySerial.println("AT+CIPSPRT=0");
  delay(3000);
  ShowSerialData();
  mySerial.println("AT+CIPSTART=\"tcp\",\"49.207.183.202\",\"4000\"");             //start up connection
  delay(3000);
  ShowSerialData();
  mySerial.println("AT+CIPSEND");                                                    //begin sendiing data to the remote server
  delay(5000);
  ShowSerialData();
  mySerial.print("POST /gprs_rfid/rest/insertrfiddata HTTP/1.1\n");
  delay(100);
  ShowSerialData();
  mySerial.println("tag_id = " + String(result));
  delay(100);
  ShowSerialData();
  mySerial.println("Content-Type: application/json");
  delay(100);
  ShowSerialData();
  mySerial.println("Content-Length: "+le);
  delay(100);
  ShowSerialData();
  mySerial.print("X-Auth-tag_id: ");
  delay(100);
  ShowSerialData();
  mySerial.println(result);
  delay(100);
  ShowSerialData();
  mySerial.println("Host: 49.207.183.202");
  delay(100);
  ShowSerialData();
  mySerial.println();
  delay(100);
  ShowSerialData();
  mySerial.println(data);
  delay(100);
  ShowSerialData();
  mySerial.println();
  delay(100);
  ShowSerialData();
  mySerial.println((char)26);
  delay(7000);
  mySerial.println();
  ShowSerialData();
  mySerial.println("AT+CIPCLOSE");                                                //close communication
  delay(1000);
  ShowSerialData();
}

void ShowSerialData()
{
  while(mySerial.available()!=0)
  Serial.write(mySerial.read());
}

AWOL

Quote
but i having an error
Didn't you think we'd like to know what the error is?

Please remember to use code tags when posting code.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

khushboo_1

  :smiley-sad:
Sorry sir/madam,i apologize...
Code: [Select]
Starting
tag_id:362a8050
Sending to xampp value=362a8050
AT+CGATT?

+CGATT: 1

OK
AT+CIPSPRT=0

OK
AT+CIPSTART="tcp","49.207.183.202","4000"

ERROR
AT+CIPSEND

ERROR
POST /gprs_rfid/rest/insertrfiddata HTTP/1.1
tag_id = 362a8050
Content-Type: application/json
Content-Length: 17
X-Auth-tag_id: 362a8050
Host: 49.207.183.202

tag_id = 362a8050



ERROR

AT+CIPCLOSE

ERROR

khushboo_1

 :smiley-sad:
Sorry sir/madam,i apologize...
Code: [Select]

Starting
tag_id:362a8050
Sending to xampp value=362a8050
AT+CGATT?

+CGATT: 1

OK
AT+CIPSPRT=0

OK
AT+CIPSTART="tcp","49.207.183.202","4000"

ERROR
AT+CIPSEND

ERROR
POST /gprs_rfid/rest/insertrfiddata HTTP/1.1
tag_id = 362a8050
Content-Type: application/json
Content-Length: 17
X-Auth-tag_id: 362a8050
Host: 49.207.183.202

tag_id = 362a8050



ERROR

AT+CIPCLOSE

ERROR

khushboo_1

plz plz plz reply...i need your help...plz do the needful

Go Up