问题描述
我在 TTN 的柜台上遇到了问题。在我的 machine.deepsleep
中添加 LoPy4
函数后发生了这个问题。我已经使用了 nvram_save() 和 nvram_restore ()
函数,但是 TTN 中的计数器仍然没有增加。
这个屏幕截图:
那么,在这种情况下有什么问题?
这是我的代码:
enter code here
import ads1x15 as extADC
import gc
import pycom
import socket
from network import LoRa
from uModBus.serial import Serial
from network import LoRa
import machine
import ubinascii
import utime
from machine import RTC,I2C
from machine import Pin
pycom.heartbeat(False)
rtc = RTC()
i2c = I2C(0,I2C.MASTER,pins=('P3','P4'),baudrate=100000)
adc = extADC.ADS1115(i2c,gain=1)
pinTrig = Pin('P23',mode=Pin.OUT)
# LoRa Socket Connection with two condition
if machine.reset_cause() == machine.DEEPSLEEP_RESET:
pinTrig.value(1) # enable High (12v)
print("WOKE UP FROM DEEPSLEEP 3 MINUTES !")
utime.sleep(1)
lora = LoRa(mode=LoRa.LORAWAN,region=LoRa.AS923)
lora.nvram_restore() # Nvram restore function
s = socket.socket(socket.AF_LORA,socket.soCK_RAW)
s.setsockopt(socket.soL_LORA,socket.so_DR,5)
s.setblocking(False)
s.bind(1)
else:
pinTrig.value(1)
utime.sleep(1)
print("I'M PowerOn by Humans or Hard reset !")
lora = LoRa(mode=LoRa.LORAWAN,region=LoRa.AS923)
lora.nvram_restore() # Nvram restore function
app_eui = ubinascii.unhexlify('********************')
app_key = ubinascii.unhexlify('-----------------------------')
lora.join(activation=LoRa.OTAA,auth=(app_eui,app_key),timeout=0)
while not lora.has_joined():
utime.sleep(2.5)
print('Not yet joined...')
print('Joined')
s = socket.socket(socket.AF_LORA,5)
s.setblocking(True)
s.bind(1)
### Begin sensor reading and sending function ##################
def read_data_Sensor () :
### End sensor reading and sending function ####################
try:
read_data_Sensor()
lora.nvram_save()
utime.sleep(1)
pinTrig.value(0)
print("DeepSleep Mode")
utime.sleep(1)
machine.deepsleep(180000)
except OSError:
print("Terjadi Error - Restart")
s.send(b"\xff\xff")
utime.sleep(1)
machine.reset()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)