serial monitor

Hi all

I got a question about the serial monitor.

I'm working on a rfid project and fully integrated an manageable in a web interface, but if i want to add a new card i need the id of them. Now i see them in the serial monitor and i want to see the output on a lcd2.

Monitor output;
11:43:53.166 -> Sending the Card ID
11:43:53.334 -> 200
11:43:53.334 -> 2147296248
11:43:53.334 -> available
And for me is only important the card id 2147296248

The code i use;
//libraries*
//RFID-----------------------------
#include <SPI.h>
#include <MFRC522.h>
//NodeMCU--------------------------
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
//************************************************************************
//#define SS_PIN D2 //D2
//#define RST_PIN D1 //D1
//#define RST_PIN 1 // RST-PIN for RC522 - RFID - SPI - Modul GPIO1
//#define SS_PIN 2 // SDA-PIN for RC522 - RFID - SPI - Modul GPIO2
#define RST_PIN 5 // RST-PIN für RC522 - RFID - SPI - Modul GPIO5
#define SS_PIN 4 // SDA-PIN für RC522 - RFID - SPI - Modul GPIO4
//************************************************************************
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
//************************************************************************
/* Set these to your desired credentials. /
const char ssid = "blablabla";
const char password = "secret";
const char
device_token = "1bea65b4df636414";
//
**********************************************************************
String URL = "http://192.168.178.32/rfidattendance/getdata.php"; //computer IP or the server domain
String getData, Link;
String OldCardID = "";
unsigned long previousMillis = 0;
//************************************************************************
void setup() {
delay(1000);
Serial.begin(115200);
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
//---------------------------------------------
connectToWiFi();
}
//************************************************************************
void loop() {
//check if there's a connection to Wi-Fi or not
if(!WiFi.isConnected()){
connectToWiFi(); //Retry to connect to Wi-Fi
}
//---------------------------------------------
if (millis() - previousMillis >= 15000) {
previousMillis = millis();
OldCardID="";
}
delay(50);
//---------------------------------------------
//look for new card
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;//got to start of loop if there is no card present
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;//if read card serial(0) returns 1, the uid struct contians the ID of the read card.
}
String CardID ="";
for (byte i = 0; i < mfrc522.uid.size; i++) {
CardID += mfrc522.uid.uidByte*;*

  • }*

  • //---------------------------------------------*

  • if( CardID == OldCardID ){*

  • return;*

  • }*

  • else{*

  • OldCardID = CardID;*

  • }*

  • //---------------------------------------------*
    // Serial.println(CardID);

  • SendCardID(CardID);*

  • delay(1000);*
    }
    //send the Card UID to the website*
    void SendCardID( String Card_uid ){

  • Serial.println("Sending the Card ID");*

  • if(WiFi.isConnected()){*

  • HTTPClient http; //Declare object of class HTTPClient*

  • //GET Data*

  • getData = "?card_uid=" + String(Card_uid) + "&device_token=" + String(device_token); // Add the Card ID to the GET array in order to send it*

  • //GET methode*

  • Link = URL + getData;*

  • http.begin(Link); //initiate HTTP request //Specify content-type header*

  • int httpCode = http.GET(); //Send the request*

  • String payload = http.getString(); //Get the response payload*
    // Serial.println(Link); //Print HTTP return code

  • Serial.println(httpCode); //Print HTTP return code*

  • Serial.println(Card_uid); //Print Card ID*

  • Serial.println(payload); //Print request response payload*

  • if (httpCode == 200) {*

  • if (payload.substring(0, 5) == "login") {*

  • String user_name = payload.substring(5);*

  • // Serial.println(user_name);*

  • }*

  • else if (payload.substring(0, 6) == "logout") {*

  • String user_name = payload.substring(6);*

  • // Serial.println(user_name);*

  • }*

  • else if (payload == "succesful") {*

  • }*

  • else if (payload == "available") {*

  • }*

  • delay(100);*

  • http.end(); //Close connection*

  • }*

  • }*
    }
    //**connect to the WiFi
    void connectToWiFi(){

  • WiFi.mode(WIFI_OFF); //Prevents reconnection issue (taking too long to connect)*

  • delay(1000);*

  • WiFi.mode(WIFI_STA);*

  • Serial.print("Connecting to ");*

  • Serial.println(ssid);*

  • WiFi.begin(ssid, password);*

  • while (WiFi.status() != WL_CONNECTED) {*

  • delay(500);*

  • Serial.print(".");*

  • }*

  • Serial.println("");*

  • Serial.println("Connected");*

  • Serial.print("IP address: ");*

  • Serial.println(WiFi.localIP()); //IP address assigned to your ESP*

  • delay(1000);*
    }
    //=======================================================================
    See screenshot.
    Thanks in advanced
    Hans


@aduinoroot

Your topic was Moved to it's current location / section as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

This is the line in your sketch that sends the Card ID to Serial Monitor:

    Serial.println(Card_uid);     //Print Card ID

Right after that you could put a line to display the ID on lcd2:

    lcd2.println(Card_uid);     // Show Card ID on LCD

johnwasser:
This is the line in your sketch that sends the Card ID to Serial Monitor:

    Serial.println(Card_uid);     //Print Card ID

Right after that you could put a line to display the ID on lcd2:

    lcd2.println(Card_uid);     // Show Card ID on LCD

That it wonderful it works thank you

Please follow the advice on posting a programming question given in Read this before posting a programming question

In particular note the advice to Auto format code in the IDE and to use code tags when posting code here as it prevents some combinations of characters in code being interpreted as HTML commands such as italics, bold or a smiley character, all of which render the code useless