DS3231 Chinese Community!

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
sprinkfitter
Posts: 36
Joined: Wed Sep 27, 2017 1:42 pm
Location: Louisville Ky

DS3231 Chinese Community!

Post by sprinkfitter » Tue Mar 26, 2019 4:06 pm

Has anyone been able to get this library to work with an esp32?? https://github.com/micropython-Chinese- ... isc/DS3231
I have added 5k pull-up resisters to SCL AND SDA lines.

Code: Select all

import DS1307
from machine import I2C, Pin
#import DS3231

i2c = I2C(sda=Pin(5), scl=Pin(4))
ds = DS1307.DS1307(i2c)
#ds = DS3231.DS3231(i2c)
ds.DateTime()
ds.DateTime([2018, 3, 9, 4, 23, 0, 1, 0])
ds.Hour(12)
ds.Hour()
ds.Time()
ds.Time([12, 10, 0])
ds.DateTime([2018, 3, 12, 1, 22, 10, 0])
ds.ALARM(12, 20, 10, ds.PER_DISABLE)
ds.ALARM(12, 20, 10, ds.PER_DAY)
ds.ClearALARM()
while True:
  print(ds.DateTime)


exec(open('RTC.py').read(),globals())
T
rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:4732
load:0x40078000,len:7496
load:0x40080400,len:5512
entry 0x4008114c
[0;32mI (399) cpu_start: Pro cpu up.[0m
[0;32mI (399) cpu_start: Single core mode[0m
[0;32mI (400) heap_init: Initializing. RAM available for dynamic allocation:[0m
[0;32mI (403) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM[0m
[0;32mI (409) heap_init: At 3FFC0E00 len 0001F200 (124 KiB): DRAM[0m
[0;32mI (415) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM[0m
[0;32mI (422) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m
[0;32mI (428) heap_init: At 400915E0 len 0000EA20 (58 KiB): IRAM[0m
[0;32mI (434) cpu_start: Pro cpu start user code[0m
[0;32mI (5) cpu_start: Starting scheduler on PRO CPU.[0m
OSError: [Errno 2] ENOENT

shaoziyang
Posts: 363
Joined: Sun Apr 17, 2016 1:55 pm

Re: DS3231 Chinese Community!

Post by shaoziyang » Wed Mar 27, 2019 3:11 am

I will try it a little later.

sprinkfitter
Posts: 36
Joined: Wed Sep 27, 2017 1:42 pm
Location: Louisville Ky

Re: DS3231 Chinese Community!

Post by sprinkfitter » Wed Mar 27, 2019 1:47 pm

Thanks Big Help!! :) :) :)

shaoziyang
Posts: 363
Joined: Sun Apr 17, 2016 1:55 pm

Re: DS3231 Chinese Community!

Post by shaoziyang » Wed Mar 27, 2019 2:03 pm

Both DS1307 and DS3231 lib are works in ESP32.

Code: Select all

MicroPython v1.10-54-g43a894fb4 on 2019-02-07; ESP32 module with ESP32
Type "help()" for more information.
>>> 
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== from machine import Pin, I2C
=== import DS1307
=== 
=== i2c = I2C(-1, sda = Pin(21), scl = Pin(22))
=== ds = DS1307.DS1307(i2c)
=== ds.DateTime()
[2019, 3, 25, 2, 21, 53, 40, 0]
>>> 

Code: Select all

>>> 
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== from machine import Pin, I2C
=== import DS3231
=== 
=== i2c = I2C(-1, sda = Pin(21), scl = Pin(22))
=== i2c.scan()
=== ds = DS3231.DS3231(i2c)
=== ds.DateTime()
[87, 104]
[2019, 3, 27, 3, 21, 55, 44]
>>> 

sprinkfitter
Posts: 36
Joined: Wed Sep 27, 2017 1:42 pm
Location: Louisville Ky

Re: DS3231 Chinese Community!

Post by sprinkfitter » Wed Mar 27, 2019 9:29 pm

Thank You!! Big help. Miss that address in code. Works great now.

Post Reply