Clock loses I2C connection with ESP8266

More
7 months 4 weeks ago #7764 by Stackerlee
@vladco Thanks for the input! I haven't yet connected it via serial while connected to the MCU to see any debug messages (when enabled of course). Worth a try.
As I said, it is the isolated part of the code that handles the IP display that causes the connection to fail. Removing this and it works flawlessly (well, without showing the IP adress obviously).
The ESP8266 doesn't hang, it keeps working but the I2C connection is lost. Very strange.
I've tried several ESP8266 modules and on two different clock, changed the ATMEGA328p, complete erase in between and so on - same results. V1.0.3 works without any problem.
This isn't really a problem, I think I can continue my life without having my clock showing it's IP adress, but it bugs me not to find the cause of it.

Please Log in or Create an account to join the conversation.

More
7 months 3 weeks ago - 7 months 3 weeks ago #7777 by Ian
Hey Vladco,

well, that was my first idea to do it that way, but because the I2C in ESP is software controlled, the code wasn't available. Slave mode is a little more tricky than master mode, because it needs interrupt drivers and the timing is pretty critical.

I started working on it, but then this guy came along and started saying, "oh I know how to do that, it's really easy, I have the code, I'll post it when I clean it up, oh now I'm on holiday, look at this other cool thing, oh yeah, I'll do that slave mode thing soon, it's really easy, now I'm busy with something else, stop asking me questions about this, it's easy, you should just do it yourself, it's really easy...". By this time I had produced the first version of the code using the ESP as master. I don't think the guy really had any working code at all. I think he was just full of hot air.

In fact I then chose to keep it that way because the ESP acts as the front end for configuring the clock, and it works quite nicely. The next thing I have on the plan is to make an ESP only clock, so I just chose to stick wit it like that.

There is slave I2C code out there now, but whatever...
Last Edit: 7 months 3 weeks ago by Ian. Reason: typo

Please Log in or Create an account to join the conversation.

More
7 months 3 weeks ago #7778 by Ian
Hmmmm, I wonder...

Did you try running this with a new version of clock firmware?

Older versions don't have the IP address code, and I wonder if the ESP is saying "hey here's an IP address for you", and the clock is like "what? I don't do IP addresses... get lost" and that causes the I2C to get all upset.

Please Log in or Create an account to join the conversation.

More
7 months 3 weeks ago #7780 by Stackerlee
@Ian
Yes, I've tried all versions past Feb 21. (Clock firmware)
It does display the IP adress but only for a while, until the I2C connection is lost.
So it's fully working until the connection for some reason gets lost.
I thought maybe there were some parts of the flash memory on the ESP8266 module that were not properly erased after a new firmware flash. But I also tried flashing the firmware on a completely new module which never had any older versions on it. No difference - same results.
I also fully erased the ATMEGA328, burnt the bootloader and did a clean flash with same results.

I'm not too sure on how to debug the module (serial) while connected to the clock circuit. Can it be done?

Please Log in or Create an account to join the conversation.

More
7 months 3 weeks ago #7782 by vladco

Ian wrote: Hey Vladco,

In fact I then chose to keep it that way because the ESP acts as the front end for configuring the clock, and it works quite nicely. The next thing I have on the plan is to make an ESP only clock, so I just chose to stick wit it like that.


that is what i thought after writing my question, that i would make more sens to have the ESP as a master. Anyway for an ESP only "brain" you need to plan carefully on resources :D

Stackerlee wrote: I'm not too sure on how to debug the module (serial) while connected to the clock circuit. Can it be done?


i think i could be done, i'm don't know he schematic, but if the I2C doesn't use same pins as the the UART its ok, if you can post a link to the schematic i can take a look :)

one question regarding the hardware that is causing the issue, since the ESP8266 is a 3V3 part and the Atmega is a 5V part is there any level shifting between the two ?

Please Log in or Create an account to join the conversation.

More
7 months 3 weeks ago - 7 months 3 weeks ago #7783 by Stackerlee

one question regarding the hardware that is causing the issue, since the ESP8266 is a 3V3 part and the Atmega is a 5V part is there any level shifting between the two ?


Yes, there is a level shifter between the two.
You can see the scematic here:
Clock
WiFi module (level shifter)
Last Edit: 7 months 3 weeks ago by Stackerlee.

Please Log in or Create an account to join the conversation.

More
7 months 3 weeks ago #7784 by vladco
@Stackerlee you can connect the serial lines to pins 7(ESP RX) and 2(ESP TX) - so TX of the serial convert would go to pin 7, and RX would go to pin 2. remember also to connect ground :)

Please Log in or Create an account to join the conversation.

More
7 months 3 weeks ago #7792 by Ian
Yeah, nice!

Please Log in or Create an account to join the conversation.

More
7 months 3 weeks ago #7793 by Stackerlee
@vladco Thanks! Yes, it was pretty straight forward when you think of it.
I've built a module with 4 level shifting lines (2 for I2C and 2 for serial) and the clock is running with serial dubugging.

My only "problem" now is that it works...
It has been running for over 24 hours without losing the connection.
Now I understand even less.
Will give it more time and see what happens.

Please Log in or Create an account to join the conversation.

More
7 months 3 weeks ago #7794 by vladco
are the pullup resistors on the ESP board 10K ? I know I2C can be picky about those resistors, also i know that a common value used for I2C at least at 5V is 4.7K so can you replace the two 10K resistors with some 4.7K ones ? (talking about R1 and R2)

if you don't have 4.7K you can just solder another 10K over the existing one making it almost 4.7K

Vlad

Please Log in or Create an account to join the conversation.

Moderators: AccutronTy_EeberfestIan
Time to create page: 0.045 seconds

Search

Tube Suppliers

Go to top
JSN Boot template designed by JoomlaShine.com