英文:
Communication LoRa
问题
Transmitter Code (发射器代码):
#include "Arduino.h"
#include "LoRa_E32.h"
LoRa_E32 e32ttl100(&Serial2, UART_BPS_RATE_9600);
void setup() {
Serial.begin(9600);
delay(500);
// Startup all pins and UART
e32ttl100.begin();
Serial.println("Hi, I'm going to send messages every second!");
// Send first message
ResponseStatus rs = e32ttl100.sendMessage("Hello, world?");
// Check if message was sent successfully
if (rs.code == 1) {
Serial.println("Message sent successfully");
} else {
Serial.println("Failed to send message");
}
}
void loop() {
delay(2000);
// Send message
ResponseStatus rs = e32ttl100.sendMessage("Hello, world?");
// Check if message was sent successfully
if (rs.code == 1) {
Serial.println("Message sent successfully");
} else {
Serial.println("Failed to send message");
}
}
Receiver Code (接收器代码):
#include <SPI.h>
#include <LoRa.h>
#define ss 8
#define reset 4
#define dio0 7
void setup() {
Serial.begin(9600);
LoRa.setPins(ss, reset, dio0);
if (!LoRa.begin(868E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
// Set signal bandwidth to 125kHz
LoRa.setSignalBandwidth(125E3);
// Set TX power to 20dBm
LoRa.setTxPower(20);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
}
void loop() {
int packetSize = LoRa.parsePacket();
if (packetSize) {
// received a packet
Serial.print("Received packet with RSSI ");
Serial.print(LoRa.packetRssi());
Serial.print(": ");
while (LoRa.available()) {
Serial.write(LoRa.read());
}
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
}
These are the translated code sections for the transmitter and receiver. If you have any further questions or need assistance with the problem, please feel free to ask.
英文:
I have two LoRa modules, the transmitter is an E32-900T20D (with ESP32 DevKitC V4) and the receiver is a LoRa32U4. The problem is that the receiver is not receiving anything from the transmitter. Here is the code for the transmitter:
#include "Arduino.h"
#include "LoRa_E32.h"
LoRa_E32 e32ttl100(&Serial2,UART_BPS_RATE_9600 );
void setup() {
Serial.begin(9600);
delay(500);
// Startup all pins and UART
e32ttl100.begin();
Serial.println("Hi, I'm going to send messages every second!");
// Send first message
ResponseStatus rs = e32ttl100.sendMessage("Hello, world?");
// Check if message was sent successfully
if (rs.code == 1) {
Serial.println("Message sent successfully");
} else {
Serial.println("Failed to send message");
}
}
void loop() {
delay(2000);
// Send message
ResponseStatus rs = e32ttl100.sendMessage("Hello, world?");
// Check if message was sent successfully
if (rs.code == 1) {
Serial.println("Message sent successfully");
} else {
Serial.println("Failed to send message");
}
}
Here is the result of the transmitter:
>Hi, I'm going to send messages every second!
Message sent successfully
Message sent successfully
Message sent successfully
Here is the code for the receiver:
#include <SPI.h>
#include <LoRa.h>
#define ss 8
#define reset 4
#define dio0 7
void setup() {
Serial.begin(9600);
LoRa.setPins(ss, reset, dio0);
if (!LoRa.begin(868E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
// Set signal bandwidth to 125kHz
LoRa.setSignalBandwidth(125E3);
// Set TX power to 20dBm
LoRa.setTxPower(20);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
}
void loop() {
int packetSize = LoRa.parsePacket();
if (packetSize) {
// received a packet
Serial.print("Received packet with RSSI ");
Serial.print(LoRa.packetRssi());
Serial.print(": ");
while (LoRa.available()) {
Serial.write(LoRa.read());
}
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
}
Knowing that both are configured for 868 Mhz, what is the problem? Any help please?
答案1
得分: 2
Ebyte模块,如果由UART管理,实际上不是LoRa设备。它们的设置与常规LoRa模块不匹配。我一直怀疑它们使用FSK传输而不是LoRa。要么完全使用Ebyte生态系统,要么不用。不要混合非Ebyte和Ebyte模块,因为如果这样做,你只会确保带来困扰。
英文:
Ebyte modules that are UART-managed are not really LoRa devices. Their settings do not match that of regular LoRa modules. I have long suspected that they use FSK transmission instead of LoRa. Stay entirely within the Ebyte ecosystem, or out. Do not mix non-Ebyte and Ebyte modules, because if you do, all you will ensure is misery.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论