'RTC' object has no attribute 'alarm'



  • Hi all!
    I'm pretty new to Python and the WiPy module. i received it last weekend and now I'm playin' arround.
    I just want to set the WiPy periodically to sleep. But I get this confusing AttributeError. What's wrong?
    Here's my code:

    import machine
    from machine import RTC
    #import os
    #import time

    global counter
    counter =0

    def alarm_handler(rtc_o):
    pass

    print("\nWiPy is up\n")

    rtc = RTC()
    rtc.alarm(time=5000, repeat=True)
    rtc_irq = rtc.irq(trigger=RTC.ALARM0, handler=alarm_handler, wake=machine.SLEEP)

    while True:
    print(counter)
    counter = counter + 1
    machine.sleep()


Log in to reply
 

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.