balance19 / micropython_ds3231 Goto Github PK
View Code? Open in Web Editor NEWA library to run the DS3231 RTC on Raspberry Pi Pico
License: MIT License
A library to run the DS3231 RTC on Raspberry Pi Pico
License: MIT License
under class RTC
m = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
under def DS3231_ReadTime
month = self.m[self.bcd2bin(buffer[5])]
in if mode ==
if mode == 2:
mod2_string = str(hour) + ":" + str(minute) + ":" + str(second) + " " + weekday + " " + month + "." + str(day) + "," + str(year)
return mod2_string
and finally change 1
t = rtc.DS3231_ReadTime(2)
yet after slapping it into my raspberry pi pico I'm getting the Error: Is the DS3231 not connected display on a 1602 LCD
could you please upload this to pypi so it can be downloaded directly from Thonny?
Edit:
It should be easy to pick this up from RTC_DS3231::setAlarm1
and RTC_DS3231::setAlarm2
in https://github.com/adafruit/RTClib/blob/master/src/RTC_DS3231.cpp
I connected the DS3231 to my Pico: SDA to pin 16, SCL to pin 17, GND to GND and VCC to VSYS.
I copied the example code in main.py and put the RTC_DS3231.py in a my_lib folder. I didn't change any code.
When i tried to run the code I got the error: ([Errno 5] EIO) and when i tried Settime() in the example code I got:
Traceback (most recent call last):
File "", line 13, in
File "my_lib/RTC_DS3231.py", line 26, in DS3231_SetTime
OSError: [Errno 5] EIO
I tried to run a I2C address scan and got 0x57, but when a changed the address it still got the same error massages.
Does someone know how to solve this problem and make it work like intended?
When I try to use differnt I2C ports on the pico your code give me an error that it can't find the device:
"Error: is the DS3231 not connected or some other problem ([Errno 5] EIO)
Error: is the DS3231 not connected or some other problem ([Errno 5] EIO)"
I have tried changing the port info in your library but it just doesn't take. I can use a simple I2C scanner and see the clock there.
When going from Thursday to Friday, program is trying to access in w the eight element. List is only seven elements long.
I replaced :
class RTC:
w = ["SAT","SUN","MON","TUE","WED","THU","FRI"]
with:
class RTC:
w = ["null","SAT","SUN","MON","TUE","WED","THU","FRI"]
Or weekday = self.w[self.bcd2bin(buffer[3])] should be
weekday = self.w[(self.bcd2bin(buffer[3]) - 1)]
Hi,
I made some improvements that solves some problems:
RTC_DS3231.py.txt
I hope this contributes to a more useful DS3231 driver.
I'm not sure if this code is still being maintained, but even if it isn't, this might be useful for other users.
The default NowTime for DS3231_SetTime has x28 for the "week" byte. This byte is actually the day of the week on the DS3231, not the week of the year. It is meant to have values from x01 to x07, with an arbitrary start of the week. If you choose to map the values to the more usual 0-6 system, with Sunday as 0 (like Javascript), then the value should be x04 (Wednesday 14 July 2021), not x28.
Most times it shouldn't matter as the DS3231 ignores the highest 4 bits and unless you are relying on the device for the day of the week, it won't affect the date and time readings.
I suggest that the byte be named "weekday" rather than "week" and the x28 be changed to x04.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.