LoPy 4 - Deep Sleep high current consumption? 412uA



  • I'm having trouble with getting my LoPy 4 down to the specified 50uA during deep sleep. As of now I get an average of 412uA. I don't know why.

    from machine import Pin
    import time
    from network import LoRa
    from network import WLAN
    from network import Bluetooth
    from network import Server
    # from network import MDNS
    import socket
    import ubinascii
    import pycom
    import machine
    from machine import Timer
    from network import Sigfox
    
    
    intervalforlora = 10 # in seconds
    # MDNS.deinit()
    wlan = WLAN()
    wlan.deinit()
    bt = Bluetooth()
    bt.deinit()
    server = Server()
    server.deinit() # disable the server
    
    
    
    
    buttonPin = Pin('P8', mode=Pin.IN, pull=True)
    buttonPin2 = Pin('P9', mode=Pin.IN, pull=True)
    
    lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.EU868, tx_power=14, sf=12, power_mode=LoRa.TX_ONLY)
    
    
    
    app_eui = ubinascii.unhexlify('XXXXXXXXXXXXXX')
    app_key = ubinascii.unhexlify('XXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
    dev_eui = ubinascii.unhexlify('XXXXXXXXXXXXXX') 
    
    lora.join(activation=LoRa.OTAA, auth=(dev_eui, app_eui, app_key), timeout=0)
    
    chrono = Timer.Chrono()
    chrono.start()
    
    lora.nvram_restore()
    
    
    while not lora.has_joined() or chrono.read() <= intervalforlora:
        pycom.heartbeat(True)
        starttime = time.time()
        time.sleep(2.5)
        print('Not yet joined...')
    if chrono.read() >= intervalforlora and not lora.has_joined():
    	machine.reset()
    
    print('Joined')
    s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    
    s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5)
    
    pycom.heartbeat(False)
    
    
    while True:
        s.setblocking(True)
        print()
        s.send(bytes([buttonPin()]))
        s.setblocking(False)
        time.sleep(10)
        
        print(buttonPin(),buttonPin2())
    
        # deepsleep
      
        if buttonPin() == 1:
            machine.pin_sleep_wakeup(["P9"], mode=machine.WAKEUP_ANY_HIGH, enable_pull=True)
            machine.deepsleep(1000*3600*24)  # 24 hours
        else:
            machine.pin_sleep_wakeup(["P8"], mode=machine.WAKEUP_ANY_HIGH, enable_pull=True)
            machine.deepsleep(1000*3600*24)  # 24 hours
    
    

    alt text
    Any help with solving this mystery would be greatly appreciated!



  • Could this be caused by having 2x 10k resistors connected to 3v3?


Log in to reply
 

Pycom on Twitter