Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi folks;

I am trying I am trying to send Mfrc522 data to a c# application through Nodemcu esp8266 which is acting as access point for c# app.
I have modified the code which i got from the following site:-

http://tdmts.net/2017/02/04/controlling-an-arduino-with-a-wifi-esp8266-adapter-using-a-windows-10-universal-app/

and my modified code is :=

#include ESP8266WiFi.h>
#include SPI.h>
#include MFRC522.h>
 
const char* AP_SSID ="IoT4143" ;
const char* AP_PASSWORD ="iot4143";

#define RST_PIN D3
#define SS_PIN D4

MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance
 

 
WiFiServer server(80);
WiFiClient client;
 
void wifiConnect()
{
  WiFi.disconnect();
  WiFi.softAP(AP_SSID, AP_PASSWORD);
  
  int watchDog = 0;
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    watchDog++;
    if(watchDog == 60)
    {
      WiFi.disconnect();
      WiFi.printDiag(Serial);
      watchDog = 0;
      return;
    }
  }
 
  server.begin();
}
 
void setup() {
  Serial.begin(115200);
  SPI.begin();      // Init SPI bus
  mfrc522.PCD_Init();   // Init MFRC522
  mfrc522.PCD_DumpVersionToSerial();  // Show details of PCD - MFRC522 Card Reader details
  Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
  
  wifiConnect();
}
 
void loop() {
  //Are we connected to WiFi?
  if(WiFi.status() != WL_CONNECTED)
  {
    wifiConnect();
  }
 
  //Wait for a connection attempt
  client = server.available();
  if (!client) {
    return;
  }
   
  // Wait until the client sends some data
  int watchDog = 0;
  while(!client.available())
  {
    delay(1);
    if(watchDog == 10000)
    {
      watchDog = 0;
      return;
    }
    watchDog++;
  }

  sendData();
}

 void sendData()
 {
  
  // Read the first line of the request
  String request = client.readStringUntil('\r');
  client.flush();
   
  // Match the request
  while(request=="READSTOP")
  {
    Serial.println("RFID READING STARTED..."); //Forward to C# App
    if ( ! mfrc522.PICC_IsNewCardPresent()) {
    return;
  }

  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) {
    return;
  }

  // Dump debug info about the card; PICC_HaltA() is automatically called
  client.print(mfrc522.uid);
}
 
    Serial.println("RFID READING STOPPED"); //Stop server

     delay(1);
  
  client.stop();
  }


I am very new to hardware/network programming i dont know what will be possible errors of above code and will it work or not

when i verified the above code in arduino ide the wasa error on this line of code:=

client.print(mfrc522.uid);

error:= no matching function for call to 'WiFiClient::print(MFRC522::Uid&)'


I just want to send rfid data to c# app all the validation will be done in c#.

When the connect button in application is clicked the "READSTART" string is send to nodemcu and when disconnect is clicked the "READSTOP" string is sent.

Please need help!!!!

What I have tried:

I have not uploaded the code on my hardware becoz of doubt in my code.
Posted
Updated 29-Dec-17 1:55am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900