Exemple #1
0
def foo():
    tf = '{3:02}:{4:02}:{5:02}'
    ds3231 = adafruit_ds3231.DS3231(busio.I2C(board.SCL, board.SDA))
    while True:
        print(gc.mem_free())
        with neopixel.NeoPixel(board.D1,
                               224,
                               bpp=3,
                               brightness=0.1,
                               auto_write=False) as p:
            print(gc.mem_free())
            p.fill((
                0,
                0,
                0,
            ))
            offset = 0
            for digit in tf.format(*ds3231.datetime):
                for i, j in enumerate(font[fontmap.index(digit)]):
                    p[i + offset] = j * 0x3333ff
                offset += len(font[fontmap.index(digit)])
            print(gc.mem_free())
            p.show()
            print(gc.mem_free())
        time.sleep(1)
Exemple #2
0
def main():
    i2c = busio.I2C(3, 2)
    rtc = adafruit_ds3231.DS3231(i2c)

    rtc.datetime = time.struct_time((2017, 1, 20, 15, 6, 0, 0, 20, 0))

    print_rtc_time(rtc)
import time
import board
# For hardware I2C (M0 boards) use this line:
import busio as io
# Or for software I2C (ESP8266) use this line instead:
#import bitbangio as io

import adafruit_ds3231

i2c = io.I2C(board.SCL,
             board.SDA)  # Change to the appropriate I2C clock & data
# pins here!

# Create the RTC instance:
rtc = adafruit_ds3231.DS3231(i2c)

# Lookup table for names of days (nicer printing).
days = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
        "Saturday")

#pylint: disable-msg=bad-whitespace
#pylint: disable-msg=using-constant-test
if False:  # change to True if you want to set the time!
    #                     year, mon, date, hour, min, sec, wday, yday, isdst
    t = time.struct_time((2017, 10, 29, 15, 14, 15, 0, -1, -1))
    # you must set year, mon, date, hour, min, sec and weekday
    # yearday is not supported, isdst can be set but we don't do anything with it at this time
    print("Setting time to:", t)  # uncomment for debugging
    rtc.datetime = t
    print()
Exemple #4
0
import time
import displayio
import terminalio
import digitalio
import canio
from adafruit_display_text import label
from adafruit_bitmap_font import bitmap_font
import adafruit_ili9341
import adafruit_stmpe610
import adafruit_ds3231
import adafruit_sdcard
import storage

# RTC communication
myI2C = busio.I2C(board.SCL, board.SDA)
rtc = adafruit_ds3231.DS3231(myI2C)

if False:  # change to True if you want to write the time!
    #                     year, mon, date, hour, min, sec, wday, yday, isdst
    t = time.struct_time((2021, 03, 16, 10, 30, 00, 0, -1, -1))
    # you must set year, mon, date, hour, min, sec and weekday
    # yearday is not supported, isdst can be set but we don't do anything with it at this time

    print("Setting time to:", t)  # uncomment for debugging
    rtc.datetime = t
    print()

# SPI communication pins
spi = board.SPI()

# SD card
Exemple #5
0
 def __init__(self):
     i2c = busio.I2C(board.SCL, board.SDA)
     self.ds3231 = adafruit_ds3231.DS3231(i2c)
#-----------------------------------------------------------------------------------------------------
#Program will simply display RTC Temperature and initialize RTC time to zero.
#-----------------------------------------------------------------------------------------------------
#Acceleration/Gyro Sensor : adafruit LSM6DSOX
#RTC Module : adafruit DS3231
#-----------------------------------------------------------------------------------------------------
#Coded by : Nicholas P. Shay, Mechanical Engineering 2022, [email protected]
#Date : 12/5/2020
#-----------------------------------------------------------------------------------------------------
import time  #Library for debugging and buffering
import csv  #Library to write data into csv file
import board  #Library for CircuitPi to get board info
import busio  #Library for CircuitPi bus communication
from adafruit_lsm6ds.lsm6dsox import LSM6DSOX  #Library for CircuitPi accel/gyrosensor
import adafruit_ds3231  #Library for CircuitPi RTC

