Download the sample code from https://github.com/Turta-io/LoRaHAT/blob/master/Samples/Python/lora_us_rx.py
Copy the sample code to a folder on the Raspberry Pi.
Open terminal, and then go to the folder you copied the sample.
Run the sample with the following command:
#!/usr/bin/env python3#This sample demonstrates receiving packets over the LoRaWAN protocol. (For US version.)#Install LoRa HAT library with "pip3 install turta-lorahat"#Raspberry Pi Configuration# - You should enable SPI and I2C from the Raspberry Pi's configuration.# To do so, type 'sudo raspi-config' to the terminal, then go to 'Interfacing Options' and enable both SPI and I2C.# - You should swap the serial ports of the Raspberry Pi.# Set "/dev/ttyAMA0" to 'serial0'. Also, disable the console on 'serial0'.# For a how-to, visit our documentation at https://docs.turta.io/how-tos/raspberry-pi/raspbian/swapping-the-serial-portsfrom time import sleepfrom turta_lorahat import Turta_LoRa#Initializelora = Turta_LoRa.RN2XX3(region = Turta_LoRa.REGIONS.US_RN2903, auto_config = Turta_LoRa.CONFIG_MODES.LORA_RX)print("Radio is set to receive.")try:while True:#Check for serial port bufferbuffer = lora.check_data()#If data is received, print itif buffer is not None:print(buffer)#Exit on CTRL+Cexcept KeyboardInterrupt:print('Bye.')
When you run the sample, it prints the incoming data, if any, from the default radio frequency. When incoming data is captured, the example output should be like this:
LoRa board temp: 28.0C
To stop the Python script, just press CTRL + C.