Skip to content

Commit 7611076

Browse files
committed
LoRa section initiated
1 parent a46f35c commit 7611076

File tree

1 file changed

+62
-2
lines changed
  • content/hardware/04.pro/shields/portenta-vision-shield/tutorials/user-manual

1 file changed

+62
-2
lines changed

content/hardware/04.pro/shields/portenta-vision-shield/tutorials/user-manual/content.md

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,10 +748,70 @@ Run the script and the current date and time will be printed in the OpenMV IDE S
748748

749749
### LoRa® (ASX00026)
750750

751-
The **Vision Shield - LoRa®** can extend our project connectivity by leveraging it LoRa® module for long-range communication in remote areas with a lack of internet access.
751+
The **Vision Shield - LoRa®** can extend our project connectivity by leveraging it LoRa® module for long-range communication in remote areas with a lack of internet access. Powered by the Murata CMWX1ZZABZ module which contains an STM32L0 processor along with a Semtech SX1276 Radio.
752752

753753
![LoRa® antenna connection](assets/antenna.png)
754754

755755
First, connect the Vision Shield - LoRa® to the Portenta H7. Attach the LoRa® antenna to its respective connector. Now connect the USB-C® cable to the Portenta H7 and your computer.
756756

757-
Now you are ready to test the connectivity with the following Python script. This example lets you connect to The Things Network using LoRaWAN® and send a `Hello World` message to it.
757+
Now you are ready to test the connectivity with the following Python script. This example lets you connect to The Things Network using LoRaWAN® and send a `Hello World` message to it.
758+
759+
```python
760+
from lora import *
761+
762+
lora = Lora(band=BAND_AU915, poll_ms=60000, debug=False)
763+
764+
print("Firmware:", lora.get_fw_version())
765+
print("Device EUI:", lora.get_device_eui())
766+
print("Data Rate:", lora.get_datarate())
767+
print("Join Status:", lora.get_join_status())
768+
769+
# Example keys for connecting to the backend
770+
appEui = "*****************" # now called JoinEUI
771+
appKey = "*****************************"
772+
773+
try:
774+
lora.join_OTAA(appEui, appKey)
775+
# Or ABP:
776+
# lora.join_ABP(devAddr, nwkSKey, appSKey, timeout=5000)
777+
# You can catch individual errors like timeout, rx etc...
778+
except LoraErrorTimeout as e:
779+
print("Something went wrong; are you indoor? Move near a window and retry")
780+
print("ErrorTimeout:", e)
781+
except LoraErrorParam as e:
782+
print("ErrorParam:", e)
783+
784+
print("Connected.")
785+
lora.set_port(3)
786+
787+
try:
788+
if lora.send_data("HeLoRA world!", True):
789+
print("Message confirmed.")
790+
else:
791+
print("Message wasn't confirmed")
792+
793+
except LoraErrorTimeout as e:
794+
print("ErrorTimeout:", e)
795+
796+
# Read downlink messages
797+
while True:
798+
if lora.available():
799+
data = lora.receive_data()
800+
if data:
801+
print("Port: " + data["port"])
802+
print("Data: " + data["data"])
803+
lora.poll()
804+
sleep_ms(1000)
805+
```
806+
807+
Find the frequency used in your country for The Things Network on this [list](https://www.thethingsnetwork.org/docs/lorawan/frequencies-by-country/) and modify the parameter in the script with the following function.
808+
809+
```python
810+
lora = Lora(band=BAND_AU915, poll_ms=60000, debug=False) # change the band with yours e.g BAND_US915
811+
```
812+
Define your application `appEUI` and `appKey`.
813+
814+
```python
815+
appEui = "*****************" # now called JoinEUI
816+
appKey = "*****************************"
817+
```

0 commit comments

Comments
 (0)