当前位置:网站首页>Arduino drive Lora module master node
Arduino drive Lora module master node
2022-07-24 09:46:00 【Jiang tengxia】
1、LoRa Module configuration
I bought the module punctual atom Lora sx1278 Use serial port protocol to realize data transmission , It's convenient to configure it .
This is the attached upper computer software , According to the manual given by the merchant, configure it in minutes according to your own needs .
matters needing attention :
(1) The transmission power should not be too high , It will cause the signal to be too accurate , Not easy to receive .
(2) Module address 、 The communication channel and baud rate should be consistent .
(3) When it comes to configuration , The baud rate above must be selected 115200, Otherwise it will prompt Connection timeout .
2、Arduino uno Code
#include <SoftwareSerial.h> / Soft string oral documents
#include <dht11.h> // Import dht11 The header file
#define DhtPIN A0 //dht11 Controlled port
SoftwareSerial LoRa_Serial(2, 3); // RX, TX // Simulate a soft serial port , The development board accepts LoRa The signal received by the module
dht11 DHT11; // Substantiation dht11 Class , Name it :DHT11
String comdata = ""; // The received string
char str_chk[] = "chk =";
char str_temp[] = "temp =";
char str_hum[] = "Hum =";
long previousMillis = millis(); // Last activation time
long interval = 5000; // interval
void Receive_Data() {
while (LoRa_Serial.available() > 0) {
// Come here with the data
comdata += char(LoRa_Serial.read());
delay(2);
}
Serial.print("comdata = ");
Serial.println(comdata); // Print information
comdata = ""; // Receive information return 0
}
void Send_Data() {
float res_temp = 0.0;
float res_hum = 0.0;
DHT11.read(DhtPIN); // Read sensor data
res_temp = (float)DHT11.temperature;
res_hum = (float)DHT11.humidity;
if (res_temp >= 0 && res_hum > 0) {
LoRa_Serial.print("temp = ");// Serial port print results , Easy to observe and debug
LoRa_Serial.print(res_temp);// Serial port print results , Easy to observe and debug
LoRa_Serial.print(",Hum = ");// Serial port print results , Easy to observe and debug
LoRa_Serial.println(res_hum);// Serial port print results , Easy to observe and debug
}
}
void setup() {
// put your setup code here, to run once:
pinMode(DhtPIN, OUTPUT); // Set up dht11 Port mode is output
Serial.begin(9600);// Initialize port continuous communication from baud rate 9600 Start
Serial.println("hardware seriall!");
Serial.begin(9600);
Serial.println("software serial!");
}
void loop() {
// put your main code here, to run repeatedly:
if (LoRa_Serial.available()) {
Receive_Data();
}
if (millis() - previousMillis > interval) {
Send_Data();
previousMillis = millis();
}
}
边栏推荐
- [don't bother to strengthen learning] video notes (IV) 2. Dqn realizes maze walking
- Dark king | analysis of zego low illumination image enhancement technology
- 【笔记】什么是内核/用户空间 从CPU如何运行程序讲起
- MySQL query database capacity size
- CAS principle [concurrent programming]
- Recursion - if the function calls itself internally, then the function is a recursive function & the effect is the same as that of the loop & the push condition return should be added, otherwise stack
- Add SSH key to bitbucket
- Build practical product help documents to improve user satisfaction
- Friends come to interview a unicorn company in Beijing at leisure. The interview question is priced at 25K
- What is the cloud native mid platform business architecture?
猜你喜欢

MySQL query database capacity size
![[don't bother to strengthen learning] video notes (III) 3. SARS (lambda)](/img/3b/981bd564a5855a317ccdd4800871ce.png)
[don't bother to strengthen learning] video notes (III) 3. SARS (lambda)

Common evaluation indexes of medical image segmentation

缓冲区的概念真的理解么?带你揭开缓冲区的面纱~

Web page opening speed is very slow, how to solve it?

Raspberry Pie: serial port login does not display print information

What if path is deleted by mistake when configuring system environment variables?

It's eleven again. Those jokes about nagging programmers going home for blind dates

Hands on deep learning (VII) -- bounding box and anchor box

C#/VB. Net: convert word or EXCEL documents to text
随机推荐
Wenxin big model raises a new "sail", and the tide of industrial application has arrived
An article takes you to understand the operation of C language files in simple terms
PHP debugging tool - socketlog installation and usage
Anti shake and throttling
Spark Learning: Spark implementation of distcp
Firewalld firewall related commands
Tag the specified commit and submit the tag
07 Jason module
Web page opening speed is very slow, how to solve it?
Detailed LinkedList
Huawei wireless device security policy configuration command
Friends come to interview a unicorn company in Beijing at leisure. The interview question is priced at 25K
[robot learning] mechanism kinematics analysis and MATLAB simulation (3D model +word report +matlab program)
Openstack network neutron knowledge point "openstack"
ASI-20220222-Implicit PendingIntent
Gin framework uses session and redis to realize distributed session & Gorm operation mysql
Hucang integrated e-commerce project (I): introduction to the project background and structure
ThreeJs
Color recognition of regions of interest in pictures and videos based on OpenCV
MySQL query database capacity size