From my understanding the Timer function relies on the Sonoff unit have access to a NTP server.
If communication is lost to the NTP or the Wifi I assume that the Timers will cease to function as the Sonoff will not know what time it is.
Again I assume the Sonoff has no inbuilt clock to hold the time once it gets its Time from the NTP.
If this is correct would it be possible to add a Real Time Clock board to the Sonoff as used in a Raspberry pi?
Hi,
From my understanding the Timer function relies on the Sonoff unit have access to a NTP server.
Yes
If communication is lost to the NTP or the Wifi I assume that the Timers will cease to function as the Sonoff will not know what time it is.
Again I assume the Sonoff has no inbuilt clock to hold the time once it gets its Time from the NTP.
If the wifi or internet is lost after Tasmota sync the time from internet, the timers will continue working. The ESP8266 will continue counting the time. It has the internal hardware to do that. The problem is that the Clock in the ESP8266 is not backed-up with a battery, so with a reset or a power loss, it will forget the time.
If Tasmota boots and can not reach a Time server, the timers will never trigger. Because, Tasmota don't know the time at startup.
If this is correct would it be possible to add a Real Time Clock board to the Sonoff as used in a Raspberry pi?
Raspberry Pi don't have a builtin Real Time Clock either. It has the same problem than the ESP8266. It can keep track of the time but it is not battery backed-up when losing power. You can add a RTC to a Raspberry as explained in this link
About the RTC on ESP8266 there is an article in this link that explains the ESP8266 precision for the Time.
An external RTC hardware for that purpose can be added to an ESP8266, but at this moment Tasmota does not support it. So, if there is no Wifi or Internet Connection when Tasmota starts, the timers and rules will not work.
Thanks for the information and clarificaton. With regards to my Raspberry Pi RTC, I was referring the an external RTC module that can be added to the Pi.
It would be interesting to see this implemented.
You could set up a NTP server on your Raspi, so the ESP would get it's time from there.
trogper .. That would be awesome if the SOnOff can read the NTP from my MQTT Server.
Do you perhaps have a link that I could use where set-up procedure is documented?
I have raspbian jessie on my raspberry, it has ntp server installed by default, so you probably only have to set the sonoff to use raspberry as the ntp source.
See Commands reference, look for ntpserver
[Feature] Support for RTC DS3231
In one of my future projects I would like to use an Tasmota flashed ESP8266 for switching some relays by the tasmota timer feature. Nothing special ... But in the productive environment the ESP8266 can't reach my wi-fi for syncing with a NTP after a power failure. The AP would be too far away. At this point my configured timers would be useless.
To keep the time "in sync" without an established network connection a DS3231 for example could be a cheap, stable and easy to integrate solution. In my mind a simple and rudimentary integration in Tasmota would be desirable:
If Tasmota has received the current time via NTP (in case of setting up Tasmota) and a DS3231 is configured, the current time is automatically stored in the DS3231.
As soon as Tasmota fails to synchronize time with an NTP after a power failure for example (at this point no access point is within range of the ESP8266), Tasmota gets the time from the DS3231 easily.
So, to get timers working after a power failure without tasmota is connected to a ntp (local or worldwide) a DS3231 (or any other rtc) extension for Tasmota would be very useful I think.
What do you think?
Hi,
I tested as @trogper has explained and works really good.
I type in the console:
ntpserver1 192.168.1.117
ntpserver2 192.168.1.117
ntpserver3 192.168.1.117
where 192.168.1.117 is the IP of my raspberry pi running Raspbian Stretch. After restarting Tasmota it takes the time from my raspberry. So, if my raspberry has a RTC DS3231 attached, on an internet disconnection, the timers from Tasmota will work.
I tried also a raspberry pi running Hassio but does not work. Hassio seems not to support NTP as RASPBIAN. EDIT: It works with an ADD-ON
@Kaimane your point is good, may be sometime in the future we will have an extension to add that, but remember that now Tasmota is mainly a firmware to add MQTT to sonoff devices for home automation, not a stand alone device.
@ascillato I haven't usede hassio yet, but I suppose you do have SSH access to it, so you could just install the NTP package. In debian it is called just ntp
I have just found (5 minutes ago) a NTP add on for hassio. I will test it and if it works I will post the link here.
I have tested the NTP server addon for hassio and works really good. Tasmota can retrieve the time correctly from there. I made also the request to be added in the community hassio addons.
Hi
I want to use Tasmota in a place without WIFI, but still enjoy the benefit of timers.
Is it possible to use external RTC like DS3231 ?
When WIFI is available then the switch will update the time/date in the external RTC , and when there is no WIFI, after reboot the switch use meanwhile the external RTC as time referance.
Also , the external RTC is more accurate then the internal RTC (can be 4 min drift in a day in the internal )
Currently, there is no driver added for any external RTC, but this is planned for future.
DS3231 is a good candidate.
Thanks for your answer.
Is there any document that explain the way to write driver ?
I will be happy to help with that.
You can take a peek at https://github.com/arendst/Sonoff-Tasmota/wiki/Sensor-API which provides the basic information. For the rest there's always the existing xsns_xx_xx.ino files that can be used as examples... there is also a Tasmota discord chat channel which is useful for development ideas also.
Added driver from @guyelg
Thanks.
Hello. I have read your conversations, I would like to know if today 29/06/19 the ds3231 can be connected directly to the sonoff. do we have new updates?
if there is still no update, tell me the best method to take time from rtc 3231.
I don't have an internet connection where sonoff esp8266 works, when the electric network is lost the timers don't work because the sonoff loses the time calculation.
can I please receive an answer? I need you
after this step what should I do on the sonoff?
From: Andre Thomas notifications@github.com
Sent: Monday, July 8, 2019 3:01:44 PM
To: arendst/Sonoff-Tasmota
Cc: matteo2019; Mention
Subject: Re: [arendst/Sonoff-Tasmota] Real Time Clock (#2871)
@matteo2019https://github.com/matteo2019 https://github.com/arendst/Sonoff-Tasmota/wiki/DS3231---External-RTC ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/arendst/Sonoff-Tasmota/issues/2871?email_source=notifications&email_token=AMIAS32L2AACRBCEBEWYYZLP6M3DRA5CNFSM4FCSCIXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZNAG3Q#issuecomment-509215598, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMIAS34S6HLMYHM6KOWZN3LP6M3DRANCNFSM4FCSCIXA.
I have to use the sonoff where there is no internet connection. It simply needs to work with time timers. When the mains power off the sonoff loses the time calculation, it does not remember the time. You need a Wemos d1 mini like you recommended. driving is clear but not complete. After installing tasmota on the wemos and connecting the RTC 3231 how should we proceed on the sonoff?
In theory...
This is rather off-label use though - having an RTC exclusively provide time where there is no internet connection so there are other risks involved such as the RTC losing some seconds over a long period and of course the fact that the coin cell will not last forever.
is there anyone so good and willing to do a guide or tutorial? many of us ask for it
however, we thank all those who are responding
someone very kind could make a scheme of how to connect the wemos to the sonoff and how to configure them?
You use Tasmota in a Wemos or in a Sonoff
You want to connect a RTC to Sonoff ? Do it on TX/RX , previously
configured as SDI, SCK.
El mié., 10 jul. 2019 a las 13:11, matteo2019 (notifications@github.com)
escribió:
someone very kind could make a scheme of how to connect the wemos to the
sonoff and how to configure them?—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/arendst/Sonoff-Tasmota/issues/2871?email_source=notifications&email_token=ACXBW4KIGKMZ3IU4GE5UOQ3P6YC2TA5CNFSM4FCSCIXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZT642I#issuecomment-510127721,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACXBW4NCYDR5GM2CDWJC7LLP6YC2TANCNFSM4FCSCIXA
.
please don't confuse my ideas. As explained above, I want the sonoff to calculate the time in the absence of the internet and I want it not to lose the time before the power failure. You advised me to flash the tasmota firmware on wemos D1 mini and connect the wemos to a 3231 rtc. I would like to know the next steps.
the other passages what are they?
I need to know specifically the steps to follow
@matteo2019
1- Compile your Tasmota firmware with DS3231 enabled
2- Flash the device you want with the Firmware you have compiled
3- configure the GPIOs as explained in the wiki
D2 GPIO04 : 06 I2C SDA
D1 GPIO05 : 05 I2C SCL
4- connect your DS3231 to those pins and also connect GND and VCC
5- power your device with internet connection
6- check the logs on the console (there will say if the time is saved inside your RTC)
7- power down and test it without internet connection. It should say in the console that it takes the time from the RTC.
@ascillato
Thank you Ascillato for your reply. Up to this point everything is clear. This you described is the configuration on the wemos d1 mini and the connection with the wemos to the rtc ds3231. the next step to connect the sonoff to the wemos what is it?
@ascillato
the sonoff (in my case sonoff dual r2 with tasmota) how should I connect it to the wemos? in wifi or with cables? can you describe the procedure in detail?
the next step to connect the sonoff to the wemos what is it?
why you want to connect a sonoff to a wemos?
You ask how to connect a RTC to a wemos, so for that wemos to have time and be used in a wifi network that does not have internet.
If you want a sonoff basic to have the time, just connect the RTC to that sonoff. You don't need a separated wemos for that.
@ascillato
because the sonoff must take the time from the wemos to a sudden restart. when there is no electricity supply
If you want a sonoff basic to have the time, just connect the RTC to that sonoff. You don't need a separated wemos for that.
it is a sonoff basic right?
I repeat that my sonoff lives in a place with no internet. Often there are losses of electrical network and its memory loses the time. You advised me to configure a wemos D1 mini connected to a rtc ds3231. After these steps how should I configure the sonoff? the sonoff I think must be connected to the wemos.
sonoff dual r2 flash tasmota stefanbode
You don't need a wemos. just connect your RTC to your sonoff dual. just that.
@ascillato
really??? you are the first to tell me this thing. You're telling me that I rtc ds3231 can connect it directly to sonoff dual r2
yes, why not? it has free gpios to connect to.
As we are spamming this old issue I recommend you to address this to the Tasmota Support Chat.
where do I connect ds3231 to sonoff? the pin buttons 1 and the pin button 2 on the board I use them to connect 2 physical buttons to lower and raise the motor
Do it on TX/RX , previously configured as SDI, SCK
Most helpful comment
Hi,
Yes
If the wifi or internet is lost after Tasmota sync the time from internet, the timers will continue working. The ESP8266 will continue counting the time. It has the internal hardware to do that. The problem is that the Clock in the ESP8266 is not backed-up with a battery, so with a reset or a power loss, it will forget the time.
If Tasmota boots and can not reach a Time server, the timers will never trigger. Because, Tasmota don't know the time at startup.
Raspberry Pi don't have a builtin Real Time Clock either. It has the same problem than the ESP8266. It can keep track of the time but it is not battery backed-up when losing power. You can add a RTC to a Raspberry as explained in this link
About the RTC on ESP8266 there is an article in this link that explains the ESP8266 precision for the Time.
An external RTC hardware for that purpose can be added to an ESP8266, but at this moment Tasmota does not support it. So, if there is no Wifi or Internet Connection when Tasmota starts, the timers and rules will not work.