Hey there! Hope you're doing great! As you may have seen lately, I'm working on a project where I need to keep track on time, and since this is pretty important for my goal, I get it from an NTP server just in case the battery of my DS3231 module runs out of power (in which you've helped me previously).
Now, I need another method to set the time, which is manually, through buttons, the problem is, that I've run out of GPIOs in my ESP8266 module. So I wanted to know if there would be a problem connecting the SDA and SLC pins of my DS3231 to two different ESP8266 modules, the first one would be the clock itself, and the other would be to do the time set.
Is important to clarify that this second circuit already exists in my system, since it performs another tasks, so It's not something I'll just add to set the time. And I'd like to know if is something possible, of course, They'll be connected to the same source.
Other solution would be to use the GPIO1 and GPIO4 (the pins connected to the Built-in LEDS) of my clock ESP8266 circuit as inputs, but I'd like to ask for any advice here, since It's gave me problems before (either fails often, or has problems during compilation).
GPIO 1 is also the UART's TX pin. Are you using Serial in some way in your project ?
You should consider either port expanders, or for just a few buttons maybe a resistor ladder Though if you want to read multiple button presses at the same time, you need to modify the circuit suggested in the link a little.
Also since you have only 1 ADC on an ESP.
Well that is not what i meant, if you built a resistor ladder and read the result through that, you can read the state of several buttons with it. Yes if you observe the maximum voltage level, you can use it as such, but it would be wasteful in resources. about the ADC
On the clock i have, i have 5 buttons.
Snooze (it's an alarm clock)
Time
Alarm
Hour
Minutes
Of course to set either the time or the alarm you would press a combination of 2 buttons. So in that case you could make 2 resistor ladders that you power from a GPIO pin and increase the value of the primary resistor to 10K and adding an extra one to GND so that it maintains the voltage divider even when there is nothing pressed.
Like this the maximum voltage on the ADC should be less than a 1/4 of 3.3v and take a near equal step down from that depending on which button is being pressed, with the leftmost button resulting in a 0v reading.
If you use a few i should mention that controlling them with a GPIO means that you set all the pins HIGH, and switch them into 'OUTPUT' pinmode 1 at a time and back to 'INPUT' , And not switching them between HIGH & LOW which would result in influencing each other. And there should probably be an extra diode between each ladder and the ADC. Something like a 1N4148. Of course there is also port expanders and or bitshifters depending on how many buttons you want.
That sounds backwards to me. I suggest you should always get time from NTP if available, and use that to update/correct the RTC. if NTP not available, then read time from the RTC.
A third method? Why? For when there is no WIFI/internet connection and the RTC battery is dead? What are the chances of both happening at the same time?
Yes, I think it would be a problem. The 2 ESP would both be master devices and the RTC would be the slave device. The i2c standard allows for multiple master devices on the same bus, but I've never seen it done with any type of Arduino. I suspect 1 master is the limit.
Crazy idea! I agree with @Deva_Rishi : use 1 esp and give it more pins using the i2c bus. For example pcf8574 will give 8 more digital inputs/outputs.
In order to set the time with buttons, you will need some kind of display I think. Do you have that already? If not, a 128x32 OLED with i2c interface would be small and convenient.
so you are looking for an option how to set the RTC without NTP - without buttons?
You are on a ESP8266. Make a simple HTML Form and let the user enter the time manually with the webserver.