• Hi guys,

    I'm using a Lopy4 with a pysense.
    (sysname='LoPy4', nodename='LoPy4', release='1.18.0.r1', version='v1.8.6-849-9569a73 on 2018-07-20', machine='LoPy4 with ESP32', lorawan='1.0.2', sigfox='1.0.1', pybytes='0.9.0')

    My large code used to work with the following lines at the end:

    py = Pysense()
    acc = LIS2HH12(py)
    py.setup_int_wake_up(True, False)
    acc.enable_activity_interrupt(800, 20)

    What is exactly how the docs told me to do.
    But since about one week now, after typing the line


    I completely loose the connection to the board and it does not sleep (heartbeat led blinking as normal)
    It seems like the communication between the Lopy and pysense does no longer work.

    I tryed with all different hardware and software - Wipy, Lopy, New Lopy, pytrack, pysense - all the same. I can no longer run my script since the sleep state never enters and I never get the pycom back unless complete removal of power.
    Any ideas what this could be or how to solve??

  • @jcaron Ill pass the suggestion along :) certainly seems like a more sane way for things to behave.

  • @paul-thornton The better option would probably be to make sure that setup_sleep only makes a note of what it will need to do, and that things actually happen only once you call go_to_sleep. I actually don't really remember why they are two different calls and not a single go_to_sleep(time_to_sleep), but it's been a while since I looked at that.

    But in the meantime, documenting the way it currently works would definitely be a good idea.

  • @jcaron Thanks a lot! Looking at it with this in mind, testing works as it should. Still kind of print("anything") before those lines does not show up in REPL. But some time.sleep(1) between solved this. Guess the PIC is faster in shutting down than the UART in sending the buffer.

  • I think this is something we can be clearer about in the documentation. Ill add a note to the api docs in the next update.

  • @pat_hslu Note that there is a difference in behaviour between doing it "by hand" (typing one then the other line, or even copying-and-pasting) and running it as part of a script.

    setup_sleep starts changing the configuration of the PIC on the Pysense. It probably shouldn't, and should probably just make a note that it should do those changes only when go_to_sleep is called, but at the moment that's the way it is.

    So the only way to test setup_sleep is to have it a script with the go_to_sleep right after it. You could for instance define a function that makes both calls, and call that function from REPL if you want to test manually.

    However if you run both as part of a script it should indeed work as intended. If it doesn't, you should probably also include details of the Pysense firmware version you are using, as well as the version of the Pysense library.

    Note that since you're using a LoPy 4, you may not need to use the Pysense-assisted deep sleep and may be better off using the "native" machine.deepsleep, but I'm not sure how that works out with accelerometer wake up.

Log in to reply

Pycom on Twitter