I2C EEPROM on uPy/ESP8266?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
User avatar
deshipu
Posts: 1346
Joined: Thu May 28, 2015 5:54 pm

Re: I2C EEPROM on uPy/ESP8266?

Post by deshipu » Tue Jan 31, 2017 12:29 pm

However, there is a problem with those pullup resistors if you are going to power this with 5V (which I suspect the EEPROM requires) -- since they are also connected to the 5V line. To use a 5V device with i2c with a 3v3 device, you need to connect the pullups to the 3v3 line, so that the maximum voltage seen by the devices is 3.3V.

mikruth
Posts: 18
Joined: Wed Jan 11, 2017 6:00 pm

Re: I2C EEPROM on uPy/ESP8266?

Post by mikruth » Tue Jan 31, 2017 4:13 pm

ioukos or mcauser ... is the module you have working ok with micropython?
Thanks

User avatar
ioukos
Posts: 33
Joined: Wed Oct 19, 2016 11:31 am
Location: Alsace, Europe

Re: I2C EEPROM on uPy/ESP8266?

Post by ioukos » Tue Jan 31, 2017 7:45 pm

mikruth,

no, I'm sorry and I tried many things ;
To sum up : I'm using 1.8.7

Code: Select all

>>> i2c.writeto_mem(0x50, 0, bytearray([104, 101, 108, 108, 111, 32]))          
>>> i2c.readfrom_mem(0x50, 0, 11)                                               
b'Qc\x83`\xc9<\x0e\xa3\xb6\xc9\xae'                                             
>>> i2c.readfrom_mem(0x50, 0, 11)                                               
b'hi]\x985\x07\x9a}}\x05!'
I tried with the module connected to 5V and 3.3V.

warren
Posts: 73
Joined: Tue Jul 12, 2016 5:47 pm

Re: I2C EEPROM on uPy/ESP8266?

Post by warren » Wed Feb 01, 2017 5:42 pm

ioukos wrote:Warren, did you succeed ?
Nope. I hit a brick wall and was considering getting another EEPROM to see if that was the issue...but now I read your post and the one from mikruth I see that there is probably an issue with the code...
ioukos wrote:My goal is to store on eeprom a timestamp (unix) and a value from a sensor, do you think it's possible ?
I can see no reason why not!

I intend to use these EEPROMS to keep state on all sorts of things across the reboot-boundary. They are such a small overhead in terms of space and cost that it would be unreasonable to risk trashing the ESP8266 flash when you could use one of these chips. Put them on a socket and if you ever go beyond their natural lifespan, you just replace them!

I too continue to get only /xff back from the chip.....awaiting developments!

Thanks

User avatar
deshipu
Posts: 1346
Joined: Thu May 28, 2015 5:54 pm

Re: I2C EEPROM on uPy/ESP8266?

Post by deshipu » Wed Feb 01, 2017 9:21 pm

The fact that just connecting the eeprom to the esp8266 erases it suggests, that the issue is not with the code or esp's i2c peripheral, but either with the power or some rogue signals that are getting sent on boot.

warren
Posts: 73
Joined: Tue Jul 12, 2016 5:47 pm

Re: I2C EEPROM on uPy/ESP8266?

Post by warren » Wed Feb 01, 2017 9:47 pm

Just to confirm, I have the 25AA512 running at 3.3 volts. There are two pullup resistors to +3.3v - one on scl and one on sda.

i2c.scan() returns an address for the EEPROM (80)

A write command does NOT return any error:

Code: Select all

>>> i2c.writeto_mem(0x50, 0, bytearray([104, 101, 108, 108, 111, 32]))
>>> 
If I remove the resistors, I get variable rubbish when I try to scan.
So the chip/wiring gives every indication that it is correct and working...
A write command does NOT yield any error, but the read command just returns the "b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'" stuff...

What other tests could I do (baring a logic analyser) to locate the problem?

