diff --git a/GW-custom/LoRa_homemade/config.py b/GW-custom/LoRa_homemade/config.py deleted file mode 100644 index fd6f75e288c1ea1dfa4d9651e341132a893ce229..0000000000000000000000000000000000000000 --- a/GW-custom/LoRa_homemade/config.py +++ /dev/null @@ -1,86 +0,0 @@ -# Copyright 2020 LeMaRiva|tech lemariva.com -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -""" -# ES32 TTGO v1.0 -device_config = { - 'miso':19, - 'mosi':27, - 'ss':18, - 'sck':5, - 'dio_0':26, - 'reset':14, - 'led':2, -} - -# M5Stack ATOM Matrix -device_config = { - 'miso':23, - 'mosi':19, - 'ss':22, - 'sck':33, - 'dio_0':25, - 'reset':21, - 'led':12, -} -""" - -""" -#M5Stack & LoRA868 Module -device_config = { - 'miso':19, - 'mosi':23, - 'ss':5, - 'sck':18, - 'dio_0':26, - 'reset':36, - 'led':12, -} -""" - -# Configuration des broches pour le module LoRa E5 avec un ESP32 -device_config = { - 'miso': 19, # Pin MISO (Master In Slave Out) - 'mosi': 27, # Pin MOSI (Master Out Slave In) - 'ss': 18, # Pin SS (Chip Select) - 'sck': 5, # Pin SCK (Clock) - 'dio_0': 26, # Pin DIO0 (utilisé pour le mode interruption ou pour la détection de la fin de transmission) - 'reset': 14, # Pin RESET (si tu veux contrôler le reset du module) - 'led': 2, # Pin LED (si tu veux utiliser une LED pour indiquer l'état de l'appareil) -} - - -app_config = { - 'loop': 200, - 'sleep': 100, -} - -lora_parameters = { - 'frequency': 868E6, - 'tx_power_level': 2, - 'signal_bandwidth': 125E3, - 'spreading_factor': 12, - 'coding_rate': 5, - 'preamble_length': 8, - 'implicit_header': False, - 'sync_word': 0x12, - 'enable_CRC': False, - 'invert_IQ': False, -} - -wifi_config = { - 'ssid':'ObjetsConnectes', - 'password':'Pandemie2021' -} \ No newline at end of file diff --git a/GW-custom/LoRa_homemade/config_lora.py b/GW-custom/LoRa_homemade/config_lora.py deleted file mode 100644 index 0112819183941f801049cff770b4c6945b445d67..0000000000000000000000000000000000000000 --- a/GW-custom/LoRa_homemade/config_lora.py +++ /dev/null @@ -1,18 +0,0 @@ -import sys -import os -import time -import machine -import ubinascii - -def mac2eui(mac): - mac = mac[0:6] + 'fffe' + mac[6:] - return hex(int(mac[0:2], 16) ^ 2)[2:] + mac[2:] - -def get_millis(): - millisecond = time.ticks_ms() - return millisecond - -def get_nodename(): - uuid = ubinascii.hexlify(machine.unique_id()).decode() - node_name = "ESP_" + uuid - return node_name diff --git a/GW-custom/LoRa_homemade/main.py b/GW-custom/LoRa_homemade/main.py index 1a347069436a286bad8b1c5cb785e22b52c661c4..9874dc4f80c952ebec5717fa93a2b1ae5e088816 100644 --- a/GW-custom/LoRa_homemade/main.py +++ b/GW-custom/LoRa_homemade/main.py @@ -5,7 +5,7 @@ from machine import UART, Pin uart = UART(2, baudrate=9600, tx=17, rx=16) # Initialisation de la LED intégrée (souvent sur GPIO 2) -led = Pin(2, Pin.OUT) # GPIO 2 pour la LED intégrée +led = Pin(2, Pin.OUT) # GPIO 2 pour la LED bleue intégrée def send_at_command(command): uart.write((command + "\r\n").encode()) # Envoie la commande AT au module LoRa @@ -16,20 +16,24 @@ def send_at_command(command): def blink_led(times, interval): for _ in range(times): - led.value(0) # Éteindre la LED + led.value(1) # Allumer la LED time.sleep(interval) # Attendre un certain temps - led.value(1) # Rallumer la LED + led.value(0) # Eteindre la LED time.sleep(interval) # Attendre un certain temps +def configure_lora(frequency, sf, bw, cr, power): + send_at_command("AT") + send_at_command("AT+MODE=TEST") + # Configurer le module LoRa avec les paramètres donnés + send_at_command(f"AT+TEST=RFCFG,{frequency},{sf},{bw},{cr},{power}") # Configurer la fréquence, le SF, le BW, le CR et la puissance + # Initialisation du module LoRa -led.value(1) # Allumer la LED (rouge) -time.sleep(2) +blink_led(3, 0.5) # Clignoter la LED 3 fois au démarrage print("Initialisation du module LoRa-E5...") -send_at_command("AT") -send_at_command("AT+MODE=TEST") -send_at_command("AT+TEST=RFCFG,868000000,12,125,8,14") # Définir le débit de données (ex: SF12BW125) +configure_lora(868000000, 12, 125, 8, 14) # Configurer le module LoRa avec les paramètres souhaités send_at_command("AT+TEST=RXLRPKT") # Commencer la réception des paquets LoRa +led.value(1) # Rallumer la LED après l'initialisation print("Module LoRa-E5 initialisé. En attente de messages...") while True: