xreef / EByte_LoRa_E220_micropython_library

MicroPython LoRa EBYTE E220 LLCC68 device library complete and tested with Arduino, esp8266, esp32, STM32 and Raspberry Pi Pico (rp2040 boards).
https://www.mischianti.org/category/my-libraries/lora-e220-llcc68-devices/
Other
12 stars 1 forks source link

Data size not match... #2

Open londere opened 1 year ago

londere commented 1 year ago

Hello everyone, I'm using this library to employ several Lora devices, in this case the e220-400t22d.

However in several raspberry pico's, such as raspberry Pico x8, waveshare rp2040 plus X2 and even using the Raspberry Pi 3b X1 with the developed library.

In the function getconfiguration of your examples get the error:

Data size not match.

I'll appreciate if anyone had any idea to solve this issue.

In advance rhanks

xreef commented 1 year ago

Hi londere, that error becomes when no data is returned from the request, probably there is a wiring issue or power supply problem. Bye Renzo

londere commented 1 year ago

It works, also I want to tell you that the library works on the Nvidia Jetson, up to now only the channel selection did not work.

Greetings

xreef commented 1 year ago

Hi, thanks for the feedback, you say that the set configuration doesn't work? Bye Renzo

londere commented 1 year ago

Yeah, maybe the implementation is incorrect but only can work with one channel. Later in the weekend, I post a brief description of my project and the pinout and modifications made to the code to make it work in the Jetson.

xreef commented 1 year ago

Yes, thanks, so I can analyze the issue. Bye Renzo

londere commented 1 year ago

Hello Renzo, please find the code before mentioned

