Skip to content

Commit

Permalink
arreglo de script de mqtt
Browse files Browse the repository at this point in the history
  • Loading branch information
fgmolteni committed Mar 22, 2024
1 parent 7e97daa commit 77564e9
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 35 deletions.
18 changes: 18 additions & 0 deletions 20240321.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
received_at application_id device_id f_port f_cnt rssi snr data_rate_index consumed_airtime frm_payload decoded_payload
2024-03-22T01:34:09.089808776Z firework eui-70b3d57ed005de4f 1 603 -34 13.3 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
2024-03-22T01:34:30.244679982Z firework eui-70b3d57ed005de4f 1 604 -38 13.5 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
2024-03-22T01:34:56.931611974Z firework eui-70b3d57ed005de4f 1 606 -39 9 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
2024-03-22T01:35:18.084203425Z firework eui-70b3d57ed005de4f 1 607 -39 12.8 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
2024-03-22T01:35:39.247520378Z firework eui-70b3d57ed005de4f 1 608 -42 13.5 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
2024-03-22T01:36:00.381748334Z firework eui-70b3d57ed005de4f 1 609 -40 14 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
2024-03-22T01:36:21.530597867Z firework eui-70b3d57ed005de4f 1 610 -41 13.3 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
2024-03-22T01:37:03.822230643Z firework eui-70b3d57ed005de4f 1 612 -39 13.3 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
2024-03-22T01:37:24.987025935Z firework eui-70b3d57ed005de4f 1 613 -40 13.8 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
2024-03-22T01:37:46.126436730Z firework eui-70b3d57ed005de4f 1 614 -38 13.3 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
2024-03-22T01:38:07.294680897Z firework eui-70b3d57ed005de4f 1 615 -40 13.8 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
2024-03-22T01:38:28.422297233Z firework eui-70b3d57ed005de4f 1 616 -34 13.5 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
2024-03-22T01:38:49.567996070Z firework eui-70b3d57ed005de4f 1 617 -34 13.3 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
2024-03-22T01:39:10.713545944Z firework eui-70b3d57ed005de4f 1 618 -48 13.5 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
2024-03-22T01:39:31.874464669Z firework eui-70b3d57ed005de4f 1 619 -49 12.3 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
2024-03-22T01:40:14.200578459Z firework eui-70b3d57ed005de4f 1 621 -48 11.5 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
2024-03-22T01:40:35.319163490Z firework eui-70b3d57ed005de4f 1 622 -46 13.8 - 0.051456s UnR7bA== {'degreesC': 27.002, 'humidity': 14.0015}
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,32 @@ Proyecto realizado por equipos de desarrollo de la Universidad Nacional del Nord

## PLacas Soportadas
- Heltec WiFi LoRA V2


## Conexión por MQTT
Realizamos una conexión al los servidores de TTN mediante el montaje de un servidor MQTT, este enviara los datos desde los TTN a los "suscriptores", para ello realizamos un script en python.

primero debemos habilitar una API keys en TTN, es lo hacemos yendo a la aplicación de nuestro dispositivo. Seguidamente nos vamos al apartado **Integraciones>>MQTT** y añadimos una nueva api-keys.


## Observaciones

Utilizar version 1 de mqtt

## Estructura

Proyecto
|
+----> Firmware Nodo-Red
| |
| +---> Sensores.
| |
| +---> Display OLED.
| |
| +---> Envió de Datos.
|
+----> Cliente MQTT
|
+---> *Almacenamiento*
|
+---> *Visualizacion*
7 changes: 4 additions & 3 deletions main.py → mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# NNSXS.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#
USER = "firework@ttn"
PASSWORD = "NNSXS.UTIGWWXDBPMH7CLWZAP65JM7HGELPXZAQ4V56LQ.AUGGSOXTUGAZJVQSVDYSIJVK7TTCDQPVSQZYIFEKY4L7YC5YOLTA"
PASSWORD = "NNSXS.FMGMPBTMKXQ5ZRB3LKWMH7X7PWYN34VQ3VTVUCA.SE35UDJS6X4CF5N2CAXVMLLYEBUOFBBK5JEIOQCQ4EIN3DNYLVFQ"
PUBLIC_TLS_ADDRESS = "nam1.cloud.thethings.network"
PUBLIC_TLS_ADDRESS_PORT = 8883
DEVICE_ID = "eui-70b3d57ed005de4f"
Expand Down Expand Up @@ -133,14 +133,15 @@ def on_log(client, userdata, level, buf):
client_id = f'python-mqtt-{random.randint(0, 1000)}'

print("Create new mqtt client instance")
mqttc = mqtt.Client(client_id)
mqttc = mqtt.Client(callback_api_version=mqtt.CallbackAPIVersion.VERSION1,
client_id=client_id)

print("Assign callback functions")
mqttc.on_connect = on_connect
mqttc.on_subscribe = on_subscribe
mqttc.on_message = on_message
mqttc.on_disconnect = on_disconnect
# mqttc.on_log = on_log # Logging for debugging OK, waste
mqttc.on_log = on_log # Logging for debugging OK, waste

# Setup authentication from settings above
mqttc.username_pw_set(USER, PASSWORD)
Expand Down
32 changes: 0 additions & 32 deletions subcribe.py

This file was deleted.

0 comments on commit 77564e9

Please sign in to comment.