LoRa/IoT B.Tech/Diploma Beginner

Interfacing LoRa SX1276 with STM32 Microcontroller | LR1276-915MHz

Interface Gplus-IoT LoRa Module LR1276 915MHz with STM32 microcontroller or SX1276 with STM32F103C & DHT11 Sensor Code as Sender and Receiver

  • Suitable forB.Tech/Diploma LoRa/IoT students
  • Build time1-2 weeks
  • LevelBeginner
  • Available atAjvika Labs, Kakinada

About this project

Overview
In this tutorial, we will learn
Interfacing of LoRa Module SX1276 with STM32
Bluepill Microcontroller. The
LR1276UA-A-915
module uses SX1276 IC and works on a
915MHz
frequency. Using the Frequency hopping, it gives the sweet balance of quality signal transmission will cover a range of 915MHz. The LoRa LR1276/SX1276 works with SPI communication protocol so it can be used with any microcontroller that supports
SPI
. The SX1276 or LR1276 module can be easily interfaced with the STM32F103 chip.
Earlier we used Reyax LoRa module
RYLR890/RYLR896
with Arduino. You can go through the post as well. The Reyax RYLR890 LoRa module works on UART Communication and has some communication breakage while testing. But
Gplus-IoT LR1276
is an SPI Module with better performance similar to
LoRa SX1278
Module.
The tutorial consists of two
examples
. In the first example, we will send a simple “
Hello World
” message from LoRa Sender/Transmitter to Receiver. But in the second example, we will send the sensor data wirelessly. The
DHT11 Humidity Temperature sensor
is best suited for the testing application. The
STM32 LoRa Sender
will send the sensor data to the
STM32 LoRa Receiver
Bill of Materials
All the components required for this tutorial are given below along with the purchase link.
S.N.
Components Name
Quantity
Purchase Links

STM32 Microcontroller

Amazon
AliExpress

LoRa Module LR1276/SX1276

Gplus-IoT on TECHDesign

DHT11 Sensor

Amazon
AliExpress

3.7V Lithium-Battery

Amazon
AliExpress

0.96" I2C OLED Display

Amazon
AliExpress

Connecting Wires

Amazon
AliExpress

Breadboard

Amazon
AliExpress
LoRa Module LR1276/SX1276
The LR1276 module is designed based on SX1276. The SX1276 incorporates the LoRa spread spectrum modem which is capable of achieving a significantly longer range than existing systems based on FSK or OOK modulation. At maximum data rates of LoRa, the sensitivity is 8dB better than FSK. But using a low-cost bill of materials with a 2Oppm XTAL LoRa can improve receiver sensitivity by more than 20dB compared to FSK.
LoRa also provides significant advances in selectivity and blocking performance, further improving communication reliability. For maximum flexibility the user may decide on the spread spectrum modulation bandwidth (BW), spreading factor (SF), and error correction rate (CR). Another benefit of the spread modulation is that each spreading factor is orthogonal. It means multiple transmitted signals can occupy the same channel without interfering.
This also permits simple coexistence with existing FSK-based systems. Standard GFSK, FSK, 00K, and GMSK modulation is also provided to allow compatibility with existing systems or standards such as wireless MBUS and IEEE 802.15.4g.
LR1276/SX1276 Features
LoRa Modem
168 dB maximum link budget
+20 dBm – 100 mW constant RF output vs. V supply
+14 dBm high efficiency PA
Programmable bit rate up to 300 kbps
High sensitivity: down to -148 dBm
Bullet-proof front end: IIP3 = -11 dBm
Excellent blocking immunity
Operating Voltage 1.8-3.7V
Low RX current of 9.9 mA, 200 nA register retention
Fully integrated synthesizer with a resolution of 61 Hz
FSK, GFSK, MSK, GMSK, LoRaTMand 00K modulation
Built-in bit synchronizer for clock recovery
Preamble detection
127 dB Dynamic Range RSSI
Automatic RF Sense and CAD with ultra-fast AFC
Packet engine up to 256 bytes with CRC
Built-in temperature sensor and low battery indicator
Applications
Automated Meter Reading.
Home and Building Automation.
Wireless Alarm and Security Systems.
Industrial Monitoring and Control
Long-range Irrigation System
LR1276/SX1276 Pinout
The Gplus-IoT LoRa Module LR1276 has total 18 pins which functionalities are as follows:
Designing LR1276 Breakout Board
The Gplus-IoT LR1276 chip is very tiny in size so its very difficult to interface it with any controller. So I designed a small breakout board using EasyEDA software and converted it into a PCB. The PCB layout looks something like this.
The Gerber File for the PCB is given below. You can simply download the Gerber File and order the PCB from
ALLPCB
at
1$
only.
Download Gerber File:
LR1276 Breakout PCB
You can use this Gerber file to order high quality PCB for this project. To do that visit the
ALLPCB
official website by clicking here:
https://www.allpcb.com/
You can now upload the Gerber File by choosing the Quote Now option. From these options, you can choose the Material Type, Dimensions, Quantity, Thickness, Solder Mask Color and other required parameters.
After filling all details, select your country and shipping method. Finally you can place the order.
Then I soldered the LR1276 chip into the PCB. The SX1276 chip has a very small gap between the two consecutive pins. So it requires good soldering skills for soldering the components.
LoRa Library for STM32
The Arduino LoRa Library is not supported by
STM32F103 Board
. That is why there is a modified library for STM32F103 Board for Arduino IDE. The STM32 LoRa library is used for sending and receiving data using
LoRa radios
This library exposes the LoRa radio directly and allows you to send data to any radios in range with the same radio parameters. All data is broadcasted and there is no addressing.
Download:
STM32 LoRa Library
Interfacing Gplus-IoT LoRa LR1276/SX1276 with STM32
Schematic & Connection
Now let us interface LoRa Module LR1276/SX1276 with STM32F103C Board and make a simple STM32 LoRa Sender Receiver Device. The connection between SX1276 & STM32F103 is as follows:
The schematic is given below. You can assemble the pair of circuits on the breadboard. One of the circuits will act as a transmitter or sender and the other as a receiver.
Sender Code

