We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm trying to resolve a discrepancy of approximately -3 minutes in the reported time and the actual time.
MicroPython v1.20.0 on 2023-04-26; ESP module with ESP8266
ESP8266 D1 Mini V2 ESP-12F WiFi Module
gmtime() (2023, 11, 21, 21, 10, 11, 1, 325)
PS C:\Users\Cash> get-date
Tuesday, November 21, 2023 9:13:45 PM
both timestamps were done with in a matter of seconds manually.
from ds1307 import DS1307 from machine import I2C, Pin from time import gmtime, time
I2C_ADDR = 0x68 # DEC 104, HEX 0x68
i2c = I2C(scl=Pin(5), sda=Pin(4), freq=400000) ds1307 = DS1307(addr=I2C_ADDR, i2c=i2c)
print("Current RTC time: {}".format(ds1307.datetime))
now = gmtime(time()) ds1307.datetime = now
print("Today is {:04d}-{:02d}-{:02d}T{:02d}:{:02d}:{:02d}".format( ds1307.year, ds1307.month, ds1307.day, ds1307.hour, ds1307.minute, ds1307.second))
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I'm trying to resolve a discrepancy of approximately -3 minutes in the reported time and the actual time.
MicroPython v1.20.0 on 2023-04-26; ESP module with ESP8266
ESP8266 D1 Mini V2 ESP-12F WiFi Module
PS C:\Users\Cash> get-date
Tuesday, November 21, 2023 9:13:45 PM
both timestamps were done with in a matter of seconds manually.
brainelectronics/micropython-ds1307
from ds1307 import DS1307
from machine import I2C, Pin
from time import gmtime, time
DS1307 on 0x68
I2C_ADDR = 0x68 # DEC 104, HEX 0x68
define custom I2C interface, default is 'I2C(0)'
check the docs of your device for further details and pin infos
this are the pins for the Lolin D1 mini board
the first parameter below was 0 which created an error on the ESP8266
the freq parameter below was changed from 800000 to 400000 for the ESP8266
i2c = I2C(scl=Pin(5), sda=Pin(4), freq=400000)
ds1307 = DS1307(addr=I2C_ADDR, i2c=i2c)
get the current RTC time
print("Current RTC time: {}".format(ds1307.datetime))
set the RTC time to the current system time
now = gmtime(time())
ds1307.datetime = now
print("Current RTC time: {}".format(ds1307.datetime))
Print the date and time in ISO8601 format: 2023-04-18T21:14:22
print("Today is {:04d}-{:02d}-{:02d}T{:02d}:{:02d}:{:02d}".format(
ds1307.year, ds1307.month, ds1307.day,
ds1307.hour, ds1307.minute, ds1307.second))
The text was updated successfully, but these errors were encountered: