Trouble with deepsleep example



  • I'm new to micropython and have been struggleing to get my device to wake up from deepsleep. I was expected it to do something, then go to sleep for x seconds and then restart the main.py program.

    I am running a FiPy with firmware version 1.18.0.r1 with a 2.0 expansion board. I'm trying to figure out how to get deepsleep to work. I started with the deepsleep example from the library. When I run that, I get the following error:

    File "main.py:, line 7, in <module>
    File "/flash/lib/deepsleep.py", line 157, in get_wake_status
    File "/flash/lib/deepsleep.py", line 81, in peek
    Index error: bytes index out of range

    0_1535675382216_50c041e5-b693-4610-8d6b-890977425bc5-image.png

    I could not figure out those errors, and have searched on help forums for a few hours today.

    I also tried using a code that utilized machine.deepsleep. I wrote a simple code that just turns the LED on. It goes to sleep, but never wakes up. I must be missing something here.

    Here is my code:

    main.py:

    0_1535674774733_e76c9aee-543b-4a25-a52a-a5372c1013da-image.png



  • Interesting.
    I have not tried only powering via USB.

    I have always connected a seperate 5V supply to replicate the exact arrangement for my end solution. You also need the extra current to make the radio components work correctly.

    Good find.

    Peter.



  • So I think I figured out how to get it working. I used an external 5v power source that I built and powered it through the Vin and Gnd GPIO pins on the expansion board. (Whereas before, I was leaving it connected to my computer using Atom so I could read the print command outputs on the command line screen.)

    Is this similar to other peoples' experiences? .. that machine.deepsleep, and maybe certain other commands, will only work when using a separate 5v power source and not connected to a computer?



  • @tuftec
    I just tried your suggestion. I turned off the heartbeat function and left it off and then I uploaded the revised main.py code and rebooted. Still no luck. It turns the green LED on and then off, then then goes to sleep and just stays asleep.

    I'm at a loss about what to do. I'd really like to get it working.



  • When your code comes out of deepsleep it should just reboot.

    I have seen funny issues when trying to use the heartbeat function.
    I would suggest you just turn it off and leave it off. That is what I do.

    Peter.



  • @jcaron @tuftec
    Oops, I meant to say that I added the /lib/deepsleep.py when I was following the deepsleep example (from the github library). I didn't realize that was only for the work around.

    I was trying to use machine.deepsleep, with the /lib/deepsleep.py in the library even though its not imported. I just now deleted it our per suggestion by jcaron and tuftec, and reset the FiPy... unfortunately it still seems to do the same thing. It runs all of the main.py and then appear to just go into deepsleep and doesn't wake up.

    Do I need anything special in the boot.py? Here is what I have (which is nothing):
    0_1535723507757_c59f637c-2932-437c-8dc0-6cdceab18543-image.png



  • @matt your code looks ok.

    But, why do you upload /lib/deepsleep.py?????
    You should not need to do this.
    The machine library is already embedded in the device ROM.
    This might be your problem.

    I am using deepsleep successfully on a LoPy4.

    You should not need to put anything in /flash/lib.



  • @matt the deepsleep.py library is required when you use the Deep Sleep shield, which is a workaround for some of the older modules which had a high power draw issue in deep sleep.

    You don’t need it with a FiPy.

    However I don’t see where you load it. Are you sure your main.py is actually the one you posted?


 

Pycom on Twitter