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.

Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Sat Apr 01, 2017 5:36 pm

I was trying Tony's example on screen. All is OK up to the moment when I import some files, I don't know where are them and where am I supposed to have them to work. I've successfully installed the 'Adafruit CircuitPython 0.9.3-dirty on 2017-03-27; Adafruit Feather M0 Adalogger with samd21g18' but when I try to import machine or os or ds3231 and sd It doesn't find. It imports well uos, time, nativeio and some others.

My purpose is to log when a contact closes or opens in a 4G card. In the card I have plenty of space so I could put tons of libraries, it seems to be easy on Circuit python to access and mount /SD. The contact is on A0 and I have light intensity on A1. As the contact opens or closes I'd open a text file, and record event number, closed or opened, light intensity, exact time change line and close file, waiting another event. That's all.

I'd like to know why it doesn't import those essential files in my case, ds3231 and SD. If you can help me with some python code I'd be very grateful. I could send you photos of the final project for the learn section.

Thanks,

Fabio

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

Re: Adalogger M0 with DS3231 +SD Wing

by tannewt on Sat Apr 01, 2017 5:53 pm

Hi Fabio, that sounds like an awesome project. Unfortunately, CircuitPython does not support mounting SD cards yet. I've begun the work but haven't finished it. I hope to have it done in the next month or two. The work is stalled waiting for some upstream improvements (mounting multiple filesystems) to be released.

machine and os are not available on CircuitPython either. machine is replaced by nativeio and os is called uos because it has non-standard methods. This driver should work for the ds3231: https://github.com/adafruit/Adafruit_Ci ... hon_DS3231 The one that imports machine is for MicroPython instead.

Sorry its not ready yet!

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

Re: Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Sat Apr 01, 2017 6:17 pm

Hi,

Thanks for your fast answer. I don'd care about waiting a month or two. I have something similar already working with arduino ide. But I'd prefer having it on Circuit Python, because the files will have properties with good time and date. You know in arduino my file must be created before on a computer to have all the good information and not the 1991 file.

I was telling machine because this is the example Tony gave on his tutorial and it was the Adalogger he was using. If you say it doesn't work it's OK for me. It's good to know from you directly this way I will stop trying things.

Congratulations for your good work. I'm waiting for the SD improvement and following your project with interest.

Fabio.

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

Re: Adalogger M0 with DS3231 +SD Wing

by tannewt on Sun Apr 02, 2017 3:55 am

Thanks for being understanding! It is definitely on my list of things to support. I'm glad you have it working in Arduino.

Yeah, some of Tony's tutorials were with earlier version of MicroPython for the SAMD. Since then we decided to switch to nativeio because its identical across ports. machine can vary some which makes writing drivers more difficult.

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

Re: Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Mon Aug 21, 2017 6:25 pm

Could you please give us some explanations on how to use the last version of Circuit Python, a M0 adalogger and a DS3231 wing to put files attributes ? How to put the libraries and bundle on the SD card ? Just some examples to start with,

Thanks.

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

Re: Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Mon Sep 04, 2017 11:47 am

I was trying the last version of Circuit Python 2.0.0-rc.1 to see if I can use my SD Card and it doesn't work very well for me.

perhaps I'm not putting the files in the good order on CIRCUITPY file. This is what happens when I try the API example:


>>> import os
>>> os.listdir()
['boot_out.txt', '.Trash-1000', 'adafruit_sdcard.mpy', 'spi_device.mpy', 'lib']

>>> import adafruit_sdcard
>>> import busio
>>> import digitalio
>>> import board
>>> import storage
>>> spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
>>> cs = digitalio.DigitalInOut(board.SD_CS)
>>> sdcard = adafruit_sdcard.SDCard(spi, cs)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "libraries/drivers/sdcard/adafruit_sdcard.py", line 84, in __init__
File "libraries/drivers/sdcard/adafruit_sdcard.py", line 117, in _init_card
File "libraries/drivers/sdcard/adafruit_sdcard.py", line 172, in _init_card_v2
OSError: timeout waiting for v2 card
>>>


Thanks for your help.

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

