Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Adalogger M0 with DS3231 +SD Wing
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Adalogger M0 with DS3231 +SD Wing

by tannewt on Wed Sep 13, 2017 12:57 pm

What do you mean by the connections are standard? Does it work if you remove all of the wires on the bottom left of the picture and only leave the battery connected and the stacked feathers?

tannewt
 
Posts: 1845
Joined: Thu Oct 06, 2016 8:48 pm

Re: Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Wed Sep 13, 2017 3:51 pm

Exactly. The wires are there only to connect the battery, and two inputs A0 and A1. I mean by standard the connections between the M0 adalogger and the DS3231. Those connections are straight forward as conception.

fabitencourt
 
Posts: 28
Joined: Fri Jul 12, 2013 8:10 pm

Re: Adalogger M0 with DS3231 +SD Wing

by tannewt on Wed Sep 13, 2017 4:00 pm

Could you give it a try when its not on the bread board?

tannewt
 
Posts: 1845
Joined: Thu Oct 06, 2016 8:48 pm

Re: Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Wed Sep 13, 2017 4:08 pm

OK, I will. But as it is right now I can use the SD card and save time parameters as a logger with a arduino sketch.
It will be done by tomorrow morning because I am at my job now and I don't have my M0adalogger.

Thanks for putting my name as a contributor with your last version. I'm flattered.
I'm glad to be useful for the project.

fabitencourt
 
Posts: 28
Joined: Fri Jul 12, 2013 8:10 pm

Re: Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Thu Sep 14, 2017 11:08 am

OK, I just did it and it did exactly the same thing using the very last bundle.
Now it was only the two board one on top of the other, without battery.




Press any key to enter the REPL. Use CTRL-D to reload.

Adafruit CircuitPython 2.0.0 on 2017-09-12; Adafruit Feather M0 Adalogger with samd21g18
>>> import os
>>> os.listdir()
['boot_out.txt', 'lib', '.Trash-1000']
>>> import board
>>> import busio
>>> import adafruit_ds3231
>>> i = busio.I2C(board.SCL, board.SDA)
>>> t = adafruit_ds3231.DS3231(i)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "libraries/drivers/ds3231/adafruit_ds3231.py", line 99, in __init__
ValueError: Unable to find DS3231 at i2c address 0x68.
>>>

fabitencourt
 
Posts: 28
Joined: Fri Jul 12, 2013 8:10 pm

Re: Adalogger M0 with DS3231 +SD Wing

by tannewt on Thu Sep 14, 2017 12:39 pm

Would you mind editing the library for the DS3231? It looks like its trying to verify the chip identity via some bits that *shouldn't* change but may have. Can you print buf[1] here: https://github.com/adafruit/Adafruit_Ci ... 231.py#L98

tannewt
 
Posts: 1845
Joined: Thu Oct 06, 2016 8:48 pm

Re: Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Thu Sep 14, 2017 8:36 pm

I'm not sure to understand why this byte is 0x18 (0b00011000) in stead of 0x68(0b01101000) ? In the maxxim datasheet when it talks about 12c communication it is always starting with a 0x68 (0b01101000) byte. Is it what's being tested here ?

fabitencourt
 
Posts: 28
Joined: Fri Jul 12, 2013 8:10 pm

Re: Adalogger M0 with DS3231 +SD Wing

by tannewt on Thu Sep 14, 2017 9:20 pm

Not quite, its checking the 0Eh register's RS1 and RS2 bits which control the frequency of the alarm signal output. Since we don't allow it to be changed through the driver and they start at 1 at powerup I'm trying to use it as a proxy for verifying the device. What is the current value for your 0Eh register? Maybe Arduino or some other code changed those bits.

tannewt
 
Posts: 1845
Joined: Thu Oct 06, 2016 8:48 pm

Re: Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Fri Sep 15, 2017 11:32 am

OK Scott, I've took out the battery for DS3231 and that error didn't appear anymore. In fact the commands that will follow are there to adjust time on that module and it need to know if it was already adjusted, in that case those bits would be changed. And my DS3231 already had the time OK. Here is what the datasheet says about RS1 and RS2 bits:

"These bits are both set to logic 1
(8.192kHz) when power is first applied."

