Page 5 of 5
Re: I2C EEPROM on uPy/ESP8266?
Posted: Thu Feb 02, 2017 3:20 pm
by mcauser
Facepalm.
The STM32 board that I was using has an AT24C08 1024k EEPROM on the back, exposed at the same address 0x50.
It actually has 4x devices, each with 256k. [80,81,82,83].
My tests that were passing were to the onboard EEPROM, not the LC Tech module!
Re: I2C EEPROM on uPy/ESP8266?
Posted: Thu Feb 02, 2017 5:46 pm
by kfricke
Re: I2C EEPROM on uPy/ESP8266?
Posted: Thu Feb 02, 2017 7:07 pm
by mikruth
Just a thought... The eeprom memory is 16 bits. Arduino sends 2 bytes consisting of MSB followed by LSB. Are we sending a 16 bit address with micropython?
Re: I2C EEPROM on uPy/ESP8266?
Posted: Thu Feb 02, 2017 9:06 pm
by deshipu
Only if you passed addrsize keyword argument to writeto_mem that specifies it. See
http://micropython.org/resources/docs/e ... operations
Note that the documentation is wrong and the addrsize is already supported on ESP8266.
Re: I2C EEPROM on uPy/ESP8266?
Posted: Fri Feb 03, 2017 1:27 am
by mcauser
Ok, so this works on my WeMos D1 Mini on 3v3:
Code: Select all
# esp8266 -- eeprom
# 3v3 ------ vcc
# gnd ------ gnd
# D1 scl --- scl
# D2 sda --- sda
from machine import I2C, Pin
i2c = I2C(scl=Pin(5), sda=Pin(4), freq=400000)
i2c.scan()
# [80]
# does not work, addrsize defaults to 8.
i2c.writeto_mem(0x50, 0, b'hello world')
i2c.readfrom_mem(0x50, 0, 11)
# b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
# does work!
i2c.writeto_mem(0x50, 0, b'hello world', addrsize=16)
i2c.readfrom_mem(80, 0, 11, addrsize=16)
# b'hello world'
i2c.readfrom_mem(80, 2, 11, addrsize=16)
# b'llo world\xff\xff'
Adding addrsize=16 to reads/writes makes it work.
Re: I2C EEPROM on uPy/ESP8266?
Posted: Fri Feb 03, 2017 10:02 am
by ioukos
Hello,
I'll give this "address size" solution a shot this evening (in 9 hours here).
Anyway, thank you, you are very talented and very well educated !
i'll keep you informed.
Re: I2C EEPROM on uPy/ESP8266?
Posted: Fri Feb 03, 2017 4:04 pm
by warren
@mcauser:
That works *perfectly*!
Thank you so much...
Re: I2C EEPROM on uPy/ESP8266?
Posted: Fri Feb 03, 2017 4:46 pm
by mikruth
That's great.....Thanks!
Re: I2C EEPROM on uPy/ESP8266?
Posted: Fri Feb 03, 2017 6:02 pm
by ioukos
Work like a charm !