[SOLVED] DS3231 uRTC set / read problems
Re: [SOLVED] DS3231 uRTC set / read problems
No offense, I just don't think we should start chasing away people who come here for help as soon as they mention the name "CircuitPython" or "WiPy". Sure, if the problem seems to be specific to the platform, stemming from a design decision or a bug specifically in that fork, we might be unable to help and will do better by pointing the user to a better source of help. But in cases like this, where the bug is most likely in a library I wrote, and would affect MicroPython and CircuitPython users equally, I think it's good to have it here -- in case others stumble upon a similar problem.
And if you are serious about waging a petty war with all the forks, may I just point out that a much better strategy to alienating the users of those forks would be an attempt to convert them to our side -- seeing much better support and friendlier community in MicroPython, they might decide to switch. Just saying.
And if you are serious about waging a petty war with all the forks, may I just point out that a much better strategy to alienating the users of those forks would be an attempt to convert them to our side -- seeing much better support and friendlier community in MicroPython, they might decide to switch. Just saying.
Re: [SOLVED] DS3231 uRTC set / read problems
Hi every one,
I'm not sure I have to post here or create a new thread :
I'm able to use deshipu's urtc.py (the one mentioned at the beginning of this thread) with DS3231 to set/read time.
But i'm not able to use it to set/read alarm, is it a known issue ?
I set the alarm with :
When I check the alarm previously set with :
every parameters of the returned Tuple is set to 0 (year, month, week, weekday, hour, minute...)
Obviously, when I read the alarm flag with :
All I get is "False", even after 9:15.
Do you think it's a problem with firmware 1.8.7 and i2c ? (none of the command above raises an error)
I'm not sure I have to post here or create a new thread :
I'm able to use deshipu's urtc.py (the one mentioned at the beginning of this thread) with DS3231 to set/read time.
But i'm not able to use it to set/read alarm, is it a known issue ?
I set the alarm with :
Code: Select all
rtc.alarm_time((2017,2,14,1,9,15))
#Set alarm to 9:15, 14/2/2017
Code: Select all
rtc.alarm_time()
#Read previously set alarm
Obviously, when I read the alarm flag with :
Code: Select all
rtc.alarm()
#Check alarm
Do you think it's a problem with firmware 1.8.7 and i2c ? (none of the command above raises an error)
Re: [SOLVED] DS3231 uRTC set / read problems
Looking at the code for that alarm_time() function, I wonder how it ever worked. It certainly doesn't work on the recent releases of MicroPython. I will need to rework that part. I'm sorry about that.
Re: [SOLVED] DS3231 uRTC set / read problems
Ok thanks for the answer.
You don't have to be sorry.
You're doing a great job for the community.
You don't have to be sorry.
You're doing a great job for the community.
Re: [SOLVED] DS3231 uRTC set / read problems
I have pushed a fix to https://github.com/adafruit/Adafruit-uRTC -- please test.
Re: [SOLVED] DS3231 uRTC set / read problems
Well well, I feel stupid but i don't understand how to use it.
I set the alarm with
But I can't check if it's well set, as rtc.alarm_time() return nothing , and now,
Is always set to... True. I try to set it back to False with :
But it fails.
I set the alarm with
Code: Select all
>>> rtc.alarm_time((2017,2,15,None,21,50,0))
Code: Select all
rtc.alarm()
Code: Select all
rtc.alarm(False)
Re: [SOLVED] DS3231 uRTC set / read problems
Can you be a little more precise? What does it mean "returns nothing" and "fails"? What does it return exactly, and how it fails? Is there an exception thrown?
This is how this works for me:
(I had the alarm set from previous experiments.)
This is how this works for me:
Code: Select all
>>> from machine import I2C, Pin
>>> i2c = I2C(scl=Pin(5), sda=Pin(4))
>>> import urtc
>>> rtc = urtc.DS3231(i2c)
>>> rtc.alarm_time((2017,2,15,None,21,50,0))
>>> rtc.alarm_time()
DateTimeTuple(year=None, month=None, day=15, weekday=None, hour=21, minute=50, second=0, millisecond=None)
>>> rtc.alarm()
True
>>> rtc.alarm(0)
>>> rtc.alarm()
False
Re: [SOLVED] DS3231 uRTC set / read problems
Hi,
Here is my output :
Here is my output :
Code: Select all
>>> from machine import I2C, Pin
>>> i2c = I2C(scl=Pin(5), sda=Pin(4))
>>> import urtc
>>> rtc = urtc.DS3231(i2c)
>>> rtc.alarm_time((2017,2,15,None,21,50,0))
>>> rtc.alarm_time()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "urtc.py", line 138, in alarm_time
IndexError: bytes index out of range
Re: [SOLVED] DS3231 uRTC set / read problems
Thank you! That was my mistake, I didn't correct for a shorter buffer in all the places that I should. I pushed the fix.
Re: [SOLVED] DS3231 uRTC set / read problems
Thank You Deshipu, we are progressing but it's still not effective, let me show you :
Here is the output :
As you can see, the alarm is not triggered at 19h35.
Code: Select all
>>> rtc.alarm_time((2017,2,17,None,19,35,0))
>>> rtc.alarm_time()
DateTimeTuple(year=None, month=None, day=17, weekday=None, hour=19, minute=35, second=0, millisecond=None)
>>> while True: #Start a test to visualise the alarm
... rtc.datetime()
... rtc.alarm()
... time.sleep(0.5)
...
Code: Select all
DateTimeTuple(year=2017, month=2, day=17, weekday=4, hour=19, minute=34, second=59, millisecond=None)
False
DateTimeTuple(year=2017, month=2, day=17, weekday=4, hour=19, minute=34, second=59, millisecond=None)
False
DateTimeTuple(year=2017, month=2, day=17, weekday=4, hour=19, minute=35, second=0, millisecond=None)
False
DateTimeTuple(year=2017, month=2, day=17, weekday=4, hour=19, minute=35, second=0, millisecond=None)
False
DateTimeTuple(year=2017, month=2, day=17, weekday=4, hour=19, minute=35, second=1, millisecond=None)
False
DateTimeTuple(year=2017, month=2, day=17, weekday=4, hour=19, minute=35, second=1, millisecond=None)
False