MKRZERO and Microchip RN2903A not communicating

I am using a MKRZERO connected to a microchip RN2903A LoRa radio in the following way:
MKRZERO tx(pin14) --- RN2903A RX
MKRZERO rx(pin13) --- RN2903A TX
MKRZERO pin2 --- RN2903A RESET

I am unable to get the arduino to receive replies from the radio. When I run the code below, I can see that the correct command is sent to the radio, and the radio replies with the expected value, but the arduino doesn't seem to receive it.

In the console, it prints out "Communication with RN2xx3 unsuccessful. Power cycle the board."

Using an Analog Discovery 2 to "spy" on the serial commands, I can see that the radio receives the request for the hweui and then replies with it (shown below in image) but the arduino seems to do nothing with it?

The original library used software serial, and I have modified to use hardware serial, so perhaps the issue is there? Any help is appreciated!!

Using this code (using this library: GitHub - jpmeijers/RN2483-Arduino-Library: Arduino C++ code to communicate with a Microchip RN2483 module)


#include <Arduino.h>
#include <rn2xx3.h>

  HardwareSerial &mySerial = Serial1;

  rn2xx3 myLora(mySerial);

void setup() {
  Serial.begin(9600);
  
  mySerial.begin(57600);
  delay(1000);

  //output LED pin
  pinMode(13, OUTPUT);
  led_on();
 
  // Open serial communications and wait for port to open:
  Serial.println("Startup");
  initialize_radio();

  //transmit a startup message
  myLora.tx("TTN Mapper on TTN Enschede node");

  led_off();
  delay(2000);
}

void initialize_radio()
{
  Serial.println("init radio");
  //reset rn2483
  pinMode(2, OUTPUT);
  digitalWrite(2, LOW);
  delay(500);
  digitalWrite(2, HIGH);

  delay(100); //wait for the RN2xx3's startup message
  mySerial.flush();

  //check communication with radio
  String hweui = myLora.hweui();
  Serial.println(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 = "70B3D57ED00001A6";
  const char *appKey = "A23C96EE13804963F8C2BD6285448198";

  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();

    Serial.println("TXing");
    myLora.tx("!"); //one byte, blocking function

    led_off();
    delay(200);
}

void led_on()
{
  digitalWrite(13, 1);
}

void led_off()
{
  digitalWrite(13, 0);
}

See TX and RX on the same line:

At least GND is missing. You might have done that but that again shows why we ask for a wiring diagram and not descriptions of your connections. How do you power the chip?

As you don't link to a breakout board we expect that you directly connect to the RN2903 micro board.

The flush() method doesn't empty receive buffers (it seems to me that you expect that).

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.