Re: Adalogger M0 with DS3231 +SD Wing

by tannewt on Mon Sep 04, 2017 12:50 pm

What brand and size of micro SD card are you using? The code looks ok to me.

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

Re: Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Mon Sep 04, 2017 12:56 pm

It's a 4GB Lexar and it was working in arduino code. The library files are well placed ? Where can I have a DS3231 library ?

Thanks for your fast answer.
Last edited by fabitencourt on Mon Sep 04, 2017 1:14 pm, edited 1 time in total.

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

Re: Adalogger M0 with DS3231 +SD Wing

by tannewt on Mon Sep 04, 2017 1:07 pm

Could you post a picture or an Amazon link? I don't have any Lexar cards here to test with.

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

Re: Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Mon Sep 04, 2017 1:24 pm

This is the micro SD card...
Attachments
CarteSDM0addalogger.jpg
CarteSDM0addalogger.jpg (69.62 KiB) Viewed 526 times
Last edited by fabitencourt on Mon Sep 04, 2017 2:09 pm, edited 1 time in total.

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

Re: Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Mon Sep 04, 2017 1:46 pm

I've just started it all again from ground up to be sure it was still the same... same results...



Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.



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

Adafruit CircuitPython 2.0.0-rc.1 on 2017-09-01; Adafruit Feather M0 Adalogger with samd21g18
>>> import os
>>> os.listdir()
['boot_out.txt', 'adafruit_sdcard.mpy', 'adafruit_bus_device', 'spi_device.mpy', 'i2c_device.mpy']
>>> import adafruit_sdcard
>>> import busio
>>> import digitalio
>>> import board
>>> import storage
>>> spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
>>> cs = digitalio.DigitalInOut(board.SD_CS)
>>> sdcard = adafruit_sdcard.SDCard(spi, cs)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "libraries/drivers/sdcard/adafruit_sdcard.py", line 84, in __init__
File "libraries/drivers/sdcard/adafruit_sdcard.py", line 117, in _init_card
File "libraries/drivers/sdcard/adafruit_sdcard.py", line 172, in _init_card_v2
OSError: timeout waiting for v2 card
>>>

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

Re: Adalogger M0 with DS3231 +SD Wing

by tannewt on Mon Sep 04, 2017 2:25 pm

Ok, I ordered a couple class 2 cards for me to test with.

Do you have any other cards you can try?

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

Re: Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Mon Sep 04, 2017 2:31 pm

If you think this is the problem, I'll find another one...

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

Re: Adalogger M0 with DS3231 +SD Wing

by fabitencourt on Mon Sep 04, 2017 2:50 pm

This time it went further with a brand new 16GB lexar . Those two cards did the same problems.



>>>
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.



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

Adafruit CircuitPython 2.0.0-rc.1 on 2017-09-01; Adafruit Feather M0 Adalogger with samd21g18
>>> import os
>>> import adafruit_sdcard
>>> import busio
>>> import digitalio
>>> import board
>>> import storage
>>> os.listdir()
['boot_out.txt', 'adafruit_sdcard.mpy', 'adafruit_bus_device', 'spi_device.mpy', 'i2c_device.mpy']
>>> spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
>>> cs = digitalio.DigitalInOut(board.SD_CS)
>>> sdcard = adafruit_sdcard.SDCard(spi, cs)
>>> vfs = storage.VfsFat(sdcard)
>>> storage.mount(vfs, "/sd")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: 19
>>> with open("/sd/test.txt", "w") as f:
... f.write("Hello world\n")
...
...
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: 30
>>>
Attachments
2017-09-04-145149.jpg
2017-09-04-145149.jpg (267.94 KiB) Viewed 498 times
2017-09-04-151433.jpg
2017-09-04-151433.jpg (206.58 KiB) Viewed 498 times

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

Re: Adalogger M0 with DS3231 +SD Wing

by tannewt on Wed Sep 06, 2017 7:31 pm

I've opened an issue for it here so I don't lose track of it: https://github.com/adafruit/circuitpython/issues/245

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

Please be positive and constructive with your questions and comments.