Skip to content
Snippets Groups Projects
Commit 8318fff7 authored by CARNEIRO--GILLET Alexandre's avatar CARNEIRO--GILLET Alexandre
Browse files

ajout test_recept_loramac, jsp si ça marche

parent 6767d33b
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,8 @@ import json ...@@ -2,6 +2,8 @@ import json
import requests import requests
## Envoi des données sur sensor community
url = "https://api.sensor.community/v1/push-sensor-data/" url = "https://api.sensor.community/v1/push-sensor-data/"
headers = { headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
......
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment