LoPy 4 - Current consumption and Deep Sleep
-
Thank you for your reply !
Here's what I get with the os.uname() command :
(sysname='LoPy4', nodename='LoPy4', release='1.15.0.b1', version='v1.8.6-849-baa8c33 on 2018-01-29', machine='LoPy4 with ESP32', lorawan='1.0.0', sigfox='1.0.1')
About my setup, I use an external 10kOhm pull down resistor and the pin P13. Here's how I configure the pin :
from machine import Pin import machine pinAlert = Pin('P13', mode=Pin.IN, pull= Pin.PULL_DOWN) machine.pin_deepsleep_wakeup(['P13'], machine.WAKEUP_ANY_HIGH, True)
The other part of the main :
import myClass import time remote = myClass.Remote() if machine.reset_cause() == machine.DEEPSLEEP_RESET: print('woke from a deep sleep') print(machine.wake_reason()) remote.send_msg() time.sleep(1) machine.deepsleep() else: print('power on or hard reset') remote.connect() print("going to deepsleep") machine.deepsleep()
If needed here are my connect and send_msg functions from the class Remote :
def connect(self): self.lora.join(activation=LoRa.OTAA, auth=(self.deveui, self.appeui, self.appkey), timeout=0, dr=0) while not self.lora.has_joined(): time.sleep(parameters.DELAY_BETWEEN_ATTEMPTS) print('CONNECTED') self.lora.nvram_save() def send_msg(self): print("SENDING LORA MESSAGE") self.lora.nvram_restore() try: self.socket.setblocking(True) self.socket.send(bytes([0x01])) except Exception as ex: print("Error: {0}".format(ex)) finally: self.socket.setblocking(False) self.socket.settimeout(parameters.SOCKET_TIMEOUT) self.lora.nvram_save()
Thanks for your help !
-
@cduplouy
Also how are you going to deepsleep and wake up on a button press? Can you show that part of your code and describe your setup?Thanks
-
@cduplouy
do you have current firmware?
You can check firmware by:import os os.uname()