Packet missing while communicating with lopy and rak7258

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.

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.

Code used

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(1)
# 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)
s.send(bytes([0x01, 0x02, 0x03]))

get any data received…

#data = s.recv(64)
#print(data)

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)

Packet Log

Thanks in advance for your support.

Hi @ajith
It is not good idea to use the module without antenna so attach one and try again. Please give print screen of used frequencies in Gateway. Every packet is unconfirmed until next one confirms receiving of the first.

Regards
Todor Velev

Hi @velev,
Thanks for your reply.
We understand that Lora communication without an antenna will damage the radio. That is why we are using very low transmission power. Does that is the reason for packet missing. Attaching the screenshot, hope that is what you are

looking for.

Hi @velev
Have got time to look into it?
I had imported AU915 settings and that is what I am currently using (image attached in the previous reply). Do I need to change anything from the values shown in that?

Hi @velev
I had solved packet missing issue. Your frequency related questions dragged me to check the same in the Lopy module also. I had removed the channel other than the frequencies required for AU915. Data is now successfully sending without any loss. Thanks for your help velev.