Communication LoRa

huangapple go评论54阅读模式
英文:

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 &quot;Arduino.h&quot;
#include &quot;LoRa_E32.h&quot;

LoRa_E32 e32ttl100(&amp;Serial2,UART_BPS_RATE_9600 ); 

void setup() {
  Serial.begin(9600);
  delay(500);
  // Startup all pins and UART
  e32ttl100.begin();
  Serial.println(&quot;Hi, I&#39;m going to send messages every second!&quot;);
  // Send first message
  ResponseStatus rs = e32ttl100.sendMessage(&quot;Hello, world?&quot;);
  // Check if message was sent successfully
  if (rs.code == 1) {
    Serial.println(&quot;Message sent successfully&quot;);
  } else {
    Serial.println(&quot;Failed to send message&quot;);
  }
}

void loop() {
  delay(2000); 
  // Send message
  ResponseStatus rs = e32ttl100.sendMessage(&quot;Hello, world?&quot;);
  // Check if message was sent successfully
  if (rs.code == 1) {
    Serial.println(&quot;Message sent successfully&quot;);
  } else {
    Serial.println(&quot;Failed to send message&quot;);
  }
}

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 &lt;SPI.h&gt;
#include &lt;LoRa.h&gt;

#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(&quot;Starting LoRa failed!&quot;);
    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(&quot;Received packet with RSSI &quot;);
    Serial.print(LoRa.packetRssi());
    Serial.print(&quot;: &quot;);
    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.

huangapple
  • 本文由 发表于 2023年4月19日 17:54:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76053132.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定