Last active
April 6, 2018 03:27
-
-
Save waldo323/a5763841edb6119b3effa34d37558734 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import board | |
import busio | |
import adafruit_pcf8523 | |
import time | |
import digitalio | |
import adafruit_sdcard | |
import storage | |
myI2C = busio.I2C(board.SCL, board.SDA) | |
rtc = adafruit_pcf8523.PCF8523(myI2C) | |
days = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") | |
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) | |
# Use board.SD_CS for Feather M0 Adalogger | |
cs = digitalio.DigitalInOut(board.D10) | |
# Or use a GPIO pin like 15 for ESP8266 wiring: | |
#cs = digitalio.DigitalInOut(board.GPIO15) | |
sdcard = adafruit_sdcard.SDCard(spi, cs) | |
vfs = storage.VfsFat(sdcard) | |
storage.mount(vfs, "/sd") | |
with open("/sd/test.txt", "w") as f: | |
f.write("Hello world!\r\n") | |
t = rtc.datetime | |
#print(t) # uncomment for debugging | |
f.write("The date is %s %d/%d/%d\r\n" % (days[t.tm_wday], t.tm_mday, t.tm_mon, t.tm_year)) | |
f.write("The time is %d:%02d:%02d\r\n" % (t.tm_hour, t.tm_min, t.tm_sec)) | |
# time.sleep(1) # wait a second |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment