Respuesta a: RFID – RDM 3600 ¿Como Almacenar la Lectura?
Inicio › Foros › Arduino (Nano, Mega, Uno, Mini) › RFID – RDM 3600 ¿Como Almacenar la Lectura? › Respuesta a: RFID – RDM 3600 ¿Como Almacenar la Lectura?
¡Gracias por su respuesta!.. mencione el transceptor de 433Mhz porque en una parte mencionaba que este hacía multiples lecturas y en una linea comentada decía que utilizaban esa linea para detener las «multiples lecturas» y pues lo relacioné con el RFID debido a que tambien tenía ese problema de las «multiples lecturas» al pasar la tarjeta por el lector. pero EN FIN…
ya logre avanzar en mi proyecto, pero requiero de mas ayuda PORFAVOR!.. si no es mucha la molestia, logré conseguir que la variable que almacena la lectura del RFID capturara 1 sola lectura, tambien logre que esa lectura se enviara a una base de datos y se almacenara, tambien logré que el arduino comprobara al pasar nuevamente la tarjeta PREVIAMENTE registrada en la base de datos, esta se validara y posteriormente accionara un led, estoy realizando un pequeño sistema con PHP y quiero lograr algo parecido a esto:
https://www.youtube.com/watch?v=h-xyvUcHZPs
ya tengo la pagina PHP del login, y eh realizado un pequeño formulario en donde quisiera que al pasar la tarjeta por el lector, el arduino me desplegara la variable de la tarjeta en el «FORM» o el campo de texto en donde colocaré dicha lectura.
le anexo el codigo que estoy utilizando en el arduino:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
#include <SPI.h> #include <Ethernet.h> #include <SoftwareSerial.h> byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; IPAddress server(192, 168, 0, 3); EthernetClient client; SoftwareSerial RFID(2, 3); // RX and TX int flag=0,RX_Flag=0;//serial port sign char Code[14]; long Num=0;//decode data long tag; String location = "http://192.168.0.3/test/data.php HTTP/1.0"; // este string es donde el PHP le envía datos al arduino para validar los RFID registrados en la DB. char inString[32]; // string for incoming serial data int stringPos = 0; // string index counter boolean startRead = false; // is reading? String dato; int abierto = 7; int on = 0; int envio = 0; String data; void Read_ID(void) { int i=0; char temp; for(i=0;(RFID.available()>0);i++)// //while(Serial.available()>0) { temp=RFID.read(); //Serial.print(temp); delay(2); //Serial.println(i); if(temp==0X02) //recieve the ssrt bit { flag=1;i=0;RX_Flag=0;// } if(flag==1)//detect the start bit and recieve data { if(temp==0X03)//detect the end code, { flag=0; //zero clearing if(i==13) RX_Flag=1;// else RX_Flag=0; break; } Code[i]=temp; } } flag=0;// } void Envio_DATO(void) // <------ este envía el TAG RFID al PHP para que este lo inserte en la base de datos { Serial.println("Connecting..."); //Serial.println(tag); if (client.connect(server, 80)>0) { // Conexion con el servidor client.print("GET /test/prueba.php?valor=");; // Enviamos los datos por GET client.print(tag); tag=0; client.println(" HTTP/1.0"); client.println("User-Agent: Arduino 1.0"); client.println(); Serial.println("Conectado"); digitalWrite(abierto,HIGH); delay(500); digitalWrite(abierto,LOW); } else { Serial.println("Fallo en la conexion"); } if (!client.connected()) { Serial.println("Disconnected!"); } client.stop(); client.flush(); } String connectAndRead(){ //connect to the server Serial.println("connecting..."); //port 80 is typical of a www page if (client.connect(server, 80)) { Serial.println("connected"); client.print("GET "); client.println(location); client.println(); //Connected - Read the page return readPage(); //go and read the output }else{ return "connection failed"; } } String readPage(){ //read the page, and capture & return everything between '<' and '>' stringPos = 0; memset( &inString, 0, 32 ); //clear inString memory while(true){ if (client.available()) { char c = client.read(); if (c == '<' ) { //'<' is our begining character startRead = true; //Ready to start reading the part }else if(startRead){ if(c != '>'){ //'>' is our ending character inString[stringPos] = c; stringPos ++; }else{ //got what we need here! We can disconnect now startRead = false; client.stop(); client.flush(); Serial.println("disconnecting."); return inString; } } } } } void setup() { pinMode(abierto, OUTPUT); // start the serial library: Serial.begin(9600); RFID.begin(9600); // start the Ethernet connection: if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // no point in carrying on, so do nothing forevermore: for(;;) ; } // give the Ethernet shield a second to initialize: delay(1000); Serial.println("connecting..."); // if you get a connection, report back via serial: } void loop() { if(tag > 0){ envio++; // le puse esto para que la segunda lectura que hace el lector porque aun que ya no hace multiples lecturas este hace 2... Serial.println(envio); if(envio == 2){ // aquí envío la segunda lectura, para no enviar las 2 Envio_DATO(); envio = 0; } // y todo lo que está comentado aca abajo es donde al pasar la tarjeta lo valida con la DB // dato = tag; // Serial.print(dato); // String pageValue = connectAndRead(); //connect to the server and read the output // int pos=pageValue.indexOf(dato); // // if (pos>=0) { // on++; // Serial.println(on); // tag = 0; // } // if(on == 2){ // // digitalWrite(abierto,HIGH); // delay(1000); // digitalWrite(abierto,LOW); // Serial.print(" ACEPTADA En La Posicion : "); // Serial.print(pos); // Serial.print(" "); // on = 0; // } //Serial.println(pageValue); //print out the findings. } int i; long temp=0,time=0; RX_Flag=0; while(1) { Read_ID(); if(RX_Flag==1) { for(i=5;i<11;i++)// { Num<<=4; if(Code[i]>64) Num+=((Code[i])-55); else Num+=((Code[i])-48); //Serial.println(Num); } //Serial.println(Num); tag = Num; while(RFID.read()>0);// RX_Flag=0;// Num=0;// } break; } } |
————- aca abajo anexo el codigo PHP que me envía los datos a la DB————–
1 2 3 4 5 6 7 8 9 10 11 12 |
<?php $conexion = mysql_connect("localhost", "root", ""); mysql_select_db("test",$conexion); mysql_query("INSERT INTO <code>probando</code>(<code>nombre</code>) VALUES ('" . $_GET['valor'] . "')", $conexion); $dato = $_GET['valor']; // aquí pretendía imprimir el valor pero pues no pasa nada.... echo $dato; ?> |
MI DUDA PRINCIPAL: ¿como pasar en tiempo real la lectura del RFID a un campo de texto en un FORM en PHP?
le agradezco mucho por tomarse el tiempo de leer esto tan largo… MUCHAS GRACIAS…