I have tried to connect two RN2483 devices ( mounted on a TTU board) to my LoRaWan gateway (Kerlink IOT station), the connection went successful through setting up the nodes as abp, however, in order to test the LoRaWan stack I would like to send something from one node to the other, I have read here that there are two possibilities, one is just testing the LoRa modulation and the other the whole stack.
That last case is the one I would be interested on, so I was wondering if someone could enlight me a bit concerning to that point. So far I can send out data from one node to the LoRaWan gateway, nevertheless I don’t see that message being received into the second node.
I have been looking the reference manual from RN2483 rn2483.pdf (362.3 KB) so as to find a commnand that read the data given from LoRa stack and not just at LoRa modulation level (command Serial1.println(“radio rx 0”)) but I cannot find it. Any suggestions?
You have to use IQ inversion the correct way. Take a look at the command manual, it describes a bit how to use is.
radio iqi on/off
oh, that was not the question… I don’t think you can interfere with the LoRaWAN protocol inside the RN2483. You should use the raw lora modulation (or (g)fsk) with ‘radio’ commands.
To use just the Lora stack you must send the “mac pause” command and then you can use “radio rx 0”.
To return to LoraWAN mode you must send “mac resume”.
If you are going to use radio rx 0 you can set “radio set wdt 2000” to set the timeout to wait for a rx packet. If you plan to do continuous reception you should set “radio set wdt 0”.
I’ve test it and works fine. Remember that if you are using LoraWAN in (adr) Adaptive Data Rate the radio will retain the last channel settings,
@a.valero I don’t really get you, as far as I understood using mac pause means that you do not use LoRaWan stack and mac resume means you do use LoRaWan stack (according to rn2483.pdf (362.3 KB) page 22)
Thus in briefly my tx should be something like below, if I send a FF ?
Hi again, I have coded this small receiver and transmitter, however I am struggling becuase I don’t see in my receiver what supposed being sent.
TX side where message is a string (HI)
text = "Node " + nodeAddress + " sending: " + message + "\n";
Serial.print(text);
//using the LoRa modulation to reach other node instead the LoRaWan stack
//stopping the LoRaWan stack on the device
Serial1.write("mac pause\r\n");
Serial1.write("radio tx 1");
Serial1.print(message);
Thus in the serial I got
Node 103 sending: HI
Node 103 sending: HI
Node 103 sending: HI
Node 103 sending: HI
My RX is
int rx = 0;
Serial1.begin(57600);
while (!Serial1);
Serial1.println("mac pause\r\n");
//setting window to zero
Serial.print("Setting radio window: ");
Serial1.println("radio set wdt 0\r\n");
//setting the rx to continous mode of reception
Serial1.println("radio rx 0\r\n");
if (Serial1.available() > 0) {
// read the incoming byte:
rx = Serial1.read();
// say what you got:
Serial.print("Comming to node " + nodeAddress +" serial: ");
Serial.println(rx);
The output I get is > Comming to node 102 serial: 52
but that value changes over time, so I am receiving something that I should not, maybe should I clear the buffer before receiving?
To enable receive mode during 1 second (any packet size)
Serial1.write(“radio set wdt 1000\r\n”);
Serial1.write(“mac pause\r\n”);
// check answer 0-4294967295\r\n
Serial1.write(“radio rx 0\r\n”);
// check answer ok\r\n
// the module waits for an RX packet during a maximum of 1 second
// if a packet arrives you will read radio_rx \r\n : hexadecimal value secuence
// if no packet arrives after 1 second read radio_err\r\n
Serial1.write(“mac resume\r\n”);
// check answer ok\r\n
To enable receive mode during 1 second expecting a 10 bytes packet
Serial1.write(“radio set wdt 1000\r\n”);
Serial1.write(“mac pause\r\n”);
// check answer 0-4294967295\r\n
Serial1.write(“radio rx 10\r\n”);
// check answer ok\r\n
// the module waits for an RX packet during a maximum of 1 second
// if a 10 bytes packet arrives you will read radio_rx \r\n : hexadecimal value secuence
// if no packet arrives after 1 second read radio_err\r\n
Serial1.write(“mac resume\r\n”);
// check answer ok\r\n
Transmit 1 packet and the wait during 1 second for any size RX packet
Serial1.write(“radio set wdt 1000\r\n”);
Serial1.write(“mac pause\r\n”);
// check answer 0-4294967295\r\n
Serial1.write(“radio tx FF\r\n”);
// check answer ok\r\n
// check answer radio_tx_ok\r\n or radio_err\r\n
Serial1.write(“radio rx 0\r\n”);
// check answer ok\r\n
// the module waits for an RX packet during a maximum of 1 second
// if a 10 bytes packet arrives you will read radio_rx \r\n : hexadecimal value secuence
// if no packet arrives after 1 second read radio_err\r\n (timeout)
Serial1.write(“mac resume\r\n”);
// check answer ok\r\n
HI @a.valero, I have followed your tip and it is the same, I don’t get the message back,I am quite puzzled by the fact that the answer to radio tx is none of the standard values, but a number is that normal?
TX is now
String text = "Node zero";
String e = "zero";
text = "Node " + nodeAddress + " sending: " + message;
Serial.println(text);
//using the LoRa modulation to reach other node instead the LoRaWan stack
//stopping the LoRaWan stack on the device
Serial.print("Pausing mac: ");
e = Serial1.write("mac pause\r\n");
Serial.println(e);
Serial.print("sending to radio: ");
e = Serial1.write("radio tx 1\r\n");
Serial.println(e);
Serial1.print(message);
whose outcome is
Node 02010102 sending: HI
Pausing mac: 11
sending to radio: 12
LoRa status:
Node 02010102 sending: HI
Pausing mac: 11
sending to radio: 12
LoRa status:
Node 02010102 sending: HI
…
RX is now
String str;
char rx[2];
int e = -1;
Serial1.begin(57600);
while (!Serial1);
Serial1.println("mac pause\r\n");
//setting window to zero
Serial1.println("radio set wdt 0\r\n");
//setting the rx to continous mode of reception
Serial1.println("radio rx 0\r\n");
if (Serial1.available() > 0) {
// read the incoming byte:
Serial1.readBytesUntil('\n', rx, 2);
// say what you got:
Serial.print("Comming to node " + nodeAddress + " serial: ");
Serial.println(rx);
and the outcome
Comming to node 02010103 serial: 42
Comming to node 02010103 serial: 94
Comming to node 02010103 serial: 96
Comming to node 02010103 serial: 72
Comming to node 02010103 serial: 45
Comming to node 02010103 serial: %
If you use Serial1.println(“mac pause\r\n”);
it includes the \r\n so you should use Serial1.println(“mac pause”); instead.
Serial1.write(“mac pause\r\n”); is the same as Serial1.println(“mac pause”);
e = Serial1.write(“radio tx 1\r\n”);
Serial.println(e);
The value for e should be 12 as is the len of “radio tx 1\r\n”.
To read the answer from the module this method is not correct:
if (Serial1.available() > 0) {
// read the incoming byte:
Serial1.readBytesUntil(’\n’, rx, 2);
You should use this:
char rx[20];
int len;
len = readWaitLn(rx, sizeof(rx), 100);
Add this two functions:
uint16_t readLn(char* buffer, uint16_t size)
{
int len = Serial1.readBytesUntil(’\n’, buffer, size);
buffer[len - 1] = ‘\0’; // bytes until \n always end with \r\n, so get rid of both
return len;
}
// Waits for a string. Returns true if the string is received before a timeout.
// Returns false if a timeout occurs or if another string is received.
uint16_t readWaitLn(char* buffer, uint16_t size, uint16_t timeout)
{
unsigned long start = millis();
uint16_t len;
while (millis() < start + timeout) {
if ((len = readLn(buffer, size)) > 0)
return len;
}
}
// timeout
return 0;
}
HI @a.valero thank you very much for your time, still struggling with it though… I don’t understand one thing, what is the timeout value depending on? Why should it be 100? THen the radio window has to match with it right?
I have tried your code as this
RX
char rx[20];
int leng ;
Serial1.begin(57600);
while (!Serial1);
Serial1.write("mac pause\r\n");
//setting window to zero
Serial1.println("radio set wdt 0\r\n");
//setting the rx to continous mode of reception
Serial1.write("radio rx 0\r\n");
leng = readWaitLn(rx, sizeof(rx), 100);
Serial.println(leng);
Outcome
11
11
11
11
11
11
11
11
11
11
TX
String text = "Node zero";
String e = "zero";
text = "Node " + nodeAddress + " sending: " + message;
Serial.println(text);
//using the LoRa modulation to reach other node instead the LoRaWan stack
//stopping the LoRaWan stack on the device
Serial.print("Pausing mac: ");
Serial1.write("mac pause\r\n");
delay(50);
while (Serial1.available()) Serial.write(Serial1.read());
Serial.print("sending to radio: ");
e = Serial1.write("radio tx 1\r\n");
Serial.println(e);
I would just warn - be aware that the radio commands in RN2483 are there really for test set ups. There is no real ‘protocol’ as such wrapped around this. No frequency agility, no duty cycling, no acknowledges etc. It works, but all those things needed to make it a robust legal system are all moved up to the application level, and you’ll need to work that out.
Its all possible, but just be aware …
With standard LoRaWAN all this has been worked out for you by the big founder members of the LoRa Alliance.
HI @sergiosena, I have followed the configuration that you provided in your link,in my both TTU. One is acting as rx and the other as tx as I mentioned in the answer to @a.valero , however, I got the same answer, I don’t get the sent menssage at all in the rx, still wondering why…
@JDP, thanks for your reply, I understand it, my real intention involves a LoRaWan gateway, in order to make use of LoRaWan stack, I was trying to test p2p with this device, but for now unluckly
LoRaWAN specification states that the transceiver may handle any other protocols when not actually doing LoRaWAN. You should then still keep to the duty cycle limit. However, I think RN2483 is not made for this purpose because it is not possible to read out the current duty cycle counter or ask the module if it is doing LoRaWAN stuff or let it interrupt radio commands. You have to implement this yourself.
You have to set the frequency, header info and some more settings of the radio the same on both modules. The radio will have the same settings as when it left LoRaWAN mode.
Thanks scle, I think I have already done it following the instructions that @sergiosena gave in his link, RN2483 is configured with the following parameters in both devices. I don’t get an error when setting them so I assume that they are correct.
Thanks again
“radio set mod lora”
“radio set freq 868000000”
“radio set pwr 14”
“radio set sf sf12”
“radio set afcbw 125”
“radio set rxbw 250”
“radio set fdev 5000”
“radio set prlen 8”
“radio set crc on”
“radio set cr 4/8”
“radio set wdt 0”
“radio set sync 12”
“radio set bw 250”
Hi scl, I have set the iq inversion in both devices as on, still nothing is coming to my RX… I am running out of ideas, and starting to dislike this platform XD