i2c = busio.I2C(board.SCL,
                board.SDA)  #Define i2c connection with circuitPi busio
sox = LSM6DSOX(i2c)  #Define acceleration sensor for data
ds3231 = adafruit_ds3231.DS3231(i2c)  #Define RTC module for timing

for i in range(1, 10):
    t_RTC = ds3231.temperature
    print(t_RTC)
    time.sleep(1)
t = time.struct_time(
    (2020, 12, 12, 00, 00, 00, 0, -1,
     -1))  #Set RTC Clock to 0 hr/min/s before starting data collection
ds3231.datetime = t
print("Success, time is:", t)  #Used for debugging RTC clockset
print()  #Used for debugging RTC clockset
Exemple #7
0
def foo():
    i2c = busio.I2C(board.SCL, board.SDA)
    ds3231 = adafruit_ds3231.DS3231(i2c)
    while True:
        print("{3:02}:{4:02}:{5:02}".format(*ds3231.datetime))
        time.sleep(1)
Exemple #8
0
def main():
    i2c = busio.I2C(3, 2)
    rtc = adafruit_ds3231.DS3231(i2c)

    rtc.datetime = time.struct_time(current_struct_time())
    print_rtc_time(rtc)
Exemple #9
0
def get_RTC_time(I2C):
    rtc = adafruit_ds3231.DS3231(I2C)
    t = time.mktime(rtc.datetime)
    return (t)
Exemple #10
0
 def __init__(self, i2c=None):
     if i2c is None:
         i2c = board.I2C()
     self._rtc = adafruit_ds3231.DS3231(i2c)
Exemple #11
0
import sys
import Adafruit_DHT
import busio
import adafruit_ds3231
import requests

from board import *

rtcI2C = busio.I2C(SCL, SDA)
rtc = adafruit_ds3231.DS3231(rtcI2C)

t = rtc.datetime

while True:
    humidity, temperature = Adafruit_DHT.read_retry(11, 24)
    if humidity is not None and temperature is not None:
        tempfile = {
            "temp": temperature,
            "humi": humidity,
            "year": t.tm_year,
            "month": t.tm_mon,
            "day": t.tm_mday,
            "hour": t.tm_hour,
            "min": t.tm_min
        }
        res = requests.post('http://localhost:3013/add', tempfile)
        print(res)
        break
Exemple #12
0
# CONSTANT MOUNTING LOCATION
MOUNT_DIR = "/home/pi/usb"

# Constant used for the time between writes to the file.
TIME_BETWEEN_LINES = 60

# /////////////////////////////////////////////////////////////
# Set up each of the devices so that they are usable throughout the script.

i2c = busio.I2C(board.SCL, board.SDA)

# Create the TCA9548A object and give it the I2C bus (This is the I2C mux)
tca = adafruit_tca9548a.TCA9548A(i2c)

# Used to talk to the ds3231 (RTC) note, this is connected to mux channel 2
rtc = adafruit_ds3231.DS3231(tca[2])

# 1 Out of the 2 MPL sensors for pressure and heat.
mpl1 = adafruit_mpl3115a2.MPL3115A2(tca[0])  # mux channel 0
mpl2 = adafruit_mpl3115a2.MPL3115A2(tca[1])  # mux channel 1

# Define LCD display dimensions and I2C address
WIDTH = 128
HEIGHT = 32

# Create the digital out used for display reset
rst = DigitalInOut(board.D7)

display = adafruit_ssd1306.SSD1306_I2C(WIDTH,
                                       HEIGHT,
                                       i2c,
Exemple #13
0
def main():
    i2c = busio.I2C(3, 2)
    rtc = adafruit_ds3231.DS3231(i2c)

    print_rtc_time(rtc)