How to covert data RFID from string to char

Bare with me. I’m not very good at english and writing in Arduino/C.
I don't know how to convert uid string to char. I want to send the data to antares and that need char

Welcome to the forum

Your topic was MOVED to its current forum category as it is more suitable than the original

Please post your sketch (use code tags when you do) that reads the RFID tag so that we can see what you have done so far

#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9

MFRC522 rfid(SS_PIN, RST_PIN);
MFRC522::MIFARE_Key key;

String strID;

void setup() {
  SPI.begin();
  rfid.PCD_Init();
  Serial.begin(9600);
  Serial.println("I am waiting for card...");
}

void loop(){
  if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial())
    return ;

  // Serial.print(F("PICC type: "));
  MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
  // Serial.println(rfid.PICC_GetTypeName(piccType));

  strID = "";
  for (byte i = 0; i <rfid.uid.size; i++) {
    strID +=
      (rfid.uid.uidByte[i] < 0x10 ? "0" : "") +
      String(rfid.uid.uidByte[i], HEX) +
      (i != rfid.uid.size-1 ? ":" : "");
  }

  strID.toUpperCase();
  Serial.print("ID : ");
  Serial.print(strID);
  delay(1000);
}

You can use the c_str() method.


void functionThatNeedChar(const char* myCharPt) {
  Serial.println(myCharPt);
}

void loop(){
  ....
  strID.toUpperCase();
  Serial.print("ID : ");
  Serial.print(strID);
  
  functionThatNeedChar(strID.c_str());

  delay(1000);
}


What exactly does Antares need ?

It seems odd that it should require a zero terminated array of chars that represent a number in HEX format. What datatype is the target field and why can't it be just an integer ?

Antares need char, it's like database. I found this code in internet, and i don't really understand about it. so what should i do to be able to send the id in char form?

did you try what's in post #4 ?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.