`import tkinter.ttk as ttk import tkinter as tk from tkinter import * from tkinter import filedialog, messagebox

import os import serial import sys import time

from datetime import datetime

import Jetson.GPIO as GPIO GPIO.setmode(GPIO.BCM)

from lora_e22 import LoRaE22, Configuration from lora_e22_operation_constant import ResponseStatusCode from lora_e22_constants import FixedTransmission, RssiEnableByte loraSerial = serial.Serial('/dev/ttyTHS1', baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS)

lora = LoRaE22('400T22D', loraSerial, aux_pin=18, m0_pin=24, m1_pin=23)

code = lora.begin() configuration_to_set = Configuration('400T22D') configuration_to_set.TRANSMISSION_MODE.enableRSSI = RssiEnableByte.RSSI_ENABLED configuration_to_set.CHAN = 29 # Address of this receive no sender code, confSetted = lora.set_configuration(configuration_to_set)

def opcion_no(): messagebox.showinfo("Opción seleccionada", "Operación Cancelada")

Datos de ejemplo de los usuarios

usuarios = [ {"nombre": "saul", "activo": True, "ultima_conexion": "2023-05-24 10:30:00", "bloqueado": False}, {"nombre": "Usuario 2", "activo": False, "ultima_conexion": "2023-05-23 14:45:00", "bloqueado": False}, {"nombre": "Usuario 3", "activo": True, "ultima_conexion": "2023-05-24 09:15:00", "bloqueado": False}, {"nombre": "Usuario 4", "activo": False, "ultima_conexion": "2023-05-22 18:20:00", "bloqueado": False}, {"nombre": "Usuario 5", "activo": True, "ultima_conexion": "2023-05-24 11:05:00", "bloqueado": False}, {"nombre": "Usuario 6", "activo": True, "ultima_conexion": "2023-05-24 13:40:00", "bloqueado": False}, {"nombre": "Usuario 7", "activo": False, "ultima_conexion": "2023-05-23 09:50:00", "bloqueado": False}, {"nombre": "Usuario 8", "activo": True, "ultima_conexion": "2023-05-24 16:25:00", "bloqueado": False} ]

Función que envía el mensaje

def env_msj(): messagebox.showinfo("Nosotros", "Somos un grupo de alumnos de ingeiería en sistemas electrónicos y telecomunicaiones de noveno semestre de la Universidad Autonoma de la Ciudad de México (UACM), plantel San Lorenzo Tezonco, en el cual desarrollamos un prototipo de interfaz para una estacion terrena. Asi como\n el enlace de moviles mediante modulos Lora, siendo este nuestro proyecto de certificacion en la materia Sistemas \nde Telefonia celular. \n¡¡¡¡PROFE PASENOS, PROMETEMOS NO EJERCER!!!!")

Funcion para bloquear al usuario

def bloq_usuario(nombre): for usuario in usuarios: if usuario["nombre"] == nombre: usuario["bloqueado"] = True break messagebox.showinfo("Bloquear usuario", f"El usuario {nombre} ha sido bloqueado.")

Funcion para desbloquear al usuario

def desbloq_usuario(nombre): for usuario in usuarios: if usuario["nombre"] == nombre: usuario["bloqueado"] = False break messagebox.showinfo("Desbloquear usuario", f"El usuario {nombre} ha sido desbloqueado.")

Funcion para salir del programa

def salir_prog(): top = Toplevel() top.title("Cerrando el programa") top.geometry("300x100") label = Label(top, text="¿Seguro que quieres salir de la aplicación?") label.pack(pady=10)

button_si = ttk.Button(top, text="Sí", command=root.destroy)
button_si.pack(side="left", padx=10)

button_no = ttk.Button(top, text="Cancelar", command=opcion_no)
button_no.pack(side="right", padx=10)

Funcion para mostrar la lista de usuarios

def list_usuarios():

Crear una ventana emergente

top = Toplevel()
top.title("Lista de usuarios")

# Crear una tabla usando Treeview
treeview = ttk.Treeview(top)
treeview.pack()

# Configurar las columnas
treeview["columns"] = ("activo", "ultima_conexion", "fecha_hora_actual", "bloqueado", "mensaje")
treeview.column("#0", width=100, anchor="w")
treeview.column("activo", width=100, anchor="center")
treeview.column("ultima_conexion", width=150, anchor="center")
treeview.column("fecha_hora_actual", width=150, anchor="center")
treeview.column("bloqueado", width=100, anchor="center")

# Configurar encabezados de columna
treeview.heading("#0", text="Nombre")
treeview.heading("activo", text="Activo")
treeview.heading("ultima_conexion", text="Última Conexión")
treeview.heading("fecha_hora_actual", text="Fecha y Hora Actual")
treeview.heading("bloqueado", text="Bloqueado")
treeview.heading("mensaje", text="Enviar mensaje")

# Agregar usuarios a la tabla
for usuario in usuarios:
    nombre = usuario["nombre"]
    activo = "Activo" if usuario["activo"] else "No activo"
    ultima_conexion = usuario["ultima_conexion"]
    fecha_hora_actual = obtener_fecha_hora_actual()
    bloqueado = "Sí" if usuario["bloqueado"] else "No"
    treeview.insert("", "end", text=nombre, values=(activo, ultima_conexion, fecha_hora_actual, bloqueado))

    # Agregar botones de bloqueo/desbloqueo
    if usuario["bloqueado"]:
        button_desbloq = ttk.Button(top, text="Desbloquear", command=lambda nombre=nombre: desbloq_usuario(nombre))
    else:
        button_bloq = ttk.Button(top, text="Bloquear", command=lambda nombre=nombre: bloq_usuario(nombre))
        button_bloq.pack()

Funcion para guardar el documento como block de notas

def guardar_documento(): file_path = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Text Files", ".txt"), ("All Files", ".*")]) if file_path:

Guardar los datos de usuarios en el archivo

    with open(file_path, 'w') as file:
        for usuario in usuarios:
            nombre = lora.receive_message(rssi=True)  # Alinear a la izquierda con una longitud de 20 caracteres
            activo = "Activo" if usuario["activo"] else "No activo"
            ultima_conexion = usuario["ultima_conexion"]
            bloqueado = "Bloqueado" if usuario["bloqueado"] else "No bloqueado"
            file.write(f"Nombre: {nombre}\tActivo: {activo}\tÚltima Conexión: {ultima_conexion}\tBloqueado: {bloqueado}\n",obtener_fecha_hora_actual())

    messagebox.showinfo("Guardar archivo", "El archivo ha sido guardado con éxito.")

Obtener la fecha y hora actual

def obtener_fecha_hora_actual(): now = datetime.now() fecha_hora_actual = now.strftime("%Y-%m-%d %H:%M:%S") return fecha_hora_actual

def recive(): while True: for channel in range(20, 31): print(str(channel)) if lora.available() > 0: configuration_to_set = Configuration('400T22D') configuration_to_set.ADDH = 0x00 configuration_to_set.ADDL = 0x01 configuration_to_set.CHAN = channel configuration_to_set.TRANSMISSION_MODE.fixedTransmission = FixedTransmission.FIXED_TRANSMISSION configuration_to_set.TRANSMISSION_MODE.enableRSSI = RssiEnableByte.RSSI_ENABLED code, value, rssi = lora.receive_message(rssi=True) print('Ch:',channel) print(ResponseStatusCode.get_description(code)) print(RssiEnableByte.RSSI_ENABLED) print('RSSI: ', rssi) print(value) print(obtener_fecha_hora_actual()) time.sleep(.5)

root = tk.Tk() root.withdraw() root.title("UACM-Lora")

toplevel_1 = tk.Toplevel(root) labelframe_1 = ttk.Labelframe(toplevel_1) labelframe_1.pack(side='top')

Agregando la imagen de fondo

imageL = PhotoImage(file='logo.gif') lblimage = Label(labelframe_1, text='Proyecto ', image=imageL).place(x=0, y=0)

Boton 1

button_1 = ttk.Button(labelframe_1, text='Aceca de:', command=env_msj) button_1.place(relx=0.8, rely=0.02, anchor=tk.CENTER)

Boton 3

button_2 = ttk.Button(labelframe_1, text='Salir', command=salir_prog) button_2.place(relx=0.95, rely=0.02, anchor=tk.CENTER)

Boton 4

button_3 = ttk.Button(labelframe_1, text='Lista de Usuarios', command=list_usuarios) button_3.place(relx=0.1, rely=0.98, anchor=tk.CENTER)

Boton 6 (Guardar documento)

button_4 = ttk.Button(labelframe_1, text='Guardar documento', command=guardar_documento) button_4.place(relx=0.31, rely=0.98, anchor=tk.CENTER)

button_5 = ttk.Button(labelframe_1, text='oRecive', command=recive) button_5.place(relx=0.51, rely=0.98, anchor=tk.CENTER)

Configuración del Labelframe

labelframe_1.config(height='1920', text='Redes celulares', width='1080')

toplevel_1.config(height='800', width='800') root.mainloop()`

DanielBustillos commented 2 weeks ago

I am experiencing the same issue across three different PCBs, involving two distinct designs. While I can send messages, I encounter a "Data Size no match" error when attempting to use setconfigure or getconfigure.

Interestingly, on one board, the configuration commands occasionally work. I've verified the connections with a multimeter, and everything appears to be correct.

I'm using an ESP32 Lillygo T7 Mini 1.3, with the following connections:

Additionally, I'm using a MOSFET to control the ground and reduce power consumption. Attached is my diagram.

I have a few questions that might help diagnose the issue:

Thank you for your assistance.

Screenshot 2024-06-18 at 3 35 05 p m
DanielBustillos commented 1 week ago

I recently developed a new board and successfully set the configuration four times. However, I am now encountering a "data size not match" error on subsequent attempts. The board does not seem to be overheating.

I am unsure whether this issue is related to hardware or software. Any assistance in troubleshooting this problem would be greatly appreciated.

I have tried the following steps:

The board includes a GPS, an accelerometer, and an infrared sensor, all of which are functioning correctly. The ebymodule used is the e220900T22D. Additionally, the board has 30 vias, and I'm not sure if this could be contributing to the issue.