Any Idea how to read/write from/to specific bytes in RFID?

I don't have any piece of code currently, I'm in an internship and I'm asked to write let's say 3 variables from the same block, let's say user_id user_name user_role in the same block (block 4 from sector 1) I have some ideas like concat the 3 variables in one variable then adding it to the block, but then how can I possibly read the 3 variables separately, is it possible for example to write in the first or last 8 bytes of a block? any advice, ideas, codes r welcome!

well you could issue 3 write to keep things simple or you could put you 3 variables in a packed structure and write the structure into the "block 4 from sector 1"

the example rfid/rfid_write_personal_data.ino at master · miguelbalboa/rfid · GitHub would give you some ideas on how to write data (assuming it's a RFID-RC522)

1 Like

Hi guys, my problem is that I want to write 2 variables in the same block, one in the first 8 bytes of a block and the other on the last 8, is it possible? how can I do it

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

Just address the target block correctly.

I'm a newbie can u explain what u mean by address? any piece of code or example is welcome

Hello, do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (including code tags and necessary documentation for your ask).

If you are using the MFRC522 library There is a write example. did you read it / try it?

every example I found is based on writing on entire blocks not specific bytes

@sakaturi
I have merged 2 of your 3 topics on the same subject into this one. I have deleted the 3rd topic as it has no replies. Posting the same topic multiple times is against to forum rules that @J-M-L linked to in reply #7. By repeatedly asking the same or similar question you are wasting the time of the volunteers trying to help you.

If you post the same question again you will be prevented from posting in the forum.

Thank you.

So read the block, update the bytes that need updating and write the block back.

Or if you don’t care about what’s already there, just consider the extra bytes as padding.

Please make note of @PerryBebbington’s note. Double posting is bad, triple posting is showing disrespect.

Yes that is because you can't write anything but blocks so you have to resort to what @J-M-L just told you.

Sry I'm still new here

it's OK we all started by being new.

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