RFID RC522 seems to not send GET data to a xampp web server via W5100 Ethernet


my problem uid not sent web server on pc serially printed , client certified connected. [outputs "connected" , ip printed] not reflect on db. i'm using xampp, firewall off, ip both correct. port 80 , manual encoding of argument working, localhost/add_data_php?rfid=12345678 [12345678 reflect on db] :) maybe because needs delay? or on or off of ss pins of each? appreciated. :))

the "counter" , "first" variables used condition whenever card gets detected, that's way data sent server. seems work fine serially, gets pass through code whenever card gets detected. not reflect on db. manage save in db "dummy" number , and in 1 execution only, setup , not on loop. please hellppp thanks. :)


code: [select]

#include <spi.h>
#include <mfrc522.h>
#include <ethernet.h>

#define ss_pin 9
#define rst_pin 8
mfrc522 mfrc522(ss_pin, rst_pin);        // create mfrc522 instance.

byte mac[] = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed };

ipaddress server(192,168,0,104);  // numeric ip server (no dns) (reduce sketch size)
ipaddress ip(192,168,0,103);      //numeric ip of ethernet shield (static)

ethernetclient client; //initialize ethernet client library(port 80 http default):

int first=0;
int counter=0;
string uid;


void setup() {
        serial.begin(9600);        // initialize serial communications pc
       
        // disable sd spi
        pinmode(4, output);
        digitalwrite(4, high);
       
        // disable w5100 spi
        pinmode(10, output);
        digitalwrite(10, high);
       
        spi.begin();                // init spi bus
        mfrc522.pcd_init();        // init mfrc522 card
        //serial.println("scan mifare classic picc demonstrate value blocks.");
       
        ethernet.begin(mac, ip); //we used static address start ethernet
   
        // print local ip address:
        serial.print("my ip address: ");
        (byte thisbyte = 0; thisbyte < 4; thisbyte++) {
        // print value of each byte of ip address:
        serial.print(ethernet.localip()[thisbyte], dec);
        serial.print(".");
        }
        // give ethernet shield second initialize:
        delay(1000);
        serial.println("connecting...");
}

void loop() {
 
          // prepare key - keys set ffffffffffffh @ chip delivery factory.
        mfrc522::mifare_key key;
        (byte = 0; < 6; i++) {
                key.keybyte[i] = 0xff;
        }
        // new cards
        if ( ! mfrc522.picc_isnewcardpresent()) {
                return;
        }

        // select 1 of cards
        if ( ! mfrc522.picc_readcardserial()) {
                return;
        }
        // card selected. uid , sak in mfrc522.uid.
       
        // dump uid
        //serial.print("card uid:");
       
             
               
    int val1=(mfrc522.uid.uidbyte[0]);
    int val2=(mfrc522.uid.uidbyte[1]);
    int val3=(mfrc522.uid.uidbyte[2]);
    int val4=(mfrc522.uid.uidbyte[3]);
   
    string vala=string(val1);
    string valb=string(val2);
    string valc=string(val3);
    string vald=string(val4);
    uid=vala+valb+valc+vald;
    serial.print(uid);
    serial.println();
    counter=counter+1;   
   serial.print(counter);
           
         
     
         
        //}
        serial.println();

   
        // halt picc
        mfrc522.picc_halta();

        // stop encryption on pcd
        mfrc522.pcd_stopcrypto1();
       
       
       
       
                       
    if (counter>first)
    {//delay ifs
    // enable w5100 spi
   
       
    if (client.connect(server, 80)) { //start of if
    serial.println("connected");
    // make http request:
    client.print("get /add_data.php?rfid="); //dont make these println
    client.print(uid);   //dont make these println
    client.println(" http/1.1");
    client.print("host: ");
    client.println(server);
    client.println("connection: close");
    client.println();
    serial.print("sent");
    serial.println();
    first++;
    serial.print(first);
    serial.println();
    client.stop();
   
  } //end of if
 
       
    }//delay ifs   

}

code: [select]
   client.print("host: ");
    client.println(server);

unless pc serving multiple domains, highly unlikely, part not needed.

what log files on server say?

why not reading server response? not reading reply leave socket open. 4 times , toast.


Arduino Forum > Using Arduino > Programming Questions > RFID RC522 seems to not send GET data to a xampp web server via W5100 Ethernet


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code