you call rfidRead() twice
4 or more times, actually.
Don't quite understand your statment "There is only ONE place where PrintHex() should be copying data to serialNumH, not 4." Can you explain,please.
From loop():
while (rfidRead(rfidData, ADDR_Serial) != 0);
Serial.println();
PrintHex(rfidData, 4); // The rfidData string should now contain the tag's serial number, so display it on the Serial Monitor
And store it in serialNumH.
From loop():
while (rfidRead(rfidData, ADDR_Type) != 0); // Read the data
PrintHex(rfidData, 4); // The rfidData string should now contain the data from the Counter address(3),
and shit on the value stored in serialNumH.
From prePay():
while (rfidRead(rfidData, ADDR_Counter) != 0); // Read the data
PrintHex(rfidData, 4); // The rfidData string should now contain the data from the Counter address(3),
and shit on the value stored in serialNumH.
From payPerVisit():
while (rfidRead(rfidData, ADDR_Counter) != 0); // Read the data
PrintHex(rfidData, 4); // The rfidData string should now contain the data from the Counter address(3),
and shit on the value stored in serialNumH.
prePay() and payPerVisit() call write_data(), AFTER calling PrintHex() and shitting on serialNumH.
tmp is declared in the PrintHex function so I cannot print it to the SD card in the printData function
The latter is true. The former need not be. Not that it matters. Only one of the 4 places where PrintHex is called should be copying data to serialNumH.
Frankly, PrintHex() is a stupid name, since the function does not print anything. Get rid of the three incorrect calls (the 2nd one in loop() and the ones in prePay() and payPerVisit()) and rename the function to something that describes what it ACTUALLY does.
Both tmp and serialNumH print correctly using Serial.print().
ONLY after the first call. But that is NOT when you actually write the data to the SD card. Prove it to yourself. Print tmp and serialNumH IN PrintHex().