fabitencourt
 
Posts: 28
Joined: Fri Jul 12, 2013 8:10 pm

Re: Adalogger M0 with DS3231 +SD Wing

by tannewt on Fri Sep 15, 2017 12:32 pm

What code had you used with it before? I should check other libraries to see if they can change it.

tannewt
 
Posts: 1845
Joined: Thu Oct 06, 2016 8:48 pm

Re: Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Fri Sep 15, 2017 12:48 pm

Now it goes like this:

Press any key to enter the REPL. Use CTRL-D to reload.

Adafruit CircuitPython 2.0.0 on 2017-09-12; Adafruit Feather M0 Adalogger with samd21g18
>>> import adafruit_ds3231
>>> import board
>>> import busio
>>> i = busio.I2C(board.SCL, board.SDA)
>>> t = adafruit_ds3231.DS3231(i)
>>> t.datetime(tm_year=2017, tm_mon=9, tm_mday=15, tm_hour=12, tm_min=42, tm_sec=00, tm_wday=4, tm_yday=-1, tm_isdst=-1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'struct_time' object is not callable
>>>

fabitencourt
 
Posts: 28
Joined: Fri Jul 12, 2013 8:10 pm

Re: Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Fri Sep 15, 2017 1:22 pm

Things are working OK now:

Press any key to enter the REPL. Use CTRL-D to reload.

Adafruit CircuitPython 2.0.0 on 2017-09-12; Adafruit Feather M0 Adalogger with samd21g18
>>> import busio
>>> import adafruit_ds3231
>>> import time
>>> from board import *
>>> myI2C = busio.I2C(SCL, SDA)
>>> rtc = adafruit_ds3231.DS3231(myI2C)
>>> t = rtc.datetime
>>> print(t)
struct_time(tm_year=2017, tm_mon=9, tm_mday=15, tm_hour=13, tm_min=12, tm_sec=50, tm_wday=4, tm_yday=-1, tm_isdst=-1)
>>> print(t)
struct_time(tm_year=2017, tm_mon=9, tm_mday=15, tm_hour=13, tm_min=12, tm_sec=50, tm_wday=4, tm_yday=-1, tm_isdst=-1)
>>> t = rtc.datetime
>>> print(t)
struct_time(tm_year=2017, tm_mon=9, tm_mday=15, tm_hour=13, tm_min=13, tm_sec=55, tm_wday=4, tm_yday=-1, tm_isdst=-1)
>>> t = rtc.datetime
>>> print(t)
struct_time(tm_year=2017, tm_mon=9, tm_mday=15, tm_hour=13, tm_min=14, tm_sec=40, tm_wday=4, tm_yday=-1, tm_isdst=-1)
>>>


Where can I have info about the last three, tm_wday, tm_yday and tm_isdst ? I don't know how to set them...

Next step, log in a file data change with time event info. Getting there...

fabitencourt
 
Posts: 28
Joined: Fri Jul 12, 2013 8:10 pm

Re: Adalogger M0 with DS3231 +SD Wing

by tannewt on Fri Sep 15, 2017 6:44 pm

datetime is a property of the DS3231 object. To set it do something like:

Code: Select all | TOGGLE FULL SIZE
t.datetime = time.struct(tm_year=2017, tm_mon=9, tm_mday=15, tm_hour=13, tm_min=12, tm_sec=50, tm_wday=4, tm_yday=-1, tm_isdst=-1)

tannewt
 
Posts: 1845
Joined: Thu Oct 06, 2016 8:48 pm

Re: Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Fri Sep 15, 2017 7:24 pm

How is the best way to make a string of my time from DS3231 and put it in a file on my SD card, Scott ? I've tried some alternatives without success. Thanks.

fabitencourt
 
Posts: 28
Joined: Fri Jul 12, 2013 8:10 pm

Re: Adalogger M0 with DS3231 +SD Wing

by tannewt on Fri Sep 15, 2017 7:58 pm

I don't think we've implemented any of the pythonic ways of doing it yet. You'll have to read each component of the struct_time yourself and use string formatting.

tannewt
 
Posts: 1845
Joined: Thu Oct 06, 2016 8:48 pm

Please be positive and constructive with your questions and comments.