#include <SPI.h>
#include <LoRa_STM32.h>
#define SS PA4
#define RST PB0
#define DI0 PA1
#define TX_P 17
#define BAND 915E6
#define ENCRYPT 0x78
int
counter
=

;
void
setup
(
)
{
Serial
begin
(
115200
)
;
while
(
!
Serial
)
;
Serial
println
(
"LoRa Sender"
)
;
LoRa
setTxPower
(
TX_P
)
;
LoRa
setSyncWord
(
ENCRYPT
)
;
LoRa
setPins
(
SS
RST
DI0
)
;
if
(
!
LoRa
begin
(
BAND
)
)
{
Serial
println
(
"Starting LoRa failed!"
)
;
while
(

)
;
}
}
void
loop
(
)
{
Serial
(
"Sending packet: "
)
;
Serial
println
(
counter
)
;
// send packet
LoRa
beginPacket
(
)
;
LoRa
(
"hello "
)
;
LoRa
(
counter
)
;
LoRa
endPacket
(
)
;
counter
++
;
delay
(
5000
)
;
}
Receiver Code

#include <SPI.h>
#include <LoRa_STM32.h>
#define SS PA4
#define RST PB0
#define DI0 PA1
#define TX_P 17
#define BAND 915E6
#define ENCRYPT 0x78
void
setup
(
)
{
Serial
begin
(
115200
)
;
while
(
!
Serial
)
;
Serial
println
(
"LoRa Receiver"
)
;
LoRa
setTxPower
(
TX_P
)
;
LoRa
setSyncWord
(
ENCRYPT
)
;
LoRa
setPins
(
SS
RST
DI0
)
;
if
(
!
LoRa
begin
(
BAND
)
)
{
Serial
println
(
"Starting LoRa failed!"
)
;
while
(

)
;
}
}
void
loop
(
)
{
// try to parse packet
int
packetSize
=
LoRa
parsePacket
(
)
;
if
(
packetSize
)
{
// received a packet
Serial
(
"Received packet '"
)
;
// read packet
while
(
LoRa
available
(
)
)
{
Serial
(
(
char
)
LoRa
read
(
)
)
;
}
// print RSSI of packet
Serial
(
"' with RSSI "
)
;
Serial
println
(
LoRa
packetRssi
(
)
)
;
}
}
Testing & Result
Once code is uploaded, open the Serial Monitor for both transmitter and receiver. The sender will send some data which is received by receiver.
Sending Sensor Data Wirelessly using LoRa Module
Schematic & Connection
Let us go through the second example now. In this example, we will be Interfacing SX1276 with STM32 and DHT11 sensor to the Sender Circuit. The DHT11 is a basic, ultra low-cost digital temperature and h

Technologies used

ArduinoSTM32LoRaBLEDHT11OLEDI2CSPIUARTADCArduino IDE

Hardware components

  • Arduino
  • STM32
  • DHT11
  • OLED
  • LoRa SX1278
  • SX1276

Software & tools

  • Arduino IDE
  • EasyEDA

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.