Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By JC999
#82184 Hello all, I am new here, have read a lot of topic to advance in my project which is doing quite well, so far... (1 server, several clients)

Yes. I made that mistake, using the IO 0, connected at boot time.

I hope someone will be able to guide me to a solution that is not to start over ;-)

The situation: I have made made some PCB board after a lot of test because I need to create a lot of client for my server. The client and the server need to be in sync, to the milli second ( tricky, I know...).
This lead to 2 problem to solve: 1/ get the sync, 2/ keep the sync.
Solution to get the sync was easy, send the exact time of the server to every client via wire & serial.
Then, to keep the sync, use an RTC (DS3231) and compute the delta between the server sqw and the client sqw. This allow every client to be in complete sync with the server, even after a power down of the client and/or server.

But, that was in theory.
The problem is the RTC, connected in I2C (with an oled after, but that is not important).
As I have explained, I am using the RTC SQW, 1hz, and I had only 2 pin available to connect the SQW, I choose pin D3, the IO 0. And I have read the last days that IO 0 is used by the esp to toggle boot sequence (f*ck).

As long as the RTC battery is not connected, everything is fine. but when I put the battery, sometime, the ESP doesn't boot using normal procedure. ( it just not start at all ... )
I guess it's because of the SQW, being up half a second every second, if I switch on the board at that moment, it doesn't boot. (but I get lucky sometimes as well... ).

It's a (lot of) wemos D1 mini pro.
RTC is DS3231(M). I2C on IO 4 and 5, SQW on IO 0, 32hz not connected.
SPI pins are used for nRF24l01.

What would be the possible solution for this, to keep using IO 0 ?
- Would it be possible to delay ( 1wave?) the SQW on the RTC when power switches from VCC instead of the battery ?
- Would it be possible to manage the internal use of IO 0 at boot myself ? to change the ESP to use another pin ?
- about the DS, is it possible to whatever the state was when going from VSS>Battery, always disable the SQW?
( I already disable BBS on the DS3231 to avoid SQW while on battery but it doesn't help at startup).

Clients firmware updates are done via HttpUpdate. And just before any update, I am now disabling SQW, and this "seems" to work.

A solution I am now testing is to add a neo6m gps to every clients, and get the sync this way. I don't need to know the exact time of the world, just that all my devices are ticking at the exact(+/- 1ms) same time.
Anyway, an RTC has tolerance, will have some error ( the DS3231M has a tolerance of 5ppm...) so may be this is the only solution...
I connected the GPS on D4 ( the internal led ), one IO for both RX & TX ( I don't TX anyway ) with espsoftSerial.

Thanks for your time & help ;-)
JC