General area when it fits no where else

Moderator: Mmiscool

User avatar
By matherp
#36820 I've just rechecked i2 write in my clock code on 1.67 ESP-12E/F and it works fine:

Code: Select alli2c.begin(address) 'start a transaction
i2c.write(0) 'point to the first address location
i2c.write(0) 'Set to BCD 00
i2c.write(88) 'Set to BCD 58
i2c.write(8) 'Set to BCD 8
i2c.write(1) 'Set to BCD 1
i2c.write(32) 'Set to BCD 20
i2c.write(18) 'Set to BCD 12
i2c.write(21) 'Set to BCD 15
i2c.end() 'finish transaction
delay 10


The above correctly sets the time to : 8:58:00 20/12/2015

Jim: have you got a DS3231 you can put on your analyser and test my code in your environment?
User avatar
By viscomjim
#36833 I am away from my setup, but I will give this exact code a try with the LA as soon as I get back. I am glad to see that it is working for you. This gives me hope.
User avatar
By viscomjim
#36861 THANK GOD!!!! Finally it works!!!! First of all, I tried Matherps code for the DS3231 and it worked just fine, so writing was working. The LA came to the rescue like this...

First of all, I was getting the i2c.begin(112) on the LA, but notice I was getting a NAK instead of an ACK. So a bit of fiddling with the resistors and viola, now getting ACK. YEAH!!!

Still could not get the display to work, so I hooked it back up to the uMite circuit and captured what was working on the LA. Then compared it to the esp to see what the difference was.

Here is a capture of working code on the uMite...

Code: Select allTime [s], Analyzer Name, Decoded Protocol Result
1.755961416666667,I2C,Setup Write to [0x70] + ACK
1.756055500000000,I2C,0x21 + ACK
1.756327666666667,I2C,Setup Write to [0x70] + ACK
1.756421666666667,I2C,0x81 + ACK
1.756696000000000,I2C,Setup Write to [0x70] + ACK
1.756790083333333,I2C,0xEF + ACK
1.757098416666667,I2C,Setup Write to [0x70] + ACK
1.757192416666667,I2C,0x00 + ACK
1.757286500000000,I2C,0x06 + ACK
1.757600916666667,I2C,Setup Write to [0x70] + ACK
1.757695000000000,I2C,0x02 + ACK
1.757789000000000,I2C,0x5B + ACK
1.758098916666667,I2C,Setup Write to [0x70] + ACK
1.758192916666667,I2C,0x06 + ACK
1.758287000000000,I2C,0x4F + ACK
1.758600166666667,I2C,Setup Write to [0x70] + ACK
1.758694166666667,I2C,0x08 + ACK
1.758788250000000,I2C,0x66 + ACK


And here is what was captured on the esp...

Code: Select allTime [s], Analyzer Name, Decoded Protocol Result
1.823055250000000,I2C,Setup Write to [0x70] + ACK
1.823169583333333,I2C,0x21 + ACK
1.823260666666667,I2C,0x81 + ACK
1.823351750000000,I2C,0xEF + ACK
1.847554500000000,I2C,Setup Write to [0x70] + ACK
1.847668833333333,I2C,0x00 + ACK
1.847759833333333,I2C,0x06 + ACK
1.872106833333333,I2C,Setup Write to [0x70] + ACK
1.872221166666667,I2C,0x02 + ACK
1.872312166666667,I2C,0x5B + ACK
1.898349583333333,I2C,Setup Write to [0x70] + ACK
1.898463916666667,I2C,0x06 + ACK
1.898555000000000,I2C,0x4F + ACK
1.924500666666667,I2C,Setup Write to [0x70] + ACK
1.924615000000000,I2C,0x08 + ACK
1.924706000000000,I2C,0x66 + ACK


You can see that the first three writes that initialize the display need to be 3 separate i2c operations. I changed the code by adding i2c.begins and i2c.ends to separate the first 3 operations and needed to get plastic surgery to remove the smile from my face. If you don't have a logic analyzer, do yourself a favor and get one. This is the only way I could have seen what was happening.

Anyway, time to get the www clock working...

Thanks to Mike and Matherp for your help. It pays to be persistent!!!