diff --git a/GW-custom/test_envoi_senscom.py b/GW-custom/test_envoi_senscom.py index 475b7bd44043e3b3ffc91c05304094b11b45666d..72b5cd92fd8c960355507969da8a8e821dc6dbf6 100644 --- a/GW-custom/test_envoi_senscom.py +++ b/GW-custom/test_envoi_senscom.py @@ -2,6 +2,8 @@ import json import requests +## Envoi des données sur sensor community + url = "https://api.sensor.community/v1/push-sensor-data/" headers = { "Content-Type": "application/json", diff --git a/GW-custom/test_recept_loramac.py b/GW-custom/test_recept_loramac.py new file mode 100644 index 0000000000000000000000000000000000000000..d53b2c90a308b7fe4ac7f855d617cd0b95d9faa5 --- /dev/null +++ b/GW-custom/test_recept_loramac.py @@ -0,0 +1,47 @@ +import time + +from machine import UART, Pin + +# Configuration UART pour le module LoRa E5 +uart = UART(1, baudrate=9600, tx=17, rx=16) + +# Configuration de la broche pour le module LoRa E5 +reset_pin = Pin(18, Pin.OUT) +reset_pin.value(1) + +def reset_lora(): + reset_pin.value(0) + time.sleep(0.1) + reset_pin.value(1) + time.sleep(0.1) + +def send_command(command, delay=0.5): + uart.write(command + '\r\n') + time.sleep(delay) + response = uart.read() + if response: + print(response.decode('utf-8')) + +def setup_lora(): + reset_lora() + send_command('AT+MODE=LWOTAA') + send_command('AT+DR=EU868') + send_command('AT+KEY=APPKEY,"YOUR_APP_KEY"') + send_command('AT+ID=DevAddr,"YOUR_DEV_ADDR"') + send_command('AT+ID=DevEui,"YOUR_DEV_EUI"') + send_command('AT+ID=AppEui,"YOUR_APP_EUI"') + send_command('AT+JOIN') + +def receive_lora(): + while True: + if uart.any(): + response = uart.read() + if response: + print("Received:", response.decode('utf-8')) + time.sleep(1) + +# Initialisation du module LoRa +setup_lora() + +# Boucle de réception des messages +receive_lora() \ No newline at end of file