TinyRTC I2C Module DS1307 + AT24C32N
TinyRTC I2C Module DS1307 + AT24C32N
I created a driver for the TinyRTC I2C module. Features a DS1307 RTC IC + AT24C32N 32K EEPROM and headers for optional DS18B20.
https://github.com/mcauser/micropython-tinyrtc-i2c
It was only after I finished that I realised my STM32F407VET6 Mini actually has built-in hardware RTC and all I needed to do was attach a coin cell between GND + VBAT. Ah well, at least I learned all about RTCs and EEPROMs. You might find this driver useful for boards without a built-in RTC.
https://github.com/mcauser/micropython-tinyrtc-i2c
It was only after I finished that I realised my STM32F407VET6 Mini actually has built-in hardware RTC and all I needed to do was attach a coin cell between GND + VBAT. Ah well, at least I learned all about RTCs and EEPROMs. You might find this driver useful for boards without a built-in RTC.
Re: TinyRTC I2C Module DS1307 + AT24C32N
Hi,
thank you for the drivers.
DS1307 works like a charm.
The AT24C32N however doesn't do what it's supposed to do:
On my TTGO ESP32 boards (latest loboris port)
when i enter this:
i get this:
I'm fairly new to Python, so i don't know what to look for.
Maybe someone wiser than me can chime in and show what i'm doing wrong here.
Thank you very much in advance.
Blechi
thank you for the drivers.
DS1307 works like a charm.
The AT24C32N however doesn't do what it's supposed to do:
On my TTGO ESP32 boards (latest loboris port)
when i enter this:
Code: Select all
import machine
i2c = machine.I2C(scl=machine.Pin(22), sda=machine.Pin(21))
print('i2c scan:',i2c.scan())
import at24c32n
eeprom = at24c32n.AT24C32N(i2c)
# read 32 bytes starting from memory address 0
eeprom.read(0, 32)
Code: Select all
i2c scan: [80, 104, 118]
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
File "at24c32n.py", line 42, in read
TypeError: extra keyword arguments given
Maybe someone wiser than me can chime in and show what i'm doing wrong here.
Thank you very much in advance.
Blechi
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: TinyRTC I2C Module DS1307 + AT24C32N
Looking at the GitHub code for the AT24C32N driver the line number in your traceback looks wrong. I strongly suspect you have not got the latest version of the driver. I suggest you update and try again.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: TinyRTC I2C Module DS1307 + AT24C32N
Thank you for the reply.
Notepad++ had eaten the 4 empty lines in the license terms.
After having fixed that by downloading the latest version from
https://github.com/mcauser/micropython-tinyrtc-i2c
the result is:
when running this:
Notepad++ had eaten the 4 empty lines in the license terms.
After having fixed that by downloading the latest version from
https://github.com/mcauser/micropython-tinyrtc-i2c
the result is:
Code: Select all
i2c scan: [80, 104, 118]
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
File "at24c32n.py", line 46, in read
TypeError: extra keyword arguments given
Code: Select all
import machine
i2c = machine.I2C(scl=machine.Pin(22), sda=machine.Pin(21))
print('i2c scan:',i2c.scan())
import at24c32n
eeprom = at24c32n.AT24C32N(i2c)
# read 32 bytes starting from memory address 0
eeprom.read(0, 32)
Re: TinyRTC I2C Module DS1307 + AT24C32N
Does the loboris port support readfrom_mem() with addrsize=16?
Re: TinyRTC I2C Module DS1307 + AT24C32N
That was the right hint.
In the Loboris port the read and write functions require adrlen = 2 instead of addrsize = 16 .
After changing that everything works fine.
Thank you all for your help.
In the Loboris port the read and write functions require adrlen = 2 instead of addrsize = 16 .
After changing that everything works fine.
Thank you all for your help.
- philwilkinson40
- Posts: 63
- Joined: Tue Nov 14, 2017 3:11 am
- Location: Perth, Australia
Re: TinyRTC I2C Module DS1307 + AT24C32N
sorry to add to an old thread, but it seems relevant.
I am using a clone TinyDS1307 with a WEMOS D1 mini Pro ESP8266.
All works well but the RTC time does not survive a power reset.
setting ds.halt(False) has the same outcome. I have tried the same code with the uRTC driver too with the same result. Am I doing this all wrong?
initially
then after a power reset exactly the same occurs.
I am using a clone TinyDS1307 with a WEMOS D1 mini Pro ESP8266.
All works well but the RTC time does not survive a power reset.
setting ds.halt(False) has the same outcome. I have tried the same code with the uRTC driver too with the same result. Am I doing this all wrong?
Code: Select all
import ds1307
import ntptime
from machine import I2C, Pin
i2c = I2C(scl=Pin(5), sda=Pin(4))
ds = ds1307.DS1307(i2c)
print('initial datetime on ds1307 is...', ds.datetime())
#set the time by ntptime
print('ntp time is set at')
ntptime.settime()
f=utime.localtime()
g=f[0],f[1],f[2],f[6],(f[3]+8),f[4],f[5]
#ds.halt(False)
ds.datetime(g)
print('new datetime on ds1307 is...', ds.datetime())
utime.sleep(5)
print('5secs later is...', ds.datetime())
Code: Select all
initial datetime on ds1307 is... (2000, 1, 1, 0, 0, 0, 0, 0)
ntp time is set at
(2018, 10, 11, 10, 58, 26, 3, 284)
new datetime on ds1307 is... (2018, 10, 11, 3, 18, 58, 26, 0)
5secs later is... (2018, 10, 11, 3, 18, 58, 31, 0)
Re: TinyRTC I2C Module DS1307 + AT24C32N
What’s the voltage on your coin cell?
- philwilkinson40
- Posts: 63
- Joined: Tue Nov 14, 2017 3:11 am
- Location: Perth, Australia
Re: TinyRTC I2C Module DS1307 + AT24C32N
it was 2.85V, so I put in a brand new CR1220 which read over 3V. Unfortunately this has the same result.
I repeated this on a second tiny RTC clone with the same outcome.
Phil
I repeated this on a second tiny RTC clone with the same outcome.
Phil
Re: TinyRTC I2C Module DS1307 + AT24C32N
Is it the same RTC module as in the photo above?
I’ll give it a try with my D1 mini pro tonight.
I’ll give it a try with my D1 mini pro tonight.