Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Deepsleep Testing

    Scheduled Pinned Locked Moved Discussion
    lopydeepsleep
    6 Posts 3 Posters 2.2k Views 5 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      ssmith
      last edited by

      Trying to test out deepsleep and it seems to work the first time but not after that. I see the the LoPy reboots with a DEEPSLEEP_RESET but after that the code seems to run a not go into deepsleep.

      from network import LoRa,  WLAN
      import socket
      import machine
      import time
      import binascii
      
      #Setup LORA
      #lora = LoRa(mode=LoRa.LORA, frequency=918000000, power_mode=LoRa.ALWAYS_ON, tx_power=14, bandwidth=LoRa.BW_125KHZ, sf=12, preamble=8, coding_rate=LoRa.CODING_4_8, tx_iq=False, rx_iq=False)
      lora = LoRa(mode=LoRa.LORA, frequency=918000000, power_mode=LoRa.ALWAYS_ON, tx_power=14, bandwidth=LoRa.BW_125KHZ, sf=12, preamble=8, coding_rate=LoRa.CODING_4_8, tx_iq=False, rx_iq=False)
      lora.init(mode=LoRa.LORA, frequency=918000000, power_mode=LoRa.ALWAYS_ON, tx_power=14, bandwidth=LoRa.BW_125KHZ, sf=12, preamble=8, coding_rate=LoRa.CODING_4_8, tx_iq=False, rx_iq=False)
      
      #Setup WLAN
      wlan = WLAN(mode=WLAN.STA)
      wlan.init(antenna=WLAN.INT_ANT,  power_save = False)
      
      #Setup RECV socket
      s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
      sn = machine.unique_id()
      sn = binascii.hexlify(sn)[-6:]
      sn = sn.decode('utf8')
      print(sn)
      wlan.connect("XXX", auth=(WLAN.WPA2, "XXX"), timeout=5000)
      
      while not wlan.isconnected(): 
           machine.idle()
      print("Connected to Wifi\n")
      
      #Start Send
      count =0 #test count
      print("BOOT")
      
      while True:
          s.setblocking(True)
          payload = str(count)
          payload = "SN: {} -- MSG: {}".format(sn, count)
          s.send(payload)
       
          print("SN: {}  --  Count: {}  --  Payload: {}".format(sn, count, payload))
          machine.deepsleep(1000)
          count += 1
      
      

      I get the following on the console when I run this code.

      Running main.py
      I (64587) wifi: sleep disable
      I (64601) wifi: sleep disable
      00b856
      I (64729) wifi: n:1 0, o:6 0, ap:255 255, sta:1 0, prof:6
      I (65717) wifi: state: init -> auth (b0)
      I (65719) wifi: state: auth -> assoc (0)
      I (65726) wifi: state: assoc -> run (10)
      I (65750) wifi: connected with WaterR8, channel 1
      Connected to Wifi
      
      BOOT
      SN: 00b856  --  Count: 0  --  Payload: SN: 00b856 -- MSG: 0
      I (67508) wifi: state: run -> init (0)
      I (67508) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:6
      E (67509) wifi: esp_wifi_connect 806 wifi not start
      ets Jun  8 2016 00:22:57
      
      rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
      configsip: 0, SPIWP:0x00
      clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
      mode:QIO, clock div:2
      load:0x3fff9010,len:8
      load:0x3fff9018,len:248
      load:0x40078000,len:4056
      load:0x4009fc00,len:920
      entry 0x4009fde4
      I (1553) wifi: wifi firmware version: 2a22b2d
      I (1568) wifi: pp_task_hdl : 3ffd6fd8, prio:23, stack:8192
      I (1568) wifi: Init lldesc rx mblock:10
      I (1568) wifi: Init lldesc rx ampdu len mblock:7
      I (1570) wifi: Init lldesc rx ampdu entry mblock:4
      I (1575) wifi: sleep disable
      I (2564) wifi: frc2_timer_task_hdl:3ffdd028, prio:22, stack:2048
      I (2567) wifi: mode : softAP (24:0a:c4:00:b8:57)
      I (2667) wifi: mode : sta (24:0a:c4:00:b8:56)
      I (2668) wifi: sleep disable
      I (2684) wifi: sleep disable
      00b856
      SN: 00b856  --  Count: 0  --  Payload: SN: 00b856 -- MSG: 0
      SN: 00b856  --  Count: 1  --  Payload: SN: 00b856 -- MSG: 1
      SN: 00b856  --  Count: 2  --  Payload: SN: 00b856 -- MSG: 2```
      1 Reply Last reply Reply Quote 0
      • B Offline
        bucknall
        last edited by

        Hi @ssmith

        The argument passed into machine.deepsleep() is in milliseconds so your board will only be sleeping for 1 second!

        This might be leading you to think the board isn't going into deepsleep! Also be aware that your code will restart from main.py when you initiate deepsleep.

        Hope this helps!

        Developer Evangelist - Pycom

        J 1 Reply Last reply Reply Quote 0
        • S Offline
          ssmith
          last edited by

          I only see 1 (DEEPSLEEP_REST) in the console. Shouldn't I see a (DEEPSLEEP_RESET) every time it reboots? I also changed the timeout to 50 seconds and the first pass see a 50 second delay before the first reboot but then the code just runs through the while loop with no delays. You can see the console output printing each message with an incrementing counter. If it was restarting main.py wouldn't the counter get reset also?

          1 Reply Last reply Reply Quote 0
          • S Offline
            ssmith
            last edited by

            @bucknall
            I figured out what was going on here. I was running the program from PyMkr. I would run correctly the first time but after a reboot it ran the code from /flash which wasn't updated.

            No I can move on to power testing.

            1 Reply Last reply Reply Quote 1
            • J Offline
              jasonriedy @bucknall
              last edited by

              @bucknall I'm seeing a general theme about debugging power usage during "deep sleep." What tooling is available to let everyone compare against the same baseline?

              B 1 Reply Last reply Reply Quote 0
              • B Offline
                bucknall @jasonriedy
                last edited by

                Hi @jasonriedy

                There's nothing in the way of tooling at the moment but I'll have a chat with the team to see about putting out a benchmark script to verify power efficiency. Will let you know when I've heard back!

                Developer Evangelist - Pycom

                1 Reply Last reply Reply Quote 1

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • 1 / 1
                • First post
                  Last post

                Pycom on Twitter

                Pycom