|
STM32F103C8T6ST(意法半导体)
|
x 1 | |
|
LoRa RA-02 SX1278 433MHz Ai-Thinker |
x 1 | |
|
BME280Bosch Tools
|
x 1 | |
|
Generic BreadboardVarious
|
x 1 | |
|
AGHGH28K305JST Sales America Inc.
|
x 1 |
|
EasyEDA software |
LoRa-based Weather&Environmental Monitoring System using STM32
Long-Range Wireless Sensor Communication System Using LoRa and STM32
Project Overview
I developed a long-range wireless sensor communication system using LoRa (Long Range) technology, specifically utilizing the SX1278 RF module paired with STM32 Bluepill microcontrollers. My goal was to create a reliable wireless sensor network capable of transmitting environmental data over significant distances - up to 5km in optimal conditions.
Why I Built This
I was fascinated by the potential of LoRa technology for IoT applications, particularly its ability to transmit data over long distances while maintaining low power consumption. The project emerged from my desire to:
- Create a cost-effective long-range wireless communication system
- Develop practical experience with LoRa technology
- Build a scalable platform for environmental monitoring
- Learn about integrating different communication protocols (SPI, I2C) in a single project
Technical Implementation
System Architecture
Circuit Design
Key Technical Features
1. Communication Protocols
- SPI for LoRa module communication
- I2C for BME280 sensor interface
2. Frequency Specifications
- Operating Frequency: 433MHz
- Frequency Range: 420-450MHz
- Signal Sensitivity: -148 dBm
- Power Output: +20 dBm
3. Range and Performance
- Transmission Distance: Up to 5km (optimal conditions)
- High reliability with frequency hopping
- Low power consumption
Results and Applications
My system successfully achieved:
- Reliable long-range wireless communication
- Accurate environmental data transmission
- Low power consumption
- Cost-effective implementation
This project has practical applications in:
- Environmental monitoring
- Agricultural sensing
- Industrial IoT
- Remote data collection
Technical Challenges and Solutions
During development, I encountered several challenges:
1. Library Compatibility: The standard Arduino LoRa library wasn't compatible with STM32. I solved this by using a modified STM32-specific library.
2. Frequency Regulations: Different regions have different frequency regulations. I addressed this by making the frequency configurable (433MHz/915MHz) based on regional requirements.
3. Signal Quality: To optimize signal quality, I implemented:
- Frequency hopping
- Proper antenna placement
- Power output optimization
Future Improvements
I plan to enhance the system with:
1. Multi-node networking capabilities
2. Solar power integration
3. Weather-resistant enclosure design
4. Web-based data visualization
#include <Wire.h>
#include <SPI.h>
#include <LoRa_STM32.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define NSS PA4
#define RST PB0
#define DI0 PA1
#define TX_P 17
#define BAND 433E6
#define ENCRYPT 0x78
int counter = 0;
String LoRaMessage = "";
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme;
void setup()
{
Serial.begin(115200);
while (!Serial);
Serial.println(F("LoRa Sender"));
//LoRa.setTxPower(TX_P);
LoRa.setSyncWord(ENCRYPT);
LoRa.setPins(NSS, RST, DI0);
if (!LoRa.begin(BAND))
{
Serial.println(F("Starting LoRa failed!"));
while (1);
}
if (!bme.begin(0x76))
{
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
void loop()
{
float temperature = bme.readTemperature();
float pressure = bme.readPressure() / 100.0F;
float altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
float humidity = bme.readHumidity();
Serial.print(F("Sending packet: "));
Serial.println(counter);
Serial.print(F("Temperature = "));
Serial.print(temperature);
Serial.println(F("*C"));
Serial.print(F("Pressure = "));
Serial.print(pressure);
Serial.println(F("hPa"));
Serial.print(F("Approx. Altitude = "));
Serial.print(altitude);
Serial.println(F("m"));
Serial.print(F("Humidity = "));
Serial.print(humidity);
Serial.println(F("%"));
Serial.println();
LoRaMessage = String(counter) + "/" + String(temperature) + "&" + String(pressure) + "#" + String(altitude) + "@" + String(humidity);
// send packet
LoRa.beginPacket();
LoRa.print(LoRaMessage);
LoRa.endPacket();
counter++;
delay(3000);
}
#include <SPI.h>
#include <LoRa_STM32.h>
#define SS PA4
#define RST PB0
#define DI0 PA1
#define TX_P 17
#define BAND 433E6
#define ENCRYPT 0x78
String counter;
String temperature;
String pressure;
String altitude;
String humidity;
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 (1);
}
}
void loop() {
// try to parse packet
int pos1,pos2,pos3,pos4;
int packetSize = LoRa.parsePacket();
if (packetSize)
{
// received a packet
Serial.print("Received packet: ");
String LoRaData = LoRa.readString();
Serial.print(LoRaData);
// read packet
while (LoRa.available()) {
Serial.print((char)LoRa.read());
}
// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi());
pos1 = LoRaData.indexOf('/');
pos2 = LoRaData.indexOf('&');
pos3 = LoRaData.indexOf('#');
pos4 = LoRaData.indexOf('@');
counter = LoRaData.substring(0, pos1);
temperature = LoRaData.substring(pos1+1,pos2);
pressure = LoRaData.substring(pos2+1,pos3);
altitude = LoRaData.substring(pos3+1,pos4);
humidity = LoRaData.substring(pos4+1,LoRaData.length());
Serial.print(F("Packet No. = "));
Serial.println(counter);
Serial.print(F("Temperature = "));
Serial.print(temperature);
Serial.println(F("*C"));
Serial.print(F("Pressure = "));
Serial.print(pressure);
Serial.println(F("hPa"));
Serial.print(F("Approx. Altitude = "));
Serial.print(altitude);
Serial.println(F("m"));
Serial.print(F("Humidity = "));
Serial.print(humidity);
Serial.println(F("%"));
Serial.println();
}
}
LoRa-based Weather&Environmental Monitoring System using STM32
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(0)
- Likes(0)
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10