Hello,
I began to use the RN2483-Arduino library and I immediately realized a problem of data transmission: using the example “ArduinoUnoNano-basic” I realized that the data is not always sent. I think it’s a problem of the node because neither on the gateway nor on the server I see traces of this seemingly lost data.
My hardware consists of an Arduino Mega and a Modem Lora RN2483A. The modem was sold by a company that provides its adapter card in which the modem is integrated and the antennas’ connections
I tested the code by trying both a UART software (managed through the Software Serial library), and a real UART of the Arduino mega but the result is the same.
`#include <rn2xx3.h>
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(10, 11); // RX, TX
//create an instance of the rn2xx3 library,
//giving the software serial as port to use
rn2xx3 myLora(Serial2);
// the setup routine runs once when you press reset:
void setup()
{
//output LED pin
//pinMode(13, OUTPUT);
//led_on();
// Open serial communications and wait for port to open:
Serial.begin(57600); //serial port to computer
Serial2.begin(9600); //serial port to radio
Serial.println("Startup");
initialize_radio();
//transmit a startup message
myLora.tx("TTN Mapper on TTN Enschede node");
//led_off();
delay(2000);
}
void initialize_radio()
{
//reset rn2483
pinMode(12, OUTPUT);
digitalWrite(12, LOW);
delay(500);
digitalWrite(12, HIGH);
delay(100); //wait for the RN2xx3's startup message
Serial2.flush();
//Autobaud the rn2483 module to 9600. The default would otherwise be 57600.
myLora.autobaud();
//check communication with radio
String hweui = myLora.hweui();
while(hweui.length() != 16)
{
Serial.println("Communication with RN2xx3 unsuccessful. Power cycle the board.");
Serial.println(hweui);
delay(10000);
hweui = myLora.hweui();
}
//print out the HWEUI so that we can register it via ttnctl
Serial.println("When using OTAA, register this DevEUI: ");
Serial.println(myLora.hweui());
Serial.println("RN2xx3 firmware version:");
Serial.println(myLora.sysver());
//configure your keys and join the network
Serial.println("Trying to join TTN");
bool join_result = false;
/*
* ABP: initABP(String addr, String AppSKey, String NwkSKey);
* Paste the example code from the TTN console here:
*/
//const char *devAddr = "02017201";
//const char *nwkSKey = "AE17E567AECC8787F749A62F5541D522";
//const char *appSKey = "8D7FFEF938589D95AAD928C2E2E7E48F";
//join_result = myLora.initABP(devAddr, appSKey, nwkSKey);
/*
* OTAA: initOTAA(String AppEUI, String AppKey);
* If you are using OTAA, paste the example code from the TTN console here:
*/
const char *appEui = "1112131415161718";
const char *appKey = "01020304050607080910111213141516";
join_result = myLora.initOTAA(appEui, appKey);
while(!join_result)
{
Serial.println("Unable to join. Are your keys correct, and do you have TTN coverage?");
delay(60000); //delay a minute before retry
join_result = myLora.init();
}
Serial.println("Successfully joined TTN");
}
// the loop routine runs over and over again forever:
void loop()
{
//led_on();
delay(10000);
Serial.println("TXing");
Serial.println(myLora.tx("!")); //one byte, blocking function
//led_off();
}
/*void led_on()
{
digitalWrite(13, 1);
}
void led_off()
{
digitalWrite(13, 0);
}*/
the problem presents itself to the line: Serial.println(myLora.tx("!")); . The message is not sent every time that function is invoked. It is sent the first time and then after a few attempts to send. I’m sure of this because I find confirmation both from the log of the gateway and those of the server (I do not see all the messages that should arrive). Moreover that function returns 0 when the message is not sent.
I powered the model module with 3v3.
The backtick was my mistake while inserting the code in the post, I was trying to format code correctly.
rn2xx3.h is the name of the library I use to communicate with the Lora module. The link of the project is as follows:
So, it works sometimes. Any chance you’re using a single-channel gateway?
(And please review your posts before/after submitting. The formatting errors just cause too much confusion. Your comment below the code was hardly visible until I edited your post just now. And as it works sometimes, I can only assume that you used fake keys when posting, like in *appKey = "01020304050607080910111213141516". Using something like *appKey = "redacted" is much clearer. See also How do I format my forum post? [HowTo])
The RN2483 is based on a PIC processor and as the RN2483 datasheet makes clear, the maximum voltage on any connected pin is 3.9V, so clearly connecting 5V logic pins from an Arduino Mega is outside specification.