Code not moving past py.read_battery_voltage once every few thousand cycles
I managed to catch this after a long time of searching, but for some reason on the rare occasion my nodes just stopped responding, I caught it after leaving my code run on a 20 second cycle (without deepsleep). There is no error, it just occurs between my code with "Line 47.5" and "Line 48". It will print line 47.5, but never print the line 48.
My code ran for about 16 hours before it stopped, but has done longer and shorter intervals, at 16 hours its about 2500 cycles. I usually do 15minutes between cycles so during those tests sometimes the node will run for it's entire battery life but maybe one unit will fail, I've never been sure why this has been happening, hopefully this is the reason.
I am making the assumption that this is happening while using deepsleep since as you can imagine it would be very difficult to refresh the REPL every time for a few thousand goes before it just stopped responding.
Has anyone else experienced this or do the battery voltage in a different way?
import machine from network import LTE from pytrack import Pytrack import os import time import socket import pycom from MQTT import MQTTClient from L76GNSS import L76GNSS def sub_cb(topic, msg): print(msg) lte = LTE() # lte.reset() lte.send_at_cmd('AT^RESET') lte.send_at_cmd('AT!="clearscanconfig"') print("Line 15") lte.send_at_cmd('AT+CGDCONT=2,"IP","telstra.internet"') print("Line 19") lte.send_at_cmd("AT!=\"RRC::addscanfreq band=28 dl-earfcn=9410\"") lte.send_at_cmd('AT!="RRC::addScanBand band=28"') print("Line 20") lte.send_at_cmd('AT+CFUN=1') print("Line 21") while not lte.isattached(): print("Attaching...") time.sleep(0.1) print(lte.isattached()) print("Attached") lte.connect() while not lte.isconnected(): print("Connecting...") time.sleep(0.1) print(lte.isconnected()) print("Connected!") time.sleep(2) def settimeout(duration): pass print("line41") def sub_cb(topic, msg): print(msg) print("line44") while lte.isconnected(): try: client = MQTTClient("Demo","io.adafruit.com",user="Dylan", password="password", port=1883) print("Line 38") client.set_callback(sub_cb) print("Line 41") client.connect() print("Line 43") time.sleep(1) client.subscribe(topic="Dylan/feeds/data") print("Line 46") print(lte.isconnected()) print('Line 47') py = Pytrack() print('47.5') battery = str(py.read_battery_voltage()) print('Line 48') time.sleep(0.1) l76 = L76GNSS(py, timeout=90) coord = l76.coordinates() print('Line 49') lat = coord lon = coord utctime = coord data = battery + ',' + str(utctime) + ',' + str(lat) + ',' + str(lon) + '\n' client.publish(topic="Dylan/feeds/data", msg=data) print(data) # lora.nvram_save() time.sleep(3) print("Line 55") #client.check_msg() time.sleep(5) # py.setup_sleep(20) # py.go_to_sleep() except OSError: print(' OSERROR occured, retrying...') time.sleep(0.5) machine.reset() if not lte.isconnected(): machine.reset()