adafruit / Adafruit_CircuitPython_24LC32

CircuitPython Driver for Adafruit 24LC32 I2C EEPROM Breakout 32Kbit / 4 KB
MIT License
6 stars 6 forks source link

Using this library for Adafruit ST25DV16K I2C RFID EEPROM Breakout #3

Closed dglaude closed 9 months ago

dglaude commented 2 years ago

I have been able to use a modified version of this library and demo code to read the EEPROM content of ST25DV16K.

Maybe a more generalized version of EEPROM reading where the size and I2C address can be changed would be more usefull.

So here are the change I made are : _MAX_SIZE_I2C = const(0x800) # 16kbits and def __init__(self, i2c_bus, address=0x53, write_protect=False, wp_pin=None):

I have used the following code:

import board
import adafruit_st25dv16

i2c = board.I2C()
eeprom = adafruit_st25dv16.EEPROM_I2C(i2c)

print("length: {}".format(len(eeprom)))

for i in range(0, 4):
    j = i * 16
    hex_string = ":".join("%02x" % b for b in eeprom[j:j+15])
    print(j, "> ", hex_string, "> ", eeprom[j:j+15])

The result is a dump:

0 >  e1:40:40:05:03:10:d1:01:0c:55:01:73:74:2e:63:6f >  bytearray(b'\xe1@@\x05\x03\x10\xd1\x01\x0cU\x01st.co')
16 >  6d:2f:73:74:32:35:fe:2f:70:72:6f:64:75:63:74:2f >  bytearray(b'm/st25\xfe/product/')
32 >  34:37:30:31:fe:00:00:00:00:00:00:00:00:00:00:00 >  bytearray(b'4701\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
48 >  00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 >  bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

We can clearly see the URL written by ST arduino demo code: "st.com/st25" (Hello World exemple from https://github.com/stm32duino/ST25DV )

And part of the URL maybe set by Adafruit in factory: "/product/4701"

So with a bit of code that properly structure the NFC TAG value in the EEPROM it should be possible to use the ST25DV16K from CircuitPython for basic usage of setting the value of the tag.

dglaude commented 2 years ago

I have a success writing almost arbitrary URI into the ST25DV16K from CircuitPython: https://gist.github.com/dglaude/6e1fbe1e2c2d1222f99872a506a48a2b

Neradoc commented 2 years ago

Oh I didn't see that until Dan mentioned it today. I have started developing a little library to write to the tag, it's super basic and has no check for size or... anything, but it can write urls or texts, and I'd like to give it the ability to read and decode them too (since I am able to write to the tag with my phone). No idea when or if I'd have time to delve more into it though. https://github.com/Neradoc/circuitpython-st25dv

FoamyGuy commented 9 months ago

Max size argument is available for usage now.