RSSI level testing
For the source code implementation, Visual Studio Code was used with the Pymakr extension installed.
For the communication tests, two Fipy modules were used, one designated as the Transmitter and the other as the Receiver.
At the receiver, to determine the thresholds regarding the level/quality of the received signal RSSI, the RGB LED provided with the Fipy module was used for indication. Additionally, for some measurements, serial communication was also used to determine the absolute values of RSSI.
The source code used for the transmitter Tx is:
# main.py -- put your code here!
# code for the LoRa Tx Fipy module
import pycom
import time
pycom.heartbeat(False)
time.sleep(1)
pycom.rgbled(0x7f0000)
time.sleep(1)
pycom.rgbled(0x7f7f00)
time.sleep(1)
pycom.rgbled(0xff00)
time.sleep(1)
#############################
from network import LoRa
import socket
import time
import ubinascii
time.sleep(1.0)
lora = LoRa(mode=LoRa.LORA, region=LoRa.EU868, frequency=868000000) # note that the frequency variable must be the same at the receiver
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
s.setblocking(False)
while True: # running infinitely
s.send('Ping') # sending the message
pycom.rgbled(0xFF0000) # programming the RGB LED for the color Red
time.sleep(1) # pause for one second
pycom.rgbled(0x7f7f00) # programming the RGB LED for the color Olive
time.sleep(1) # pause for one second
pycom.rgbled(0x00FF00) # programming the RGB LED for the color Green
time.sleep(1) # pause for one second
#############################
The source code for the receiver Rx is:
# main.py -- put your code here!
# code for the LoRa Rx Fipy module
from network import LoRa
import socket
import time
import pycom
# A region corresponding to our location where we use the module will be chosen
# Asia = LoRa.AS923
# Australia = LoRa.AU915
# Europe = LoRa.EU868
# United States = LoRa.US915
lora = LoRa(mode=LoRa.LORA, region=LoRa.EU868, frequency= 868000000)
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
s.setblocking(False)
pycom.heartbeat(False)
while True:
if s.recv(64) == b'Ping':
status=lora.stats()
rssi = status.rssi
snr = status.snr
# print(lora.stats())
print("RSSI= %s" %rssi)
print("SNR= %s" %snr)
int_rssi=int(rssi)
if int_rssi >=-71:
pycom.rgbled(0x00FF00) # Green LED
elif int_rssi <=-71 and int_rssi >=-120:
pycom.rgbled(0x000FF0) # Blue LED
elif int_rssi <= -121:
pycom.rgbled(0xFF0000) # Red LED
int_rssi=0 # initialize the RSSI value
To connect via Wi-Fi using the FTP protocol, the connection to the Wi-Fi router will be established using the boot.py file:
boot.py -- run on boot-up
import machine
import os
uart = machine.UART(0, 115200) # Delete the line if serial port is not desired
os.dupterm(uart) # Delete the line if terminal at the serial port is not desired
if machine.reset_cause() != machine.SOFT_RESET:
from network import WLAN
# We establish which wireless network we are connecting to; if it does not connect, it will switch to the default AP mode
known_nets = [('SSID', 'parola')]
wl = WLAN()
original_ssid = wl.ssid()
original_auth = wl.auth()
wl.mode(WLAN.STA)
available_nets = wl.scan()
nets = frozenset([e.ssid for e in available_nets])
known_nets_names = frozenset([e[0] for e in known_nets])
net_to_use = list(nets & known_nets_names)
try:
net_to_use = net_to_use[0]
pwd = dict(known_nets)[net_to_use]
sec = [e.sec for e in available_nets if e.ssid == net_to_use][0]
wl.connect(net_to_use, (sec, pwd), timeout=10000) # The waiting time for connection (ms)
except:
wl.init(mode=WLAN.AP, ssid=original_ssid, auth=original_auth, channel=6, antenna=WLAN.INT_ANT)
Initially, the RSSI values were measured with the transmitter and receiver close together, achieving perfect values for RSSI=0, as shown in the figure below:
Modules prepared for field measurement
RSSI level=0 for nearby modules, as above
For efficiency, it is useful to use a car:
Field measurements
No. | Distance [km] | RSSI [dBm] | Receiver antenna type | Transmitter antenna type | Screenshot |
---|---|---|---|---|---|
1 | 2.2 | -115 | Yagi-Uda isolated boom | Stick | ![]() |
2 | 2.2 | -115 | Yagi-Uda metal boom | Stick | ![]() |
3 | 2.2 | -121 | Stick | Stick | ![]() |
4 | 2.9 | -127 | Yagi-Uda isolated boom | Stick | ![]() |
5 | 2.9 | - | Stick | Stick | No reception |
The tests were conducted under the following conditions:
- The heights of the antennas above ground were approximately 1.8 m;
- The tests were conducted within a municipality with blocks and other quite tall buildings;
- Tests 1-3 are conducted in a direction with more houses than blocks up to the municipal limit;
-
Tests 4-5 are conducted in a direction with more blocks and tall buildings.
The conclusion is that at reception, a high-gain antenna makes a difference, and long distances or lower consumption can be achieved, depending on what is desired. The Yagi-Uda antennas with 12 elements are those found here . The antenna with an isolated boom is less noisy than the one with an aluminum boom but is less durable over time in inclement weather.