Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • main
1 result

Target

Select target project
  • pronto-3/capteur-autonome-penn-avel
1 result
Select Git revision
Show changes
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
......
......@@ -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
......