Lora communication

Hi all

Iam Sreejith have just joined your community today.

My team is working a project on Lora which deals transmission communication between loppy and RAK4gateway.

Gateway configured and Lopy was programmed to read the analogue values.

Issue found: Random packet loss while communication

Can you please guide us on what has to be done to resolve the issue.

Many reasons lead to packet loss, need more information

  1. RAK7258 will be designated to act as a gateway.

  2. Sensor modules will be integrated with the Lopy4 board.

  3. We will enable LoRa to LoRa communication between LoPy4 and RAK 7258.
    can u please brief me what more details u need?

Hello @sreejith
We need to know at what bands you will operate. LoRa to LoRa is different than LoRaWAN so please explain more clearly. And it we be good if you give us some logs or print screens from Gateway and device serial output(if any).

Regards
Todor Velev

Hi @velev

Thank you for the prompt response

Sorry, we are beginners in this Lora technology.

We are trying to communicate Pycom Lopy4 and RAK7258 gateway using Lora.

The frequency used for testing was AU915.

No antenna was used and transmission power: 2dB

Spread factor: 7

The mode was LoraWAN. Attaching the code used and logs from the gateway.

And one more clarification also why the data received shows unconfirmed data. And is this packet missing is because of lower transmission power. We are not able to increase the power because we feel without the antenna chip may get damaged.

Thanks in advance for your support.

(Attachment main (1).py is missing)

(Attachment Packet_log_20190820_185119 (Autosaved).csv is missing)

Hi @Velev
Please find the code i have trying to responded by mail but have received message that the attachments were rejected
Please find the code

Measuring temperature by TMP36

from network import LoRa
import socket
import utime
import binascii
import pycom
import ustruct
import machine
from machine import Pin

adc = machine.ADC() # create an ADC object
apin = adc.channel(pin=Pin.exp_board.G3) # Lopy4 specific: (pin = ‘P16’) create an analog pin on P16 & connect TMP36

Temp measurment

def temp_measure():
print("")
print(“Reading Moisture Sensor…”)
value = apin()
print(“ADC count = %d” %(value))

# LoPy  has 1.1 V input range for ADC
temp = ((value * 1100 ) / 4096 - 500) / 10
print("Temperature = %5.1f C" % (temp))

return temp

disable LED heartbeat (so we can control the LED)

pycom.heartbeat(False)

set LED to red

pycom.rgbled(0x7f0000)

lora config

lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.AU915,tx_power=2)

access info

app_eui = binascii.unhexlify(‘ADA4DAE3AC12676B’)
app_key = binascii.unhexlify(‘11B0282A189B75B0B4D2D8C7FA38548B’)

attempt join - continues attempts background

lora.join(activation=LoRa.OTAA, auth=(app_eui, app_key), timeout=0)

wait for a connection

print(‘Waiting for LoRaWAN network connection…’)
while not lora.has_joined():
utime.sleep(2.5)
# if no connection in a few seconds, then reboot

we’re online, set LED to green and notify via print

pycom.rgbled(0x004600)
print(‘Network joined!’)

setup the socket

s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5)
s.setblocking(False)
s.bind(1)

limit to 200 packets; just in case power is left on

while 1:
# take temp measurment, turn the temp blue when measuring
pycom.rgbled(0x00007d)
utime.sleep(1)
temp = temp_measure()
pycom.rgbled(0x004600)

# encode the packet, so that it's in BYTES (TTN friendly)
# could be extended like this struct.pack('f', temp) + struct.pack('c',"example text")
# 'h' packs it into a short, 'f' packs it into a float, must be decoded in TTN
packet = ustruct.pack('f', temp)

# send the prepared packet via LoRa
s.send(packet)

# example of unpacking a payload - unpack returns a sequence of
#immutable objects (a list) and in this case the first object is the only object
print ("Unpacked value is:", ustruct.unpack('f',packet)[0])

# check for a downlink payload, up to 64 bytes
rx_pkt = s.recv(64)

# check if a downlink was received
if len(rx_pkt) > 0:
	print("Downlink data on port 200:", rx_pkt)
	pycom.rgbled(0x7f0000)
utime.sleep(40)

please find the packet structure received

null 18:49:49 917.2 -112 -11.3 CRC_ERR LORA ‘4/5’ SF7BW125
null 18:49:35 917.4 -112 -11.3 CRC_ERR LORA ‘4/8’ SF7BW125
null 18:48:48 917.2 -106 -11.3 CRC_ERR LORA ‘OFF’ SF7BW125
Unconfirmed Data Up 18:47:16 918 -100 3 CRC_OK LORA ‘4/5’ SF7BW125 101 2000001 1 01 51 AE 9C
Unconfirmed Data Down 18:47:06 927.5 CRC LORA ‘4/5’ SF7BW500 10 2000001
Unconfirmed Data Up 18:47:06 918.2 -104 6.3 CRC_OK LORA ‘4/5’ SF7BW125 100 2000001 1 01 DF 25 98
null 18:46:52 917.4 -111 -11.3 CRC_ERR LORA ‘4/6’ SF7BW125
Unconfirmed Data Down 18:46:34 923.3 CRC LORA ‘4/5’ SF7BW500 9 2000001
Unconfirmed Data Up 18:46:32 916.8 -105 6.5 CRC_OK LORA ‘4/5’ SF7BW125 97 2000001 1 01 24 07 EE
null 18:46:27 918 -108 -11.3 CRC_ERR LORA ‘4/6’ SF7BW125
null 18:44:49 916.8 -111 -11.5 CRC_ERR LORA ‘4/5’ SF7BW125
null 18:41:36 916.8 -112 -11 CRC_ERR LORA ‘4/6’ SF7BW125
Unconfirmed Data Down 18:41:24 925.1 CRC LORA ‘4/5’ SF7BW500 8 2000001
Unconfirmed Data Up 18:41:24 917.4 -106 4 CRC_OK LORA ‘4/5’ SF7BW125 69 2000001 1 01 24 AB 45
null 18:40:55 916.8 -113 -10.8 CRC_ERR LORA ‘4/7’ SF7BW125
Unconfirmed Data Up 18:40:39 917.6 -105 5.3 CRC_OK LORA ‘4/5’ SF7BW125 65 2000001 1 01 DD E4 C2
Unconfirmed Data Down 18:40:29 923.9 CRC LORA ‘4/5’ SF7BW500 7 2000001
Unconfirmed Data Up 18:40:29 917 -112 -8 CRC_OK LORA ‘4/5’ SF7BW125 64 2000001 1 01 B2 9C 2B