Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Voltage on SQW #12

Open
PaoloFanta opened this issue Jan 9, 2022 · 6 comments
Open

Voltage on SQW #12

PaoloFanta opened this issue Jan 9, 2022 · 6 comments

Comments

@PaoloFanta
Copy link

Hello. I state that I am not a programmer. I am using your library and thank you for sharing it. I use it with an ESP32 that I would like to awaken from a deep sleep with a DS3231. The DS3231 is connected to ESP32 with SDA on pin 22 and SCL on pin 23. The SQW pin of the DS3231 to pin 32 of the ESP32. On the DS3231 I was able to correctly set both the time and the alarm for waking up. When ESP32 goes into deep sleep, a problem arises that prevents it from restarting at the time programmed on DS3231. It happens that when ESP32 goes into deep sleep the voltage goes from 0V to 3.28V and immediately reactivates ESP32 in a continuous loop and I cannot understand why. The DS3231 is powered directly from the 3.3v pin of the ESP32 which continues to supply current even when it goes into dormancy. This is my code.

import machine
from machine import Pin, I2C, RTC, lightsleep, wake_reason, idle
import utime
import time
import DS3231

i2c = I2C(sda = Pin(22), scl=Pin(23))
ds = DS3231.DS3231(i2c)

led = Pin (18, Pin.OUT)
led.value(1)
rtc = RTC()

import esp32
from time import sleep
sleep(10)

btn1 = Pin(32, Pin.IN, Pin.PULL_DOWN) # Normally low, high when pressed
esp32.wake_on_ext0(pin = btn1, level = esp32.WAKEUP_ANY_HIGH)
machine.deepsleep()

What could be the problem?

I thank you in advance.

@shaoziyang
Copy link
Collaborator

Do you enable alarm interrupt or Square-Wave Output? You can try to set Control Register (0Eh) to 0x1C (default value) to disable SQW, and clear A1F/A2F (Alarm Flag) before enter deepsleep mode.

@PaoloFanta
Copy link
Author

thanks for your kind reply. As I explained to you, I am not a programmer, I managed to get here only thanks to what I found on the internet. I'm sorry but I'm unable to go any further on my own.

@shaoziyang
Copy link
Collaborator

use ds.setReg(DS3231_REG_CTRL, 0x1C) to disable SQW, and ds.ClearALARM() to clear alarm.

@PaoloFanta
Copy link
Author

By adding
ds.setReg(DS3231_REG_CTRL, 0x1C)

gives me the following error:

File "main.py", line 27, in
NameError: name 'DS3231_REG_CTRL' isn't defined

@shaoziyang
Copy link
Collaborator

use
ds.setReg(DS3231.DS3231_REG_CTRL, 0x1C)

@PaoloFanta
Copy link
Author

The command does not give an error but the SQW pin always remains high.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants