Communication LoRa

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

Communication LoRa

问题

Transmitter Code (发射器代码):

  1. #include "Arduino.h"
  2. #include "LoRa_E32.h"
  3. LoRa_E32 e32ttl100(&Serial2, UART_BPS_RATE_9600);
  4. void setup() {
  5. Serial.begin(9600);
  6. delay(500);
  7. // Startup all pins and UART
  8. e32ttl100.begin();
  9. Serial.println("Hi, I'm going to send messages every second!");
  10. // Send first message
  11. ResponseStatus rs = e32ttl100.sendMessage("Hello, world?");
  12. // Check if message was sent successfully
  13. if (rs.code == 1) {
  14. Serial.println("Message sent successfully");
  15. } else {
  16. Serial.println("Failed to send message");
  17. }
  18. }
  19. void loop() {
  20. delay(2000);
  21. // Send message
  22. ResponseStatus rs = e32ttl100.sendMessage("Hello, world?");
  23. // Check if message was sent successfully
  24. if (rs.code == 1) {
  25. Serial.println("Message sent successfully");
  26. } else {
  27. Serial.println("Failed to send message");
  28. }
  29. }

Receiver Code (接收器代码):

  1. #include <SPI.h>
  2. #include <LoRa.h>
  3. #define ss 8
  4. #define reset 4
  5. #define dio0 7
  6. void setup() {
  7. Serial.begin(9600);
  8. LoRa.setPins(ss, reset, dio0);
  9. if (!LoRa.begin(868E6)) {
  10. Serial.println("Starting LoRa failed!");
  11. while (1);
  12. }
  13. // Set signal bandwidth to 125kHz
  14. LoRa.setSignalBandwidth(125E3);
  15. // Set TX power to 20dBm
  16. LoRa.setTxPower(20);
  17. pinMode(LED_BUILTIN, OUTPUT);
  18. digitalWrite(LED_BUILTIN, HIGH);
  19. }
  20. void loop() {
  21. int packetSize = LoRa.parsePacket();
  22. if (packetSize) {
  23. // received a packet
  24. Serial.print("Received packet with RSSI ");
  25. Serial.print(LoRa.packetRssi());
  26. Serial.print(": ");
  27. while (LoRa.available()) {
  28. Serial.write(LoRa.read());
  29. }
  30. digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
  31. }
  32. }

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:

  1. #include &quot;Arduino.h&quot;
  2. #include &quot;LoRa_E32.h&quot;
  3. LoRa_E32 e32ttl100(&amp;Serial2,UART_BPS_RATE_9600 );
  4. void setup() {
  5. Serial.begin(9600);
  6. delay(500);
  7. // Startup all pins and UART
  8. e32ttl100.begin();
  9. Serial.println(&quot;Hi, I&#39;m going to send messages every second!&quot;);
  10. // Send first message
  11. ResponseStatus rs = e32ttl100.sendMessage(&quot;Hello, world?&quot;);
  12. // Check if message was sent successfully
  13. if (rs.code == 1) {
  14. Serial.println(&quot;Message sent successfully&quot;);
  15. } else {
  16. Serial.println(&quot;Failed to send message&quot;);
  17. }
  18. }
  19. void loop() {
  20. delay(2000);
  21. // Send message
  22. ResponseStatus rs = e32ttl100.sendMessage(&quot;Hello, world?&quot;);
  23. // Check if message was sent successfully
  24. if (rs.code == 1) {
  25. Serial.println(&quot;Message sent successfully&quot;);
  26. } else {
  27. Serial.println(&quot;Failed to send message&quot;);
  28. }
  29. }

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:

  1. #include &lt;SPI.h&gt;
  2. #include &lt;LoRa.h&gt;
  3. #define ss 8
  4. #define reset 4
  5. #define dio0 7
  6. void setup() {
  7. Serial.begin(9600);
  8. LoRa.setPins(ss, reset, dio0);
  9. if (!LoRa.begin(868E6)) {
  10. Serial.println(&quot;Starting LoRa failed!&quot;);
  11. while (1);
  12. }
  13. // Set signal bandwidth to 125kHz
  14. LoRa.setSignalBandwidth(125E3);
  15. // Set TX power to 20dBm
  16. LoRa.setTxPower(20);
  17. pinMode(LED_BUILTIN, OUTPUT);
  18. digitalWrite(LED_BUILTIN, HIGH);
  19. }
  20. void loop() {
  21. int packetSize = LoRa.parsePacket();
  22. if (packetSize) {
  23. // received a packet
  24. Serial.print(&quot;Received packet with RSSI &quot;);
  25. Serial.print(LoRa.packetRssi());
  26. Serial.print(&quot;: &quot;);
  27. while (LoRa.available()) {
  28. Serial.write(LoRa.read());
  29. }
  30. digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
  31. }
  32. }

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:

确定