about esp32 mcahine.RTC.irq

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
ambob
Posts: 2
Joined: Mon Oct 08, 2018 11:23 pm

about esp32 mcahine.RTC.irq

Post by ambob » Thu Oct 11, 2018 12:58 am

hello everyone

i want to use the follow code:

import machine

# configure RTC.ALARM0 to be able to wake the device
rtc = machine.RTC()
rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)

it tell me 'AttributeError: 'RTC' object has no attribute 'irq''

dir(rtc). it tell me:
['__class__', 'datetime', 'init', 'memory']

so i want to know,how to resolve it?
1\. import another module for instead of RTC?
2\ RTC need some config?

i only want to use timer to enter deep-sleep mode and wake up it

thanks
by the way ,my english is poor, :lol:
我可以说中文,就会说的顺溜了 哈哈

jickster
Posts: 511
Joined: Thu Sep 07, 2017 8:57 pm

Re: about esp32 mcahine.RTC.irq

Post by jickster » Thu Oct 11, 2018 8:46 pm

The ESP32 port doesn't have those attributes

https://github.com/micropython/micropyt ... rtc.c#L150

Code: Select all

STATIC const mp_rom_map_elem_t machine_rtc_locals_dict_table[] = {
    { MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&machine_rtc_init_obj) },
    { MP_ROM_QSTR(MP_QSTR_datetime), MP_ROM_PTR(&machine_rtc_datetime_obj) },
    { MP_ROM_QSTR(MP_QSTR_memory), MP_ROM_PTR(&machine_rtc_memory_obj) },
};
STATIC MP_DEFINE_CONST_DICT(machine_rtc_locals_dict, machine_rtc_locals_dict_table);

const mp_obj_type_t machine_rtc_type = {
    { &mp_type_type },
    .name = MP_QSTR_RTC,
    .make_new = machine_rtc_make_new,
    .locals_dict = (mp_obj_t)&machine_rtc_locals_dict,
};

User avatar
Mike Teachman
Posts: 26
Joined: Mon Jun 13, 2016 3:19 pm
Location: Victoria, BC, Canada

Re: about esp32 mcahine.RTC.irq

Post by Mike Teachman » Thu Oct 11, 2018 11:27 pm

If you want to deepsleep for a period of time you can try the following in MicroPython v1.9.4

>>> import machine
>>> machine.deepsleep(3000)
<ESP32 resets after 3 seconds>


you also might want to take a look at the LoBo port. It supports wake from deepsleep using a timer and using external pins
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo

ambob
Posts: 2
Joined: Mon Oct 08, 2018 11:23 pm

Re: about esp32 mcahine.RTC.irq

Post by ambob » Fri Oct 12, 2018 1:17 am

thanks very much

it works well

i have a new question about deepsleep

it looks restart the programe

when programe start i set some initialize value and device: for example:
1. oled screen it will spangled per restart ,for it need initialize

i want to save some as global variables
when programe first start. it will be initialize
but when deepsleep ,it be saved when wake up from deepsleep. it can be use not must be initilaze again.
so the device like oled screen will not be spangled

Post Reply