-
-
Notifications
You must be signed in to change notification settings - Fork 659
Closed
Description
Hi,
I'm testing out my LoRa connectivity using duplex example.
It seems everything up to sending is great! But I can't receive from both modules.
Both modules run this code :
#include <SPI.h> // include libraries
#include <LoRa.h>
//setTxPower
const int csPin = D1; // LoRa radio chip select
const int resetPin = D2; // LoRa radio reset
const int irqPin = D0; // change for your board; must be a hardware interrupt pin
#define dev1
#ifdef dev1
#define LOCAL_ADDR 0xBB
#define DEST_ADDR 0xFF
#else
#define LOCAL_ADDR 0xFF
#define DEST_ADDR 0xBB
#endif
String outgoing; // outgoing message
byte msgCount = 0; // count of outgoing messages
byte localAddress = LOCAL_ADDR; // address of this device
byte destination = DEST_ADDR; // destination to send to
long lastSendTime = 0; // last send time
int interval = 2000; // interval between sends
void onReceive(int packetSize);
void sendMessage(String outgoing);
void setup()
{
Serial.begin(115200); // initialize serial
Serial.println("LoRa Duplex with callback");
// override the default CS, reset, and IRQ pins (optional)
LoRa.setPins(csPin, resetPin, irqPin); // set CS, reset, IRQ pin
if (!LoRa.begin(433E6))
{ // initialize ratio at 915 MHz
Serial.println("LoRa init failed. Check your connections.");
while (true)
; // if failed, do nothing
}
LoRa.setTxPower(10);
LoRa.onReceive(onReceive);
LoRa.receive();
Serial.println("LoRa init succeeded.");
LoRa.dumpRegisters(Serial);
}
void loop()
{
if (millis() - lastSendTime > interval)
{
String message = "HeLoRa World!"; // send a message
sendMessage(message);
Serial.println("Sending " + message);
lastSendTime = millis(); // timestamp the message
interval = random(2000) + 1000; // 2-3 seconds
LoRa.receive(); // go back into receive mode
}
}
void sendMessage(String outgoing)
{
LoRa.beginPacket(); // start packet
LoRa.write(destination); // add destination address
LoRa.write(localAddress); // add sender address
LoRa.write(msgCount); // add message ID
LoRa.write(outgoing.length()); // add payload length
LoRa.print(outgoing); // add payload
LoRa.endPacket(); // finish packet and send it
msgCount++; // increment message ID
}
void onReceive(int packetSize)
{
if (packetSize == 0)
return; // if there's no packet, return
// read packet header bytes:
int recipient = LoRa.read(); // recipient address
byte sender = LoRa.read(); // sender address
byte incomingMsgId = LoRa.read(); // incoming msg ID
byte incomingLength = LoRa.read(); // incoming msg length
String incoming = ""; // payload of packet
while (LoRa.available())
{ // can't use readString() in callback, so
incoming += (char)LoRa.read(); // add bytes one by one
}
if (incomingLength != incoming.length())
{ // check length for error
Serial.println("error: message length does not match length");
return; // skip rest of function
}
// if the recipient isn't this device or broadcast,
if (recipient != localAddress && recipient != LOCAL_ADDR)
{
Serial.println("This message is not for me.");
return; // skip rest of function
}
// if message is for this device, or broadcast, print details:
Serial.println("Received from: 0x" + String(sender, HEX));
Serial.println("Sent to: 0x" + String(recipient, HEX));
Serial.println("Message ID: " + String(incomingMsgId));
Serial.println("Message length: " + String(incomingLength));
Serial.println("Message: " + incoming);
Serial.println("RSSI: " + String(LoRa.packetRssi()));
Serial.println("Snr: " + String(LoRa.packetSnr()));
Serial.println();
}
Output (mainly for LoRa.dumpRegisters(Serial);
:
dev1 :
LoRa Duplex with callback
LoRa init succeeded.
0x0: 0xFF
0x1: 0x85
0x2: 0x1A
0x3: 0xB
0x4: 0x0
0x5: 0x52
0x6: 0x6C
0x7: 0x40
0x8: 0x0
0x9: 0x88
0xA: 0x9
0xB: 0x2B
0xC: 0x23
0xD: 0x1
0xE: 0x0
0xF: 0x0
0x10: 0x0
0x11: 0x0
0x12: 0x0
0x13: 0x0
0x14: 0x0
0x15: 0x0
0x16: 0x0
0x17: 0x0
0x18: 0x4
0x19: 0x0
0x1A: 0x0
0x1B: 0x2B
0x1C: 0x0
0x1D: 0x72
0x1E: 0x70
0x1F: 0x64
0x20: 0x0
0x21: 0x8
0x22: 0x1
0x23: 0xFF
0x24: 0x0
0x25: 0x0
0x26: 0x4
0x27: 0x0
0x28: 0x0
0x29: 0x0
0x2A: 0x0
0x2B: 0x0
0x2C: 0xE
0x2D: 0x50
0x2E: 0x14
0x2F: 0x45
0x30: 0x55
0x31: 0xC3
0x32: 0x5
0x33: 0x27
0x34: 0x1C
0x35: 0xA
0x36: 0x3
0x37: 0xA
0x38: 0x42
0x39: 0x12
0x3A: 0x52
0x3B: 0x1D
0x3C: 0x0
0x3D: 0xAF
0x3E: 0x0
0x3F: 0x0
0x40: 0x0
0x41: 0x0
0x42: 0x12
0x43: 0x24
0x44: 0x2D
0x45: 0x0
0x46: 0x3
0x47: 0x0
0x48: 0x4
0x49: 0x23
0x4A: 0x0
0x4B: 0x9
0x4C: 0x5
0x4D: 0x84
0x4E: 0x32
0x4F: 0x2B
0x50: 0x14
0x51: 0x0
0x52: 0x0
0x53: 0x10
0x54: 0x0
0x55: 0x0
0x56: 0x0
0x57: 0xF
0x58: 0xE0
0x59: 0x0
0x5A: 0xC
0x5B: 0xE5
0x5C: 0x6
0x5D: 0x0
0x5E: 0x5C
0x5F: 0x78
0x60: 0x0
0x61: 0x1C
0x62: 0xE
0x63: 0x5B
0x64: 0xCC
0x65: 0x0
0x66: 0x1
0x67: 0x50
0x68: 0x0
0x69: 0x0
0x6A: 0x0
0x6B: 0x0
0x6C: 0x0
0x6D: 0x0
0x6E: 0x0
0x6F: 0xB
0x70: 0xD0
0x71: 0x0
0x72: 0x13
0x73: 0x0
0x74: 0x0
0x75: 0x0
0x76: 0x0
0x77: 0x0
0x78: 0x0
0x79: 0x0
0x7A: 0x0
0x7B: 0x0
0x7C: 0x0
0x7D: 0x0
0x7E: 0x0
0x7F: 0x0
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
dev2 :
LoRa init succeeded.
0x0: 0xFF
0x1: 0x85
0x2: 0x1A
0x3: 0xB
0x4: 0x0
0x5: 0x52
0x6: 0x6C
0x7: 0x40
0x8: 0x0
0x9: 0x88
0xA: 0x9
0xB: 0x2B
0xC: 0x23
0xD: 0x1
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x7A: 0x0
0x7B: 0x0
0x7C: 0x0
0x7D: 0x0
0x7E: 0x0
0x7F: 0x0
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
Sending HeLoRa World!
By comparing, it seems 2 modules differs in 3 registers :
- 2C
- 53
- 5B
What might be my problem ?
could it be the soldered antenna ? 433Mhz antenna. but originally ipx terminal, I've cut it and soldered it to the pin.
Any ideas ?
UPDATE : I've checked out antenna, There's one antenna was shorted to gnd, I've fixed it.
But until now, No module is receiving a message.
Metadata
Metadata
Assignees
Labels
No labels