diff --git a/Autre/pygate 2/main.py b/Autre/pygate 2/main.py index 24602c4d94104dcb60939710b4eb4c7dc586a16e..d5d204dc1bd03338f6d3355bcdccb2d25fffb8f9 100644 --- a/Autre/pygate 2/main.py +++ b/Autre/pygate 2/main.py @@ -1,8 +1,9 @@ -from network import WLAN import time + import machine -from machine import RTC import pycom +from machine import RTC +from network import WLAN print('\nStarting LoRaWAN concentrator') # Disable Hearbeat @@ -27,12 +28,14 @@ machine.callback(trigger = (machine.PYGATE_START_EVT | machine.PYGATE_STOP_EVT | print('Connecting to WiFi...', end='') # Connect to a Wifi Network wlan = WLAN(mode=WLAN.STA) -wlan.connect(ssid='ObjetsConnectes', auth=(WLAN.WPA2, 'Pandemie2021')) +wlan.connect(ssid='Redmi Note 8 (2021)', auth=(WLAN.WPA2, 'lemotdepassecestca')) #wlan.connect(ssid='iPhone de Charlotte', auth=(WLAN.WPA2, 'azilisenoraalan')) -while not wlan.isconnected(): +timout = 10 # seconds +while not wlan.isconnected() and timout > 0: print('.', end='') time.sleep(1) + timout -= 1 print(" OK") # Sync time via NTP server for GW timestamps on Events diff --git a/GW-custom/LoRa_homemade/main.py b/GW-custom/LoRa_homemade/main.py index 2981f0e8667fb6008938113390e4b9fe4bacbfbc..9fe0782fd006b404f511c9c0a4fcbe8115f88bf8 100644 --- a/GW-custom/LoRa_homemade/main.py +++ b/GW-custom/LoRa_homemade/main.py @@ -49,7 +49,7 @@ def blink_led(times, interval): led.value(0) # Eteindre la LED time.sleep(interval) # Attendre un certain temps -def configure_lora(frequency, sf, bw, TXPR, RXPR, TX_power): +def configure_lora(): send_at_command("") send_at_command("+MODE=TEST") @@ -90,7 +90,7 @@ def send_to_sensor_community_sht30(temp, humid): url = "https://api.sensor.community/v1/push-sensor-data/" headers = { "Content-Type": "application/json", - "X-Pin": "7", # 7 = SHT30 + "X-Pin": "7", # 7 = SHT30 ou DHT22 "X-Sensor": "esp32-900881266" } data = { @@ -129,23 +129,6 @@ def try_receive(): wifi_connect() # Connexion au Wi-Fi -wlan = network.WLAN(network.STA_IF) -print(wlan.ifconfig()) - - -import urequests - -try: - r = urequests.post("http://httpbin.org/post", json={"test": 123}) - print("Réponse HTTP:", r.status_code) - print(r.text) - r.close() -except Exception as e: - print("Erreur:", e) - - - - uart = UART(2, baudrate=9600, tx=17, rx=16) @@ -154,7 +137,7 @@ led = Pin(2, Pin.OUT) # GPIO 2 pour la LED bleue intégrée # Initialisation du module LoRa blink_led(3, 0.5) # Clignoter la LED 3 fois au démarrage print("\n\nInitialisation du module LoRa-E5...\n") -configure_lora(868000000, 12, 125, 12, 15, 14) # Configurer le module LoRa avec les paramètres souhaités +configure_lora() # Configurer le module LoRa avec les paramètres souhaités send_at_command("+TEST=RXLRPKT") # Commencer la réception des paquets LoRa led.value(1) # Rallumer la LED après l'initialisation