read CID of SD card with SD.h library I would like to be able to read the serial numbers of SD cards using the SD.h library. Only reading the values is enough, I am not looking to modify the CID.
This should be possible but I do not have the programming skills to get it running.

I am using an esp8266 and already have the SD card running and working correctly. Only the chipselect needed to be modified for the SD library to work.

So far I have found this in Sd2Card.h

      /**
   * Read a cards CID register. The CID contains card identification
   * information such as Manufacturer ID, Product name, Product serial
   * number and Manufacturing date. */
  uint8_t readCID(cid_t* cid) {
    return readRegister(CMD10, cid);
  }
  /**


And in Sd2Card.cpp there is this:

/** read CID or CSR register */
uint8_t Sd2Card::readRegister(uint8_t cmd, void* buf) {
  uint8_t* dst = reinterpret_cast&lt;uint8_t*&gt;(buf);
  if (cardCommand(cmd, 0)) {
    error(SD_CARD_ERROR_READ_REG);
    goto fail;
  }
  if (!waitStartBlock()) goto fail;
  // transfer data
  for (uint16_t i = 0; i &lt; 16; i++) dst[i] = spiRec();
  spiRec();  // get first crc byte
  spiRec();  // get second crc byte
  chipSelectHigh();
  return true;

 fail:
  chipSelectHigh();
  return false;
}


So it seems that the underlying code has been prepared in the library already, my question is how would I include it into a sketch like CardInfo.ino?
The method is visible from within your sketch. You just need to first create a cid_t struct like this in your sketch:

cid_t cid;  // at the top with the other globals


Then call readCID() anywhere in setup() after the card has been initialized.

card.readCID(&amp;cid);
Serial.print("Serial number: "); Serial.println(cid.psn); // psn is the serial number field of the struct


Check out SdInfo.h for the other struct members.