当前位置:网站首页>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();
}
}
边栏推荐
- Jenkins post build script does not execute
- What are the 6% annualized products?
- Get the historical quotation data of all stocks
- Raspberry Pie: /bin/sh: 1: bison: not found
- [example] v-contextmenu right click menu component
- Detailed LinkedList
- Will your NFT disappear? Dfinity provides the best solution for NFT storage
- Spark Learning: how to choose different association forms and mechanisms?
- Development history of the first commercial humanoid biped robot in China
- Basic knowledge of PHP - complete collection of PHP functions
猜你喜欢

Where is the bitbucket clone address

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

Open source summer interview | learn with problems, Apache dolphin scheduler, Wang Fuzheng

Scarcity in Web3: how to become a winner in a decentralized world
![[don't bother to strengthen learning] video notes (II) 2. Write a small example of Q learning](/img/b1/d5c869bc68ba273be2030202f94a55.png)
[don't bother to strengthen learning] video notes (II) 2. Write a small example of Q learning

Embedded development: Tools - optimizing firmware using DRT

Code random notes_ Linked list_ Turn over the linked list in groups of 25K

Will your NFT disappear? Dfinity provides the best solution for NFT storage
![[note] what is kernel / user space? Let's start with how the CPU runs the program](/img/b5/0ab4f2841faf3573b4502d2cd09069.png)
[note] what is kernel / user space? Let's start with how the CPU runs the program

error: field ‘XXX’ declared as a function
随机推荐
Spark Learning: compile spark source code in win10
The difference between classification and regression
Use of jstack "JVM common commands"
Simple parsing JSON strings with regular expressions
Huawei wireless device security policy configuration command
Yarn: unable to load file
Firewall off and on command
《动手学深度学习》(七) -- 边界框和锚框
[don't bother with reinforcement learning] video notes (I) 2. Summary of reinforcement learning methods
JS 84*148=b6a8 how many decimal places can you make both sides equal
Scarcity in Web3: how to become a winner in a decentralized world
What's the difference between testing / developing programmers' professionalism and salted fish? They don't want to be excellent coders?
Understanding of magnetic parameters in Hall sensors
DSP development, using CCS software to establish engineering and burning
Spark Learning: a form of association in a distributed environment?
【笔记】什么是内核/用户空间 从CPU如何运行程序讲起
PHP log base - monolog knowledge collation
Tag the specified commit and submit the tag
Hucang integrated e-commerce project (I): introduction to the project background and structure
Basic knowledge of PHP - complete collection of PHP functions