User avatar
deshipu
Posts: 1346
Joined: Thu May 28, 2015 5:54 pm

Re: I2C EEPROM on uPy/ESP8266?

Post by deshipu » Thu Feb 02, 2017 12:36 am

I'm really running out of ideas.

Can you try this?
  • write some things with Arduino,
  • disconnect from Arduino, connect again,
  • read it with Arduino to verify that it has been written and retained,
  • connect only VCC and GND to the ESP8266, switch on, switch off,
  • connect to Arduino and verify if the data is still there,
  • connect only VCC and GND to the ESP8266, switch on, connect the data lines while it's switched on, try the read command (don't run the i2c.scan() command), switch off,
  • connect to Arduino, verify if the data is still there,
  • connect to ESP8266, try the read command, run the i2c.scan(), try the read command again...

mikruth
Posts: 18
Joined: Wed Jan 11, 2017 6:00 pm

Re: I2C EEPROM on uPy/ESP8266?

Post by mikruth » Thu Feb 02, 2017 9:47 am

After many tests, it seems that the ESP running micropython is not reading, writing or destroying any data on the eeprom.
I previously had some problems with erroneous data due to a broken jumper cable.
The eeprom can be found OK with xxx.scan() on the ESP and will also be found correctly, when the eeprom address is changed, so it can see the chip, but any read or write commands are accepted but don't seem to be executed.
One other thing I noticed is that if the sda line is not connected to the eeprom, Arduino incorrectly returns 255 for every memory location.

User avatar
Frida
Posts: 38
Joined: Sat Jan 30, 2016 2:20 pm
Location: Middelfart, Denmark

Re: I2C EEPROM on uPy/ESP8266?

Post by Frida » Thu Feb 02, 2017 1:56 pm

@ warren

From the datasheet http://ww1.microchip.com/downloads/en/D ... 21754M.pdf


Page Write Time 5 ms max.

Note:
The 24XX512 does not generate any
Acknowledge bits if an internal programming
cycle is in progress.



7.0
ACKNOWLEDGE POLLING
Since the device will not acknowledge during a write
cycle, this can be used to determine when the cycle is
complete (this feature can be used to maximize bus
throughput). Once the Stop condition for a Write
command has been issued from the master, the device
initiates the internally timed write cycle. ACK polling
can be initiated immediately. This involves the master
sending a Start condition, followed by the control byte
for a Write command (R/W
=
0
). If the device is still
busy with the write cycle, then no ACK will be returned.
If no ACK is returned, then the Start bit and control byte
must be re-sent. If the cycle is complete, then the
device will return the ACK and the master can then
proceed with the next Read or Write command. See
Figure 7-1 for flow diagram.

Or try a delay after each byte or bytes.
Yes Frida is my watchdog!

User avatar
mcauser
Posts: 379
Joined: Mon Jun 15, 2015 8:03 am

Re: I2C EEPROM on uPy/ESP8266?

Post by mcauser » Thu Feb 02, 2017 2:51 pm

I've run some tests with multiple WeMos D1 Minis, a WeMos D1 Mini Pro, a PyBoard 1.0 and my VCC-GND STM32F407VET6 board and captured reads and writes with a logic analyser.

In summary, I couldn't get any ESP8266 on either 3v3 or 5v rails to read/write to the device. All return b'\xff\xff'...
PyBoard 1.0 at v1.8.2 and v1.8.7 on 3v3 using both software and hardware I2C was also unable to read/write to the device.
My VCC-GND STM32F407VET6 board running v1.8.7 using 3v3 was the only device that worked every time, with every test.
I tried two identical EEPROM modules. LC Technology AT24C256. Both working as expected with the STM32 board.
Bytes written with the STM32 were still present after failed overwrite attempts with other boards.

Captures and executed scripts here:
https://www.dropbox.com/sh/4ga53p4226su ... VEJha?dl=0
To view the captures, you'll need the free Saleae Logic app: https://www.saleae.com/downloads

Post Reply