Go Down

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

khushboo_1

Feb 17, 2017, 11:57 am Last Edit: Feb 17, 2017, 01:07 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());
}

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy