Introduction
In the previous article we have seen how to program Nucleo board using MBED OS and ran a LED blinking application. In this article, we will see how to transmit and receive wireless messages using Lora communication and observe the result
Software used
- STM32Cube IDE with STM32WL package
- Teraterm
Source code
For this example, I used the demo example available in the STM32WL package. STM32CubeWL/Projects/NUCLEO-WL55JC/Applications/SubGHz_Phy/SubGHz_Phy_PingPong at main · STMicroelectronics/STM32CubeWL (github.com)
Test
Running the example code is pretty much straight forward. Right now, we are not going to change any parameters. Except the RF frequency according to your country of course.
Note:
- Modify the RF_FREQUENCY parameter in subghz_phy_app.h.
- Currently the Output Tx power is set to 14, which we need to increase to improve the signal quality.
- Example provides a simple way to switch between using LoRa and generic FSK modulation by setting USE_MODEM_LORA and USE_MODEM_FSK to (1,0) or (0,1).
Working process
The example requires two nodes to act as master and slave. Nodes to act as either master or slave will be selected at runtime automatically. The master node will send “PING” and slave node will send “PONG” in response.
Scenario 1:
I placed the two nodes on top of each other and the signal strength is really good as expected. (Got 1dbm on one node and 0 on another).
Scenario 2:
When I kept one node nearly 25m away from another, the signal strength dropped to 60.
Observation
When I brought the node near another one, the signal response was inversely proportional to the distance and nearly produced the relationship according to the formula mentioned in LoRa specification.
To get a RSSI of ~60, the distance between two nodes must be around 30m.
This is an interesting finding as we can use the RSSI and AoA (angle of arrival) to calculate the distance and position of any moving object with LoRa with near accuracy without the need for triangulation as required in other wireless based beacon systems.
Conclusion
So far, we were able to transmit and receive data packets using LoRa protocol and compared the signal strength. In upcoming blogs, we will see real world applications and how external factors influence the performance of LoRa on outdoor setup.