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

    Fipy freezes after two or three days. Using pytrack, Sigfox and DeepSleep

    Scheduled Pinned Locked Moved FiPy
    7 Posts 3 Posters 79 Views 3 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.
    • E Offline
      Erick Falcon
      last edited by

      I want it for continuous monitoring. I did some tests with the following code, but after two or three days the code stops working and the blue light starts flashing. I want to send sensor data and coordinates using Sigfox every two hours and use the deep sleep function to save energy. I would greatly appreciate your help.

          import time
          import machine        
          from machine import Pin        
          from onewire import DS18X20       
          from onewire import OneWire
          
          from machine import UART
          
          from machine import ADC
          
          import math
          
          from network import Sigfox
          
          import socket
          
          import pycom
          
          import network
          
          import os
          
          import utime
          
          import gc
          
          from machine import RTC
          
          from machine import SD
          
          from L76GNSS import L76GNSS
          
          from pytrack import Pytrack
          
          from network import Sigfox
          
          import socket
          
          from crypto import AES
          
          import crypto
          
          import ubinascii
          
          from machine import SD
          
          
          
          pycom.heartbeat(False)
          
          #machine.reset()
          
          p_out = Pin('P9', mode=Pin.OUT)
          
          p_out.hold (False)
          
          p_out.value(0)
          
          p_out.hold (True)
          
          
          
          
          
          
          
          CountT=0
          
          ow = OneWire(Pin('P3'))
          
          temp = DS18X20(ow)
          
          while CountT<=5:
          
              DS18X20.start_conversion(temp)
          
              #time.sleep(1)
          
              #print(DS18X20.read_temp_async(temp))
          
              time.sleep(0.2)
          
              valor_T=str(DS18X20.read_temp_async(temp))
          
          
          
              limite_T=len(valor_T)
          
              #print("Temperatura: "+valor_T)
          
              #print("Temperatura: "+valor_T)
          
              CountT+=1
          
          #<------------Aqui va el codigo de micro sd
          
          
          
          py = Pytrack()
          
          l76 = L76GNSS(py, timeout=30)
          
          
          
          
          
          
          
          #..............................
          
          contador=0
          
          C=""
          
          Coordenadas=""
          
          Latitud=""
          
          Longitud=""
          
          contador=0
          
          #Pines: P10(TX)->RX(Verde) P11(RX)->TX(Azul) (EC,S,TDS) P3=Temperatura  P16->pH  P17-> Turbiedad  P8->Transistores
          
          # DS18B20 data line connected to pin P10
          
          #Objetos para el sensor de temperatura
          
          
          
          #-----------------------------------------------------------
          
          #Objetos para el sensor de Conducitvidad Altas Scientific
          
          uart = UART(1,9600,pins=('P10','P11'))#uart=UART(baudrate=9600,pins=('P12','P11'))# #P3=TX P4=RX
          
          #uart.init(9600, bits=8, parity=None, stop=1,)
          
          
          
          bajo = 0
          
          alto = 1
          
          w=''
          
          
          
          EC = ''
          
          TDS = ''
          
          Sal = ''
          
          pH = ''
          
          ntu = ''
          
          Condicion = True
          
          C=0
          
          T = ''
          
          
          
          
          
          #PM=Primer Mensaje
          
          #------------------------------------------------------------
          
          
          
          
          
          while contador<=5:
          
          
          
              p_out.hold (False)
          
              p_out.value(1)
          
              p_out.hold (True)
          
          
          
              coord = l76.coordinates()
          
              #f.write("{} - {}\n".format(coord, rtc.now()))
          
              COORD="{}".format(coord)
          
              #print( COORD + str(contador))
          
              if COORD!="(None, None)":
          
          
          
                  Coordenadas= "{}".format(coord)
          
          
          
                  pycom.rgbled(0xFFCC00) # Amarillo                                 #
          
                  time.sleep(1)
          
                  pycom.rgbled(0x000000) # Apagado
          
          
          
                  if Coordenadas!="":
          
                      if PM==1:
          
                          LC=len(Coordenadas)
          
                          #print(C)
          
                          while  alto <= LC:
          
                              digito = Coordenadas[bajo:alto]
          
                              if digito.isdigit():
          
                                  Latitud = (Latitud + digito)
          
                              elif digito=="-":
          
                                  Latitud = (Latitud + digito)
          
                              elif digito==".":
          
                                  Latitud = (Latitud + digito)
          
                              elif digito==",":
          
                                  bajo=alto
          
                                  alto=bajo + 1
          
                                  while alto <= LC:
          
                                      digito = Coordenadas[bajo:alto]
          
                                      if digito.isdigit():
          
                                          Longitud = (Longitud + digito)
          
                                      elif digito=="-":
          
                                          Longitud = (Longitud + digito)
          
                                      elif digito==".":
          
                                          Longitud = (Longitud + digito)
          
                                      elif digito==")":
          
                                          break
          
                                      bajo +=1
          
                                      alto +=1
          
                                  break
          
                              bajo +=1
          
                              alto +=1
          
                          bajo=0
          
                          alto=1
          
          
          
          
          
                          #mensaje2=('Lat'+Latitud+'Lon'+Longitud)
          
                          #LonM=len(mensaje2)
          
                          #print(LonM)
          
                  else:
          
                      pycom.rgbled(0xCC0000) # Rojo                                   #
          
                      time.sleep(1)
          
                      pycom.rgbled(0x000000) # Azul Marino
          
          
          
          #-------------Midiento el pH-----------------
          
          
          
          
          
              x=0
          
              a = []
          
          
          
              while x<100:
          
                  x+=1
          
                  adc = ADC()
          
                  # Set calibration - see note above
          
                  adc.vref(1093)
          
                  # Check calibration by reading a known voltage
          
                  adc_c = adc.channel(pin='P16', attn=ADC.ATTN_11DB)
          
                  #print(adc_c.voltage())
          
                  a.append(adc_c.voltage())
          
                  #print(a)
          
                  #print(x)
          
                  promediopH = sum(a)/100
          
              #print(int(promedio))
          
          
          
              m = 3/218
          
              b = -2416/218
          
          
          
              valor_ph = (promediopH*m)+b
          
              #valor_pH=valor_pH+0.35
          
          
          
              valor_ph=str(valor_ph)
          
              limite_ph=len(valor_ph)
          
          
          
              while  alto<= limite_ph and C<=4:
          
          
          
                  digito_ph = valor_ph[bajo:alto]
          
                  if digito_ph.isdigit():
          
                      pH = (pH + digito_ph)
          
                  elif digito_ph=='.':
          
                      pH = (pH + digito_ph)
          
                      bajo=alto
          
                      alto=bajo + 1
          
                      while alto<=limite_ph and C<=4:
          
                          digito_ph = valor_ph[bajo:alto]
          
                          if digito_ph.isdigit():
          
                              pH =  (pH + digito_ph)
          
          
          
                          bajo +=1
          
                          alto +=1
          
                          C+=1
          
                  bajo +=1
          
                  alto +=1
          
              bajo = 0
          
              alto = 1
          
              C=0
          
          #-----------------Midiento la Turbiedad---------------------
          
              y=0
          
              b = []
          
              while y<100:
          
                  y+=1
          
                  adc = ADC()
          
                  # Set calibration - see note above
          
                  adc.vref(1093)
          
                  # Check calibration by reading a known voltage
          
                  adc_c = adc.channel(pin='P17', attn=ADC.ATTN_11DB)
          
                  #print(adc_c.voltage())
          
                  b.append(adc_c.voltage())
          
                  #print(a)
          
                  #print(x)
          
                  promedioTur = sum(b)/100
          
                  volt=promedioTur/1000
          
                  volt = volt + 1.145
          
              volt=float(volt)
          
              RaizCuadradaV = math.pow(volt,2)
          
              if volt < 2.5:
          
                  valor_ntu=3000
          
              else:
          
                  valor_ntu=-1120.4*RaizCuadradaV +5742.3*(volt)-4352.8
          
              if valor_ntu <0:
          
                  valor_ntu=0
          
              #print('Voltage: '+ str(volt))
          
              valor_ntu=str(valor_ntu)
          
          
          
              limite_ntu=len(valor_ntu)
          
              #print(valor_ntu)
          
              while  alto <= limite_ntu:
          
          
          
                  digito_ntu = valor_ntu[bajo:alto]
          
                  if digito_ntu.isdigit():
          
                      ntu = (ntu + digito_ntu)
          
                  elif digito_ntu == '.':
          
                      ntu = (ntu + digito_ntu)
          
                      #break
          
                  bajo +=1
          
                  alto +=1
          
          
          
              bajo = 0
          
              alto = 1
          
          
          
          #---------------Midiendo EC, TDS, Salinidad-------------------
          
              v=uart.read()
          
              #print('Tipo de dato: ' + str(type(y)))
          
              W = str(v)
          
              limite = len(W)
          
          
          
          
          
              #print(limite)
          
          
          
              for i in W:
          
                  if str(i)=="r":
          
                      break
          
                  #print(i)
          
                  w=(w +str(i))
          
          
          
          #    while  alto <= limite:
          
                  #digito = w[bajo:alto]
          
              #    if digito=="r":
          
                  #    break
          
                  #else:
          
                  #    AtlasD = (AtlasD + digito)
          
                  #bajo +=1
          
                  #alto +=1
          
              #bajo = 0
          
              #alto = 1
          
              #limite=len(AtlasD)
          
              #print(w)
          
              limite=len(w)
          
              #print(limite)
          
              if limite>6:
          
                  while  alto <= limite:
          
                      #print("error")
          
                      digito = w[bajo:alto]
          
                      if digito.isdigit():
          
                          EC = (EC + digito)
          
                      elif digito=='.':
          
                          EC = (EC + digito)
          
                      elif digito==',':
          
                          bajo=alto
          
                          alto=bajo + 1
          
                          while alto<=limite:
          
                              digito =w[bajo:alto]
          
                              if digito.isdigit():
          
                                  TDS =  (TDS + digito)
          
                              elif digito=='.':
          
                                  TDS = (TDS + digito)
          
                              elif digito==',':
          
                                  bajo=alto
          
                                  alto=bajo+1
          
                                  while alto<=limite:
          
                                      digito=w[bajo:alto]
          
                                      if digito.isdigit():
          
                                          Sal = (Sal + digito)
          
                                      elif digito=='.':
          
                                          Sal = (Sal + digito)
          
          
          
                                      bajo +=1
          
                                      alto +=1
          
                              bajo +=1
          
                              alto +=1
          
                      bajo +=1
          
                      alto +=1
          
          
          
              #contador += 1
          
              #print(contador)
          
              #print(EC)
          
          
          
                  bajo = 0
          
                  alto = 1
          
          
          
          #-----------------Miediendo la temperatura---------------------
          
              #T = temp.read_temp_async()
          
          
          
          
          
              while  alto <= limite_T and C<=4:
          
          
          
                  digito_T = valor_T[bajo:alto]
          
                  if digito_T.isdigit():
          
                      T = (T + digito_T)
          
                  elif digito_T=='.':
          
                      T = (T + digito_T)
          
                  bajo +=1
          
                  alto +=1
          
                  C+=1
          
              bajo = 0
          
              alto = 1
          
              C=0
          
              T=T[0:5]
          
              #print("T: "+ T)
          
              limiteEC = len(str(EC))
          
              limiteTDS = len(str(TDS))
          
              limiteSal = len(str(Sal))
          
              print('Sensores: ' + EC + "---" +TDS+ "---" + Sal+ "---" + T+ "---" + ntu+ "---" + pH)
          
              #print(EC)
          
              if EC!= '' and TDS!='' and Sal!='':
          
                  #if limiteEC <=7 and limiteTDS<=7 and limiteSal<=4:
          
          
          
          
          
                  T=str(T)
          
                  ntu=str(ntu)
          
          
          
          
          
                  print('------------------------------------------------------------------------------------------------------')
          
                      #print('Datos totales: ' + w)
          
                      #print('EC: ' + EC)
          
                      #print('TDS: ' + TDS)
          
                      #print('Sal: ' + Sal)
          
                      #print('Temperatura: ' + T)
          
                      #print('NTU: ' + ntu)
          
                      #print("pH: "+ pH)
          
                      #print("valor_ph: "+ valor_ph)
          
                      #print(len(valor_ph))
          
          
          
                      #print(type(pH))
          
                  print('contador: '+ str(contador))
          
                      #print('pH: ' + pH)
          
                      #print(valor_ph)
          
                  pycom.rgbled(0x006600) # Azul cielo
          
                  time.sleep(0.5)
          
                  pycom.rgbled(0x000000) # Azul Marino
          
                  time.sleep(0.5)
          
                  contador+=1
          
                      
          
          
          
          
          
          
          
                  Sensor1=EC
          
                  
          
                  Sensor2=TDS
          
               
          
                  Sensor3=Sal
          
                 
          
                  Sensor4=T
          
                 
          
                  Sensor5=ntu
          
                       
          
                  Sensor6=pH
          
                     
          
          
          
                  
                 
          
          
          
              w=''
          
              EC = ''
          
              TDS = ''
          
              Sal = ''
          
              pH= ''
          
              T=''
          
              ntu=''
          
          
          
          p_out.hold (False)
          
          p_out.value(0)
          
          p_out.hold (True)
          
          
          
          
          
          sd = SD()
          
          os.mount(sd, '/sd')
          
        
          
          C=os.listdir('/sd')
          
          print('Archivos dentro de la memoria: ' + str(C))  # imprime lo que tiene la memoria guardado.
          
         
          
          CL=len(C) #cantidad de archivos guardados en la memoria
          
          print('Numero de archivos encontrados: ' +str(CL))
          
          #time.sleep(1)
          
          if CL>0:
          
              Ci=1
          
              E=0
          
              D=''
          
              IDD=''
          
              D1=''
          
              D2=''
          
          
          
              while Ci<=CL:
          
                                  
         
                  D=C[E]
          
                  Dlon=len(D)
          
          
          
          
          
                  IDD=D[0:4] #identificardor de datos en cada archivo
          
                  if IDD=='hora':
          
                      D1=D
          
                      print('hora encontrada en memoria microSD: ' +str(D1))
          
                      
          
                  elif IDD=='coo0':
          
                      D2=D
          
                      print('No se enviaron las coordenadas: ' + str(D2))
          
                      
          
                  elif IDD=='coo1':
          
                      D2=D
          
                      print('Ya se enviaron las coordenadas: ' + str(D2))
          
                     
          
                  else:
          
                      print('Archivo ' + str(IDD) + ' no identificado...A')
          
                     
          
          
          
                  Ci+=1
          
                  E+=1
          
          
          
              if D1=='':
          
                  D1='hora1'
          
              if D2=='':
          
                  D2='coo0'
          
          
          
              pycom.rgbled(0xFFCCCC) # Rojo
          
              os.fsformat('/sd')
          
              pycom.rgbled(0x000000) # Rojo
          
              print('memoria con datos')
          
          
          
          
          else:
          
              print('memoria vacia')
          
         
          
              D1='hora1'
          
              D2='coo0'
          
        
          
          
          
              print('Hora: '+ str(D1))
          
              print('Coor: '+ str(D2))
          
              D1L=len(D1)
          
          
          
          D1=D1[4:]
          
          D1=int(D1)
          
          #d1=D1
          
          
          
          D2=D2[3:]
          
          D2=int(D2)
          
      
                          
          
      
          
          
          
          if D1<=12:
          
              D1+=1
          
          
          
          if D1>12:
          
              D1=1
          
              D2=0
          
          
          
          #else:
          
              #Latitud=""    #conseguir las coordenadas rapido
          
              #Longitud=""
          
          
          
          if Latitud!= ""  and Longitud != "":  #conseguir las coordenadas rapido
          
              E2=1
          
          
          
              print('Guardando el siguiente valor de hora:  ' + str(D1))
          
              print('Guardando el siguiente valor de coor:  ' + str(E2))
          
              d1=('hora' + str(D1))
          
              d2=('coo' + str(E2))
          
              f = open('/sd/'+ d1, 'a')
          
              f = open('/sd/'+ d2, 'a')
          
              C=os.listdir('/sd')
          
              #time.sleep(1)
          
              f.close()
          
              print('Completado... ' + str(C) )
          
              time.sleep(3)
          
          else:
          
              print('Guardando el siguiente valor de hora:  ' + str(D1))
          
              print('Guardando el siguiente valor de coor:  ' + str(D2))
          
              d1=('hora' + str(D1))
          
              d2=('coo' + str(D2))
          
              f = open('/sd/'+ d1, 'a')
          
              f = open('/sd/'+ d2, 'a')
          
              C=os.listdir('/sd')
          
              #time.sleep(1)
          
              f.close()
          
              print('Completado... ' + str(C) )
          
              time.sleep(3)
          
          
          
          #..............................
          
          while True:
          
          
          
              Paquetes = []
          
              if D2==0 and Latitud== ""  and Longitud == "":
          
                  Paquetes.append(Sensor1)
          
                  Paquetes.append(Sensor4)
          
                  Paquetes.append(Sensor5)
          
                  Paquetes.append(Sensor6)
          
              if D2==0 and Latitud!= ""  and Longitud != "":
          
                  Paquetes.append(Sensor1)
          
                  Paquetes.append(Sensor4)
          
                  Paquetes.append(Sensor5)
          
                  Paquetes.append(Sensor6)
          
                  Paquetes.append(Latitud)
          
                  Paquetes.append(Longitud)
          
          
          
              if D2==1 and Latitud != ""  and Longitud != "":
          
          
          
                  Paquetes.append(Sensor1)
          
                  Paquetes.append(Sensor4)
          
                  Paquetes.append(Sensor5)
          
                  Paquetes.append(Sensor6)
          
          
          
              if D2==1 and Latitud == ""  and Longitud == "":
          
          
          
                  Paquetes.append(Sensor1)
          
                  Paquetes.append(Sensor4)
          
                  Paquetes.append(Sensor5)
          
                  Paquetes.append(Sensor6)
          
                  
          
              print('Paquetes: ' + str(Paquetes))
          
              for i in Paquetes:
          
                  if i!='':
          
          
          
                      inicio = 0
          
                      fin = 1
          
                      key = b'Radikalsystems!!' # 128 bit (16 bytes) key
          
                      #iv = crypto.getrandbits(128) # hardware generated random IV (never reuse it)
          
                      cipher = AES(key, AES.MODE_ECB)  #ECB/CFB
          
                      mensaje=i
          
                      LonM=len(mensaje)
          
                      #print(Sensores6)
          
                      #print(LonM)
          
                      if LonM<16:
          
                          mensaje = (mensaje+ '/')
          
                          while LonM<16:
          
                              mensaje= (mensaje + mensaje[inicio:fin])
          
                              inicio+=1
          
                              fin+=1
          
                              #print(mensaje)
          
                              LonM=len(mensaje)
          
                              #print(len(mensaje))
          
                              #time.sleep(1)
          
                          inicio=0
          
                          fin=1
          
                      #print(mensaje)
          
                      #print(len(mensaje))
          
                      msg =cipher.encrypt(mensaje)
          
                      hex_bytes=ubinascii.hexlify(msg)
          
                      #print(hex_bytes)
          
                      hex_str=hex_bytes.decode("ascii")
          
                      #print(hex_str)
          
                      LM=len(hex_str)
          
                      #print(LM)
          
          
          
                      Count=2
          
                      inicio=0
          
                      fin=2
          
                      NP=1  #Numero del paquete=NP
          
                      while Count <=LM:
          
          
          
                          Cint=1
          
                          paquete=[]
          
                          paquete.append(NP)  #NP=numero de paquete 1 ó 2
          
                          if len(Paquetes)>4:
          
                              P5=Paquetes[5]
          
                              P4=Paquetes[4]
          
                              if i == P5:
          
                                  paquete.append(49)  #Numero de versión
          
          
          
                                  paquete.append(111)  # 111=o  Longitud  6F  hex
          
                              if i == P4:
          
                                  paquete.append(49)  #Numero de versión
          
          
          
                                  paquete.append(97)  # 97=a   Latitud    61 hex
          
                              color=0
          
                          P3=Paquetes[3]
          
                          P2=Paquetes[2]
          
                          P1=Paquetes[1]
          
                          P0=Paquetes[0]
          
                          color=1
          
          
          
          
          
                          if i == P3:
          
                              paquete.append(49)  #Numero de versión
          
          
          
                              paquete.append(112)  #112=p    pH  70 hex
          
                          if i == P2:
          
                              paquete.append(49)  #Numero de versión
          
          
          
                              paquete.append(110)  #110=n     ntc  6E hex
          
                          if i == P1:
          
                              paquete.append(49)  #Numero de versión
          
          
          
                              paquete.append(84)  #84=T   Temperatura  54 hex
          
                          if i == P0:
          
                              paquete.append(49)  #Numero de versión
          
          
          
                              paquete.append(69)  #69=E  Conductividad   45 hex
          
          
          
                          print('Agregando identificadores: ' + str(paquete))
          
                          time.sleep(1)
          
                          while Cint<=8:  #8 son los esapcios que quedan disponibles para los datos dentro de los 12 bytes los primeros 4 bytes son identificadores Version/Sensor o corrdenadas/clave del sensro/num. de paquete.
          
          
          
                              #print('Hex: '+Hex[inicio:fin])
          
                              mensaje = (hex_str[inicio:fin])
          
                              Dec = int("0x"+mensaje, 16)
          
                              paquete.append(int((Dec)))
          
                              #print('Dec: '+ str(Dec))
          
                              #print(len(mensaje))
          
                              #print(" ")
          
                              inicio+=2
          
                              fin+=2
          
                              Cint+=1
          
                              Count+=2
          
                              #time.sleep(1)
          
                              if inicio>=LM:
          
                                  break
          
                          # init Sigfox for RCZ2 (Mexico)
          
                          sigfox = Sigfox(mode=Sigfox.SIGFOX, rcz=Sigfox.RCZ2)
          
                          # create a Sigfox socket
          
                          s = socket.socket(socket.AF_SIGFOX, socket.SOCK_RAW)
          
                          # make the socket blocking
          
                          s.setblocking(True)
          
                          # configure it as uplink only
          
                          s.setsockopt(socket.SOL_SIGFOX, socket.SO_RX, False)
          
          
          
                          s.send(bytes(paquete))
          
                          print('Datos enviados a Sigfox: '+ str(paquete))
          
                          NP=int(NP)
          
                          NP+=1 # NP= Numero de Paquete
          
                          if color==1:
          
                              pycom.rgbled(0x109DFA) # Azul cielo                                   #
          
                              time.sleep(4)
          
                              pycom.rgbled(0x024A86) # Azul Marino
          
                              time.sleep(4)
          
                              pycom.rgbled(0x109DFA) # Azul cielo
          
                              time.sleep(4)
          
                              pycom.rgbled(0x024A86) # Azul Marino
          
                              time.sleep(4)
          
                              pycom.rgbled(0x996633) # Amarillo oscuro
          
                              time.sleep(10)
          
                              pycom.rgbled(0x000000) # apagado
          
                          if color==0:
          
                              pycom.rgbled(0x660066) # Morado                               #
          
                              time.sleep(5)
          
                              pycom.rgbled(0x000000) # apagado
          
                              time.sleep(5)
          
                              pycom.rgbled(0x660066) # Morado
          
                              time.sleep(5)
          
                              pycom.rgbled(0x996633) # amarillo oscuro
          
                              time.sleep(11)
          
                              pycom.rgbled(0x000000) # apagado
          
          
          
                  else:
          
                      print('no se encontro el dato del sensor')
          
          
          
          
          
              print('Sueño profundo')
          
              machine.deepsleep (6926000)  # 7,200,000 = 2 horas  #25000 25 Segundos
      
      1 Reply Last reply Reply Quote 0
      • G Offline
        Gijs
        last edited by

        @Erick-Falcon said in Fipy freezes after two or three days. Using pytrack, Sigfox and DeepSleep:

        import time
        import machine
        from machine import Pin
        from onewire import DS18X20
        from onewire import OneWire

        from machine import UART
        
        from machine import ADC
        
        import math
        
        from network import Sigfox
        
        import socket
        
        import pycom
        
        import network
        
        import os
        
        import utime
        
        import gc
        
        from machine import RTC
        
        from machine import SD
        
        from L76GNSS import L76GNSS
        
        from pytrack import Pytrack
        
        from network import Sigfox
        
        import socket
        
        from crypto import AES
        
        import crypto
        
        import ubinascii
        
        from machine import SD
        
        
        
        pycom.heartbeat(False)
        
        #machine.reset()
        
        p_out = Pin('P9', mode=Pin.OUT)
        
        p_out.hold (False)
        
        p_out.value(0)
        
        p_out.hold (True)
        
        
        
        
        
        
        
        CountT=0
        
        ow = OneWire(Pin('P3'))
        
        temp = DS18X20(ow)
        
        while CountT<=5:
        
            DS18X20.start_conversion(temp)
        
            #time.sleep(1)
        
            #print(DS18X20.read_temp_async(temp))
        
            time.sleep(0.2)
        
            valor_T=str(DS18X20.read_temp_async(temp))
        
        
        
            limite_T=len(valor_T)
        
            #print("Temperatura: "+valor_T)
        
            #print("Temperatura: "+valor_T)
        
            CountT+=1
        
        #<------------Aqui va el codigo de micro sd
        
        
        
        py = Pytrack()
        
        l76 = L76GNSS(py, timeout=30)
        
        
        
        
        
        
        
        #..............................
        
        contador=0
        
        C=""
        
        Coordenadas=""
        
        Latitud=""
        
        Longitud=""
        
        contador=0
        
        #Pines: P10(TX)->RX(Verde) P11(RX)->TX(Azul) (EC,S,TDS) P3=Temperatura  P16->pH  P17-> Turbiedad  P8->Transistores
        
        # DS18B20 data line connected to pin P10
        
        #Objetos para el sensor de temperatura
        
        
        
        #-----------------------------------------------------------
        
        #Objetos para el sensor de Conducitvidad Altas Scientific
        
        uart = UART(1,9600,pins=('P10','P11'))#uart=UART(baudrate=9600,pins=('P12','P11'))# #P3=TX P4=RX
        
        #uart.init(9600, bits=8, parity=None, stop=1,)
        
        
        
        bajo = 0
        
        alto = 1
        
        w=''
        
        
        
        EC = ''
        
        TDS = ''
        
        Sal = ''
        
        pH = ''
        
        ntu = ''
        
        Condicion = True
        
        C=0
        
        T = ''
        
        
        
        
        
        #PM=Primer Mensaje
        
        #------------------------------------------------------------
        
        
        
        
        
        while contador<=5:
        
        
        
            p_out.hold (False)
        
            p_out.value(1)
        
            p_out.hold (True)
        
        
        
            coord = l76.coordinates()
        
            #f.write("{} - {}\n".format(coord, rtc.now()))
        
            COORD="{}".format(coord)
        
            #print( COORD + str(contador))
        
            if COORD!="(None, None)":
        
        
        
                Coordenadas= "{}".format(coord)
        
        
        
                pycom.rgbled(0xFFCC00) # Amarillo                                 #
        
                time.sleep(1)
        
                pycom.rgbled(0x000000) # Apagado
        
        
        
                if Coordenadas!="":
        
                    if PM==1:
        
                        LC=len(Coordenadas)
        
                        #print(C)
        
                        while  alto <= LC:
        
                            digito = Coordenadas[bajo:alto]
        
                            if digito.isdigit():
        
                                Latitud = (Latitud + digito)
        
                            elif digito=="-":
        
                                Latitud = (Latitud + digito)
        
                            elif digito==".":
        
                                Latitud = (Latitud + digito)
        
                            elif digito==",":
        
                                bajo=alto
        
                                alto=bajo + 1
        
                                while alto <= LC:
        
                                    digito = Coordenadas[bajo:alto]
        
                                    if digito.isdigit():
        
                                        Longitud = (Longitud + digito)
        
                                    elif digito=="-":
        
                                        Longitud = (Longitud + digito)
        
                                    elif digito==".":
        
                                        Longitud = (Longitud + digito)
        
                                    elif digito==")":
        
                                        break
        
                                    bajo +=1
        
                                    alto +=1
        
                                break
        
                            bajo +=1
        
                            alto +=1
        
                        bajo=0
        
                        alto=1
        
        
        
        
        
                        #mensaje2=('Lat'+Latitud+'Lon'+Longitud)
        
                        #LonM=len(mensaje2)
        
                        #print(LonM)
        
                else:
        
                    pycom.rgbled(0xCC0000) # Rojo                                   #
        
                    time.sleep(1)
        
                    pycom.rgbled(0x000000) # Azul Marino
        
        
        
        #-------------Midiento el pH-----------------
        
        
        
        
        
            x=0
        
            a = []
        
        
        
            while x<100:
        
                x+=1
        
                adc = ADC()
        
                # Set calibration - see note above
        
                adc.vref(1093)
        
                # Check calibration by reading a known voltage
        
                adc_c = adc.channel(pin='P16', attn=ADC.ATTN_11DB)
        
                #print(adc_c.voltage())
        
                a.append(adc_c.voltage())
        
                #print(a)
        
                #print(x)
        
                promediopH = sum(a)/100
        
            #print(int(promedio))
        
        
        
            m = 3/218
        
            b = -2416/218
        
        
        
            valor_ph = (promediopH*m)+b
        
            #valor_pH=valor_pH+0.35
        
        
        
            valor_ph=str(valor_ph)
        
            limite_ph=len(valor_ph)
        
        
        
            while  alto<= limite_ph and C<=4:
        
        
        
                digito_ph = valor_ph[bajo:alto]
        
                if digito_ph.isdigit():
        
                    pH = (pH + digito_ph)
        
                elif digito_ph=='.':
        
                    pH = (pH + digito_ph)
        
                    bajo=alto
        
                    alto=bajo + 1
        
                    while alto<=limite_ph and C<=4:
        
                        digito_ph = valor_ph[bajo:alto]
        
                        if digito_ph.isdigit():
        
                            pH =  (pH + digito_ph)
        
        
        
                        bajo +=1
        
                        alto +=1
        
                        C+=1
        
                bajo +=1
        
                alto +=1
        
            bajo = 0
        
            alto = 1
        
            C=0
        
        #-----------------Midiento la Turbiedad---------------------
        
            y=0
        
            b = []
        
            while y<100:
        
                y+=1
        
                adc = ADC()
        
                # Set calibration - see note above
        
                adc.vref(1093)
        
                # Check calibration by reading a known voltage
        
                adc_c = adc.channel(pin='P17', attn=ADC.ATTN_11DB)
        
                #print(adc_c.voltage())
        
                b.append(adc_c.voltage())
        
                #print(a)
        
                #print(x)
        
                promedioTur = sum(b)/100
        
                volt=promedioTur/1000
        
                volt = volt + 1.145
        
            volt=float(volt)
        
            RaizCuadradaV = math.pow(volt,2)
        
            if volt < 2.5:
        
                valor_ntu=3000
        
            else:
        
                valor_ntu=-1120.4*RaizCuadradaV +5742.3*(volt)-4352.8
        
            if valor_ntu <0:
        
                valor_ntu=0
        
            #print('Voltage: '+ str(volt))
        
            valor_ntu=str(valor_ntu)
        
        
        
            limite_ntu=len(valor_ntu)
        
            #print(valor_ntu)
        
            while  alto <= limite_ntu:
        
        
        
                digito_ntu = valor_ntu[bajo:alto]
        
                if digito_ntu.isdigit():
        
                    ntu = (ntu + digito_ntu)
        
                elif digito_ntu == '.':
        
                    ntu = (ntu + digito_ntu)
        
                    #break
        
                bajo +=1
        
                alto +=1
        
        
        
            bajo = 0
        
            alto = 1
        
        
        
        #---------------Midiendo EC, TDS, Salinidad-------------------
        
            v=uart.read()
        
            #print('Tipo de dato: ' + str(type(y)))
        
            W = str(v)
        
            limite = len(W)
        
        
        
        
        
            #print(limite)
        
        
        
            for i in W:
        
                if str(i)=="r":
        
                    break
        
                #print(i)
        
                w=(w +str(i))
        
        
        
        #    while  alto <= limite:
        
                #digito = w[bajo:alto]
        
            #    if digito=="r":
        
                #    break
        
                #else:
        
                #    AtlasD = (AtlasD + digito)
        
                #bajo +=1
        
                #alto +=1
        
            #bajo = 0
        
            #alto = 1
        
            #limite=len(AtlasD)
        
            #print(w)
        
            limite=len(w)
        
            #print(limite)
        
            if limite>6:
        
                while  alto <= limite:
        
                    #print("error")
        
                    digito = w[bajo:alto]
        
                    if digito.isdigit():
        
                        EC = (EC + digito)
        
                    elif digito=='.':
        
                        EC = (EC + digito)
        
                    elif digito==',':
        
                        bajo=alto
        
                        alto=bajo + 1
        
                        while alto<=limite:
        
                            digito =w[bajo:alto]
        
                            if digito.isdigit():
        
                                TDS =  (TDS + digito)
        
                            elif digito=='.':
        
                                TDS = (TDS + digito)
        
                            elif digito==',':
        
                                bajo=alto
        
                                alto=bajo+1
        
                                while alto<=limite:
        
                                    digito=w[bajo:alto]
        
                                    if digito.isdigit():
        
                                        Sal = (Sal + digito)
        
                                    elif digito=='.':
        
                                        Sal = (Sal + digito)
        
        
        
                                    bajo +=1
        
                                    alto +=1
        
                            bajo +=1
        
                            alto +=1
        
                    bajo +=1
        
                    alto +=1
        
        
        
            #contador += 1
        
            #print(contador)
        
            #print(EC)
        
        
        
                bajo = 0
        
                alto = 1
        
        
        
        #-----------------Miediendo la temperatura---------------------
        
            #T = temp.read_temp_async()
        
        
        
        
        
            while  alto <= limite_T and C<=4:
        
        
        
                digito_T = valor_T[bajo:alto]
        
                if digito_T.isdigit():
        
                    T = (T + digito_T)
        
                elif digito_T=='.':
        
                    T = (T + digito_T)
        
                bajo +=1
        
                alto +=1
        
                C+=1
        
            bajo = 0
        
            alto = 1
        
            C=0
        
            T=T[0:5]
        
            #print("T: "+ T)
        
            limiteEC = len(str(EC))
        
            limiteTDS = len(str(TDS))
        
            limiteSal = len(str(Sal))
        
            print('Sensores: ' + EC + "---" +TDS+ "---" + Sal+ "---" + T+ "---" + ntu+ "---" + pH)
        
            #print(EC)
        
            if EC!= '' and TDS!='' and Sal!='':
        
                #if limiteEC <=7 and limiteTDS<=7 and limiteSal<=4:
        
        
        
        
        
                T=str(T)
        
                ntu=str(ntu)
        
        
        
        
        
                print('------------------------------------------------------------------------------------------------------')
        
                    #print('Datos totales: ' + w)
        
                    #print('EC: ' + EC)
        
                    #print('TDS: ' + TDS)
        
                    #print('Sal: ' + Sal)
        
                    #print('Temperatura: ' + T)
        
                    #print('NTU: ' + ntu)
        
                    #print("pH: "+ pH)
        
                    #print("valor_ph: "+ valor_ph)
        
                    #print(len(valor_ph))
        
        
        
                    #print(type(pH))
        
                print('contador: '+ str(contador))
        
                    #print('pH: ' + pH)
        
                    #print(valor_ph)
        
                pycom.rgbled(0x006600) # Azul cielo
        
                time.sleep(0.5)
        
                pycom.rgbled(0x000000) # Azul Marino
        
                time.sleep(0.5)
        
                contador+=1
        
                    
        
        
        
        
        
        
        
                Sensor1=EC
        
                
        
                Sensor2=TDS
        
             
        
                Sensor3=Sal
        
               
        
                Sensor4=T
        
               
        
                Sensor5=ntu
        
                     
        
                Sensor6=pH
        
                   
        
        
        
                
               
        
        
        
            w=''
        
            EC = ''
        
            TDS = ''
        
            Sal = ''
        
            pH= ''
        
            T=''
        
            ntu=''
        
        
        
        p_out.hold (False)
        
        p_out.value(0)
        
        p_out.hold (True)
        
        
        
        
        
        sd = SD()
        
        os.mount(sd, '/sd')
        
        
        
        C=os.listdir('/sd')
        
        print('Archivos dentro de la memoria: ' + str(C))  # imprime lo que tiene la memoria guardado.
        
        
        
        CL=len(C) #cantidad de archivos guardados en la memoria
        
        print('Numero de archivos encontrados: ' +str(CL))
        
        #time.sleep(1)
        
        if CL>0:
        
            Ci=1
        
            E=0
        
            D=''
        
            IDD=''
        
            D1=''
        
            D2=''
        
        
        
            while Ci<=CL:
        
                                
        
                D=C[E]
        
                Dlon=len(D)
        
        
        
        
        
                IDD=D[0:4] #identificardor de datos en cada archivo
        
                if IDD=='hora':
        
                    D1=D
        
                    print('hora encontrada en memoria microSD: ' +str(D1))
        
                    
        
                elif IDD=='coo0':
        
                    D2=D
        
                    print('No se enviaron las coordenadas: ' + str(D2))
        
                    
        
                elif IDD=='coo1':
        
                    D2=D
        
                    print('Ya se enviaron las coordenadas: ' + str(D2))
        
                   
        
                else:
        
                    print('Archivo ' + str(IDD) + ' no identificado...A')
        
                   
        
        
        
                Ci+=1
        
                E+=1
        
        
        
            if D1=='':
        
                D1='hora1'
        
            if D2=='':
        
                D2='coo0'
        
        
        
            pycom.rgbled(0xFFCCCC) # Rojo
        
            os.fsformat('/sd')
        
            pycom.rgbled(0x000000) # Rojo
        
            print('memoria con datos')
        
        
        
        
        else:
        
            print('memoria vacia')
        
        
        
            D1='hora1'
        
            D2='coo0'
        
        
        
        
        
            print('Hora: '+ str(D1))
        
            print('Coor: '+ str(D2))
        
            D1L=len(D1)
        
        
        
        D1=D1[4:]
        
        D1=int(D1)
        
        #d1=D1
        
        
        
        D2=D2[3:]
        
        D2=int(D2)
        
        
                        
        
        
        
        
        
        if D1<=12:
        
            D1+=1
        
        
        
        if D1>12:
        
            D1=1
        
            D2=0
        
        
        
        #else:
        
            #Latitud=""    #conseguir las coordenadas rapido
        
            #Longitud=""
        
        
        
        if Latitud!= ""  and Longitud != "":  #conseguir las coordenadas rapido
        
            E2=1
        
        
        
            print('Guardando el siguiente valor de hora:  ' + str(D1))
        
            print('Guardando el siguiente valor de coor:  ' + str(E2))
        
            d1=('hora' + str(D1))
        
            d2=('coo' + str(E2))
        
            f = open('/sd/'+ d1, 'a')
        
            f = open('/sd/'+ d2, 'a')
        
            C=os.listdir('/sd')
        
            #time.sleep(1)
        
            f.close()
        
            print('Completado... ' + str(C) )
        
            time.sleep(3)
        
        else:
        
            print('Guardando el siguiente valor de hora:  ' + str(D1))
        
            print('Guardando el siguiente valor de coor:  ' + str(D2))
        
            d1=('hora' + str(D1))
        
            d2=('coo' + str(D2))
        
            f = open('/sd/'+ d1, 'a')
        
            f = open('/sd/'+ d2, 'a')
        
            C=os.listdir('/sd')
        
            #time.sleep(1)
        
            f.close()
        
            print('Completado... ' + str(C) )
        
            time.sleep(3)
        
        
        
        #..............................
        
        while True:
        
        
        
            Paquetes = []
        
            if D2==0 and Latitud== ""  and Longitud == "":
        
                Paquetes.append(Sensor1)
        
                Paquetes.append(Sensor4)
        
                Paquetes.append(Sensor5)
        
                Paquetes.append(Sensor6)
        
            if D2==0 and Latitud!= ""  and Longitud != "":
        
                Paquetes.append(Sensor1)
        
                Paquetes.append(Sensor4)
        
                Paquetes.append(Sensor5)
        
                Paquetes.append(Sensor6)
        
                Paquetes.append(Latitud)
        
                Paquetes.append(Longitud)
        
        
        
            if D2==1 and Latitud != ""  and Longitud != "":
        
        
        
                Paquetes.append(Sensor1)
        
                Paquetes.append(Sensor4)
        
                Paquetes.append(Sensor5)
        
                Paquetes.append(Sensor6)
        
        
        
            if D2==1 and Latitud == ""  and Longitud == "":
        
        
        
                Paquetes.append(Sensor1)
        
                Paquetes.append(Sensor4)
        
                Paquetes.append(Sensor5)
        
                Paquetes.append(Sensor6)
        
                
        
            print('Paquetes: ' + str(Paquetes))
        
            for i in Paquetes:
        
                if i!='':
        
        
        
                    inicio = 0
        
                    fin = 1
        
                    key = b'Radikalsystems!!' # 128 bit (16 bytes) key
        
                    #iv = crypto.getrandbits(128) # hardware generated random IV (never reuse it)
        
                    cipher = AES(key, AES.MODE_ECB)  #ECB/CFB
        
                    mensaje=i
        
                    LonM=len(mensaje)
        
                    #print(Sensores6)
        
                    #print(LonM)
        
                    if LonM<16:
        
                        mensaje = (mensaje+ '/')
        
                        while LonM<16:
        
                            mensaje= (mensaje + mensaje[inicio:fin])
        
                            inicio+=1
        
                            fin+=1
        
                            #print(mensaje)
        
                            LonM=len(mensaje)
        
                            #print(len(mensaje))
        
                            #time.sleep(1)
        
                        inicio=0
        
                        fin=1
        
                    #print(mensaje)
        
                    #print(len(mensaje))
        
                    msg =cipher.encrypt(mensaje)
        
                    hex_bytes=ubinascii.hexlify(msg)
        
                    #print(hex_bytes)
        
                    hex_str=hex_bytes.decode("ascii")
        
                    #print(hex_str)
        
                    LM=len(hex_str)
        
                    #print(LM)
        
        
        
                    Count=2
        
                    inicio=0
        
                    fin=2
        
                    NP=1  #Numero del paquete=NP
        
                    while Count <=LM:
        
        
        
                        Cint=1
        
                        paquete=[]
        
                        paquete.append(NP)  #NP=numero de paquete 1 ó 2
        
                        if len(Paquetes)>4:
        
                            P5=Paquetes[5]
        
                            P4=Paquetes[4]
        
                            if i == P5:
        
                                paquete.append(49)  #Numero de versión
        
        
        
                                paquete.append(111)  # 111=o  Longitud  6F  hex
        
                            if i == P4:
        
                                paquete.append(49)  #Numero de versión
        
        
        
                                paquete.append(97)  # 97=a   Latitud    61 hex
        
                            color=0
        
                        P3=Paquetes[3]
        
                        P2=Paquetes[2]
        
                        P1=Paquetes[1]
        
                        P0=Paquetes[0]
        
                        color=1
        
        
        
        
        
                        if i == P3:
        
                            paquete.append(49)  #Numero de versión
        
        
        
                            paquete.append(112)  #112=p    pH  70 hex
        
                        if i == P2:
        
                            paquete.append(49)  #Numero de versión
        
        
        
                            paquete.append(110)  #110=n     ntc  6E hex
        
                        if i == P1:
        
                            paquete.append(49)  #Numero de versión
        
        
        
                            paquete.append(84)  #84=T   Temperatura  54 hex
        
                        if i == P0:
        
                            paquete.append(49)  #Numero de versión
        
        
        
                            paquete.append(69)  #69=E  Conductividad   45 hex
        
        
        
                        print('Agregando identificadores: ' + str(paquete))
        
                        time.sleep(1)
        
                        while Cint<=8:  #8 son los esapcios que quedan disponibles para los datos dentro de los 12 bytes los primeros 4 bytes son identificadores Version/Sensor o corrdenadas/clave del sensro/num. de paquete.
        
        
        
                            #print('Hex: '+Hex[inicio:fin])
        
                            mensaje = (hex_str[inicio:fin])
        
                            Dec = int("0x"+mensaje, 16)
        
                            paquete.append(int((Dec)))
        
                            #print('Dec: '+ str(Dec))
        
                            #print(len(mensaje))
        
                            #print(" ")
        
                            inicio+=2
        
                            fin+=2
        
                            Cint+=1
        
                            Count+=2
        
                            #time.sleep(1)
        
                            if inicio>=LM:
        
                                break
        
                        # init Sigfox for RCZ2 (Mexico)
        
                        sigfox = Sigfox(mode=Sigfox.SIGFOX, rcz=Sigfox.RCZ2)
        
                        # create a Sigfox socket
        
                        s = socket.socket(socket.AF_SIGFOX, socket.SOCK_RAW)
        
                        # make the socket blocking
        
                        s.setblocking(True)
        
                        # configure it as uplink only
        
                        s.setsockopt(socket.SOL_SIGFOX, socket.SO_RX, False)
        
        
        
                        s.send(bytes(paquete))
        
                        print('Datos enviados a Sigfox: '+ str(paquete))
        
                        NP=int(NP)
        
                        NP+=1 # NP= Numero de Paquete
        
                        if color==1:
        
                            pycom.rgbled(0x109DFA) # Azul cielo                                   #
        
                            time.sleep(4)
        
                            pycom.rgbled(0x024A86) # Azul Marino
        
                            time.sleep(4)
        
                            pycom.rgbled(0x109DFA) # Azul cielo
        
                            time.sleep(4)
        
                            pycom.rgbled(0x024A86) # Azul Marino
        
                            time.sleep(4)
        
                            pycom.rgbled(0x996633) # Amarillo oscuro
        
                            time.sleep(10)
        
                            pycom.rgbled(0x000000) # apagado
        
                        if color==0:
        
                            pycom.rgbled(0x660066) # Morado                               #
        
                            time.sleep(5)
        
                            pycom.rgbled(0x000000) # apagado
        
                            time.sleep(5)
        
                            pycom.rgbled(0x660066) # Morado
        
                            time.sleep(5)
        
                            pycom.rgbled(0x996633) # amarillo oscuro
        
                            time.sleep(11)
        
                            pycom.rgbled(0x000000) # apagado
        
        
        
                else:
        
                    print('no se encontro el dato del sensor')
        
        
        
        
        
            print('Sueño profundo')
        
            machine.deepsleep (6926000)  # 7,200,000 = 2 horas  #25000 25 Segundos
        

        Hi,

        Based on what you are saying, did you upload the code to the device, or click run? After deepsleep, the code will re-enter at the top of boot.py and will continue to main.py. If both are empty, it will of course not continue. Do you have any information on why it crashes, coredumps or the like? Even after a crash, it should pick up the program at the top, disabling the heartbeat led. It could be the device running out of memory, or an issue with the sensor / GPS data that is not handled?

        I do not see any critical errors upon first look at your code.
        Let me know!

        E 1 Reply Last reply Reply Quote 0
        • E Offline
          Erick Falcon @Gijs
          last edited by

          @Gijs said in Fipy freezes after two or three days. Using pytrack, Sigfox and DeepSleep:

          Hi,
          Based on what you are saying, did you upload the code to the device, or click run? After deepsleep, the code will re-enter at the top of boot.py and will continue to main.py. If both are empty, it will of course not continue. Do you have any information on why it crashes, coredumps or the like? Even after a crash, it should pick up the program at the top, disabling the heartbeat led. It could be the device running out of memory, or an issue with the sensor / GPS data that is not handled?
          I do not see any critical errors upon first look at your code.
          Let me know!

          I uploaded the code to the device, it works fine for a while but after 1 or 3 days it stops. I think if I connect the device to atom I can find what error appears, I'm on it.
          I don't think that is a memory problem, but How can I find out how much memory is available?, Is there a command for this?

          1 Reply Last reply Reply Quote 0
          • E Offline
            Erick Falcon
            last edited by Erick Falcon

            @robert-hh @Gijs

                ets Jun  8 2016 00:22:57
                
                
                
                rst:0x5 (DEEPSLEEP_RESET),boot:0x16 (SPI_FAST_FLASH_BOOT)
                
                configsip: 0, SPIWP:0xee
                
                clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
                
                mode:DIO, clock div:1
                
                load:0x3fff8020,len:8
                
                load:0x3fff8028,len:2140
                
                ho 0 tail 12 room 4
                
                load:0x4009fa00,len:19760
                
                entry 0x400a05bc
                
                Smart Provisioning started in the background
                
                See https://docs.pycom.io/smart for details
                
                Sensores: ---------31.06---3000---17.48418
                
                Sensores: ---------31.06---3000---17.45638
                
                Sensores: 0.00---0---0.00---31.06---3000---17.45156
                
                ------------------------------------------------------------------------------------------------------
                
                contador: 0
                
                Sensores: 0.00---0---0.00---31.06---3000---17.4228
                
                ------------------------------------------------------------------------------------------------------
                
                contador: 1
                
                Sensores: 0.00---0---0.00---31.06---3000---17.42197
                
                ------------------------------------------------------------------------------------------------------
                
                contador: 2
                
                Sensores: 0.00---0---0.00---31.06---3000---17.37587
                
                ------------------------------------------------------------------------------------------------------
                
                contador: 3
                
                Sensores: 0.00---0---0.00---31.06---3000---17.48225
                
                ------------------------------------------------------------------------------------------------------
                
                contador: 4
                
                Sensores: 0.00---0---0.00---31.06---3000---17.48046
                
                ------------------------------------------------------------------------------------------------------
                
                contador: 5
                
                Archivos dentro de la memoria: ['hora11', 'coo0']
                
                Numero de archivos encontrados: 2
                
                hora encontrada en memoria microSD: hora11
                
                No se enviaron las coordenadas: coo0
                
                memoria con datos
                
                Guardando el siguiente valor de hora:  12
                
                Guardando el siguiente valor de coor:  0
                
                Completado... ['hora12', 'coo0']
                
                Paquetes: ['0.00', '31.06', '3000', '17.48225']
                
                Agregando identificadores: [1, 49, 69]
                
                Datos enviados a Sigfox: [1, 49, 69, 229, 52, 158, 216, 116, 125, 107, 255]
                
                Agregando identificadores: [2, 49, 69]
                
                Datos enviados a Sigfox: [2, 49, 69, 18, 130, 192, 181, 226, 181, 115, 181]
                
                Agregando identificadores: [1, 49, 84]
                
                Datos enviados a Sigfox: [1, 49, 84, 121, 242, 116, 52, 205, 151, 49, 213]
                
                Agregando identificadores: [2, 49, 84]
                
                Datos enviados a Sigfox: [2, 49, 84, 131, 137, 127, 8, 32, 106, 118, 118]
                
                Agregando identificadores: [1, 49, 110]
                
                Datos enviados a Sigfox: [1, 49, 110, 187, 79, 190, 41, 196, 83, 242, 241]
                
                Agregando identificadores: [2, 49, 110]
                
                Datos enviados a Sigfox: [2, 49, 110, 18, 252, 1, 239, 192, 2, 237, 55]
                
                Agregando identificadores: [1, 49, 112]
                
                Datos enviados a Sigfox: [1, 49, 112, 150, 109, 117, 142, 125, 166, 14, 43]
                
                Agregando identificadores: [2, 49, 112]
                
                Datos enviados a Sigfox: [2, 49, 112, 199, 127, 103, 215, 213, 228, 128, 71]
                
                Sueño profundo
            
            robert-hhR 1 Reply Last reply Reply Quote 0
            • robert-hhR Offline
              robert-hh @Erick Falcon
              last edited by

              @Erick-Falcon Two questions:

              • Is this log the good or the bad case?
              • Do you need pybytes? If not, you may try disabling it with:

              import pycom
              pycom.pybytes_on_boot(False)

              And then reboot. The setting is permanent. If that does not work, create a file on you device called pybytes_config.json and the content:
              {"pybytes_autostart": false}

              E 1 Reply Last reply Reply Quote 0
              • E Offline
                Erick Falcon @robert-hh
                last edited by Erick Falcon

                @robert-hh said in Fipy freezes after two or three days. Using pytrack, Sigfox and DeepSleep:

                @Erick-Falcon Two questions:

                Is this log the good or the bad case?
                Do you need pybytes? If not, you may try disabling it with:

                import pycom
                pycom.pybytes_on_boot(False)
                And then reboot. The setting is permanent. If that does not work, create a file on you device called pybytes_config.json and the content:

                • good case
                • I don´t need pybytes.
                1 Reply Last reply Reply Quote 0
                • G Offline
                  Gijs
                  last edited by

                  I thought of something, now Im not sure this could be it, but its worth trying:

                  • Try closing the socket after sending the data using s.close(), I believe there is no way to de-init the SigFox radio though.
                  • Update to the latest firmware
                    And indeed disable pybytes if it is enabled like @robert-hh suggested. It would indeed be interesting to see the log of a bad case.

                  Best

                  1 Reply Last reply Reply Quote 0

                  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