Laravel 我的rfid设备如何在我的电子停车项目中读取和切断同一设备的平衡?
我的设备是rfid卡Mifare类型、NodeMCU ESP8266 v3和rfid RC522模块。我的基于网络的RFID项目有问题。我将Laravel7用于web和MySQL 所以我和拉威尔有一个电子停车项目。rfid阅读器工作正常,数据显示如下图所示 所以我有一列,名字是balance。所以当我把车停在停车场,当我扫描我的rfid卡时,余额会被扣除。可以在同一个rfid设备上实现吗?它就像我的rfid设备有2种模式,读取模式和剪切平衡模式。这是我的带有arduino IDE的rfid脚本 无效设置() void循环()Laravel 我的rfid设备如何在我的电子停车项目中读取和切断同一设备的平衡?,laravel,esp8266,rfid,Laravel,Esp8266,Rfid,我的设备是rfid卡Mifare类型、NodeMCU ESP8266 v3和rfid RC522模块。我的基于网络的RFID项目有问题。我将Laravel7用于web和MySQL 所以我和拉威尔有一个电子停车项目。rfid阅读器工作正常,数据显示如下图所示 所以我有一列,名字是balance。所以当我把车停在停车场,当我扫描我的rfid卡时,余额会被扣除。可以在同一个rfid设备上实现吗?它就像我的rfid设备有2种模式,读取模式和剪切平衡模式。这是我的带有arduino IDE的rfid脚本
void循环(){
//将主代码放在这里,以便重复运行
readsuccess=getid();
if(readsuccess){
数字写入(板上发光二极管,低电平);
无线客户端;
HTTPClient http;//声明类HTTPClient的对象
字符串UIDresultSend,postData;
UIDresultSend=StrUID;
//发布数据
postData=“UIDresult=”+UIDresultSend;
http.begin(客户端,“http://192.168.1.8/rfid-nodemcu/getUID.php“”;//指定请求目标
http.addHeader(“内容类型”、“应用程序/x-www-form-urlencoded”);//指定内容类型头
int httpCode=http.POST(postData);//发送请求
字符串负载=http.getString();//获取响应负载
Serial.println(UIDresultSend);
Serial.println(httpCode);//打印HTTP返回代码
Serial.println(负载);//打印请求响应负载
http.end();//关闭连接
延迟(500);
数字写入(板上LED,高电平);
}
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
//----------------------------------------从卡或钥匙链读取和获取UID的步骤---------------------------------------------------------------------------------//
int getid(){
如果(!mfrc522.PICC_IsNewCardPresent()){
返回0;
}
如果(!mfrc522.PICC_ReadCardSerial()){
返回0;
}
Serial.print(“扫描卡的UID为:”);
对于(int i=0;i<4;i++){
readcard[i]=mfrc522.uid.uidByte[i];//将标记的uid存储在readcard中
数组到字符串(读卡,4,str);
StrUID=str;
}
mfrc522.PICC_HaltA();
返回1;
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
//----------------------------------------将数组UID读入字符串的结果更改为字符串的过程------------------------------------------------------------------------------//
无效数组\u到\u字符串(字节数组[],无符号整数len,字符缓冲区[]){
for(无符号整数i=0;i>4)&0x0F;
字节nib2=(数组[i]>>0)&0x0F;
缓冲区[i*2+0]=nib1<0xA?'0'+nib1:'A'+nib1-0xA;
缓冲区[i*2+1]=nib2<0xA?'0'+nib2:'A'+nib2-0xA;
}
缓冲区[len*2]='\0';
}
所以请有人能帮我吗?多谢各位
void setup() {
Serial.begin(115200); //--> Initialize serial communications with the PC
SPI.begin(); //--> Init SPI bus
mfrc522.PCD_Init(); //--> Init MFRC522 card
delay(500);
WiFi.begin(ssid, password); //--> Connect to your WiFi router
Serial.println("");
pinMode(ON_Board_LED, OUTPUT);
digitalWrite(ON_Board_LED, HIGH); //--> Turn off Led On Board
//----------------------------------------Wait for connection
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
//----------------------------------------Make the On Board Flashing LED on the process of connecting to the wifi router.
digitalWrite(ON_Board_LED, LOW);
delay(250);
digitalWrite(ON_Board_LED, HIGH);
delay(250);
}
digitalWrite(ON_Board_LED, HIGH); //--> Turn off the On Board LED when it is connected to the wifi router.
//----------------------------------------If successfully connected to the wifi router, the IP Address that will be visited is displayed in the serial monitor
Serial.println("");
Serial.print("Successfully connected to : ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("Please tag a card or keychain to see the UID !");
Serial.println("");
}
void loop() {
// put your main code here, to run repeatedly
readsuccess = getid();
if (readsuccess) {
digitalWrite(ON_Board_LED, LOW);
WiFiClient client;
HTTPClient http; //Declare object of class HTTPClient
String UIDresultSend, postData;
UIDresultSend = StrUID;
//Post Data
postData = "UIDresult=" + UIDresultSend;
http.begin(client, "http://192.168.1.8/rfid-nodemcu/getUID.php"); //Specify request destination
http.addHeader("Content-Type", "application/x-www-form-urlencoded"); //Specify content-type header
int httpCode = http.POST(postData); //Send the request
String payload = http.getString(); //Get the response payload
Serial.println(UIDresultSend);
Serial.println(httpCode); //Print HTTP return code
Serial.println(payload); //Print request response payload
http.end(); //Close connection
delay(500);
digitalWrite(ON_Board_LED, HIGH);
}
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
//----------------------------------------Procedure for reading and obtaining a UID from a card or keychain---------------------------------------------------------------------------------//
int getid() {
if (!mfrc522.PICC_IsNewCardPresent()) {
return 0;
}
if (!mfrc522.PICC_ReadCardSerial()) {
return 0;
}
Serial.print("THE UID OF THE SCANNED CARD IS : ");
for (int i = 0; i < 4; i++) {
readcard[i] = mfrc522.uid.uidByte[i]; //storing the UID of the tag in readcard
array_to_string(readcard, 4, str);
StrUID = str;
}
mfrc522.PICC_HaltA();
return 1;
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
//----------------------------------------Procedure to change the result of reading an array UID into a string------------------------------------------------------------------------------//
void array_to_string(byte array[], unsigned int len, char buffer[]) {
for (unsigned int i = 0; i < len; i++)
{
byte nib1 = (array[i] >> 4) & 0x0F;
byte nib2 = (array[i] >> 0) & 0x0F;
buffer[i * 2 + 0] = nib1 < 0xA ? '0' + nib1 : 'A' + nib1 - 0xA;
buffer[i * 2 + 1] = nib2 < 0xA ? '0' + nib2 : 'A' + nib2 - 0xA;
}
buffer[len * 2] = '\0';
}