Getting started with Microchip RN2483 LoRaWAN modules

Posted on Posted in wireless
Introduction

Thing Innovations have developed a simple breakout board for the Microchip RN2483 LoRaWAN module. This breaks out the power, UART and Reset pins so that the module can be connected easily to a microcontroller for LoRaWAN sensor development. With the RN2483 being certified by the LoRa Alliance, it is becoming an attractive module for developing sensors for use with The Things Network.

RN2483_Breakout

Building the breakout board

Soldering the RN2483 modules can be tricky. The best method would be to use solder paste accurately placed on each pad and either put the board into a reflow oven or place a hot soldering iron onto each joint to melt the paste.

Alternatively each joint can be made with regular solder from a reel. The finer the better. I found that holding the module down with a couple of lumps of Blu Tack or similar can help. First solder the corner pads, these are all required as they are ground pins. Once the module has been secured the Blu Tack can be removed. Work carefully, checking each connection with a multimeter to ensure there are no shorts between pins or to the ground plane.

For ease of assembly and to reduce the risk of shorts, only the required pins need to be soldered. These are 1,2,3,6,7,8,11,12,20-28,32,33,34,41,47.

There are two pads where a 1206 sized 100nF smd capacitor can be soldered. If this is to be added then it is best to be done before the header pins are added. I have used right-angle so the board can stand vertically in a breadboard.

Connecting to an Arduino

To use the breakout board with an Arduino, the following connections need to be made:

Breakout Arduino Name
1 GND GND
2   UART_RTS
3   UART_CTS
4 +3.3V PWR
5 D3 UART_TX
6 D4 UART_RX
7 D5 RESET

Example sketch to create a simple temperature sensor using a Dallas OneWire DS18B20 temperature sensor. Other devices can be used and appropriate code and libraries added instead.

// RN2483_temperature.ino - Simple LoRaWAN temperature sensor using Microchip RN2483 module
#include "SoftwareSerial.h"
#include "OneWire.h"
#include "DallasTemperature.h"

SoftwareSerial lora(3, 4); // RX, TX
// OneWire bus pin for temperature sensor pin
#define ONE_WIRE_BUS 6
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// arrays to hold device address
DeviceAddress temperatureSensor;

void sendCmd( char *cmd) {
  Serial.write( cmd );
  Serial.write("\n");
  lora.write(cmd);
  lora.write("\r\n");
  while (!lora.available() ) {
    delay(100);
  }
  while (lora.available())
    Serial.write(lora.read());
}

void waitForResponse() {
  while (!lora.available() ) {
    delay(100);
  }
  while (lora.available())
    Serial.write(lora.read());
}

char getHexHi( char ch ) {
  char nibble = ch >> 4;
  return (nibble > 9) ? nibble + 'A' - 10 : nibble + '0';
}
char getHexLo( char ch ) {
  char nibble = ch & 0x0f;
  return (nibble > 9) ? nibble + 'A' - 10 : nibble + '0';
}

void sendData( char *data) {
  Serial.write( "mac tx uncnf 1 " );
  lora.write( "mac tx uncnf 1 " );
  // Write data as hex characters
  char *ptr = data;
  int idiotCount = 50;
  while (*ptr && idiotCount ) {
    lora.write( getHexHi( *ptr ) );
    lora.write( getHexLo( *ptr ) );

    Serial.write( getHexHi( *ptr ) );
    Serial.write( getHexLo( *ptr ) );

    ptr++;
    idiotCount--;
  }
  lora.write("\r\n");
  Serial.write("\n");
  delay(5000);

  while (lora.available())
    Serial.write(lora.read());
}

void setup()
{
  Serial.begin(57600);
  lora.begin(57600);
  Serial.println("RN2483 Test");

  pinMode(5, OUTPUT);
  digitalWrite(5, HIGH);
  delay(50);
  digitalWrite(5, LOW);
  delay(50);
  digitalWrite(5, HIGH);
  delay(50);

  waitForResponse();

  sensors.begin();
  if (sensors.getAddress(temperatureSensor, 0)) {
    // set the resolution to 9 bit
    sensors.setResolution(temperatureSensor, 9);
  }

  sendCmd("sys factoryRESET");
  sendCmd("sys get hweui");
  sendCmd("mac get deveui");

  // For TTN
  sendCmd("mac set devaddr AABBCCDD");  // Set own address
  sendCmd("mac set appskey 2B7E151628AED2A6ABF7158809CF4F3C");
  sendCmd("mac set nwkskey 2B7E151628AED2A6ABF7158809CF4F3C");
  sendCmd("mac set adr off");
  sendCmd("mac set rx2 3 869525000");
  sendCmd("mac join abp");
  sendCmd("mac get status");
  sendCmd("mac get devaddr");
}

void loop() {
  // put your main code here, to run repeatedly:
  float temperature = 0.0;

  sensors.requestTemperatures();
  temperature = sensors.getTempCByIndex(0);
  Serial.println(temperature);
  char msgBuf[40];
  sprintf(msgBuf, "{\"temp\":%d.%01d}", (int)temperature, (int)(temperature * 10) % 10);
  Serial.println(msgBuf);

  sendData(msgBuf);
  delay(5000);
  while (lora.available())
    Serial.write(lora.read());

  delay(60000);
}

The device node address needs to be set correctly using the mac set devaddrr command

sendCmd("mac set devaddr AABBCCDD");

Where AABBCCDD is an address in your allocated node address space.

To see the data being received by The Things Network you should visit the URL http://thethingsnetwork.org/api/v0/nodes/AABBCCDD/ where AABBCCDD matches the value in your sketch.

The sketch is an example and can be improved by removing the Factory Reset line and saving the configuration values so they are available on power up or reset. The sketch could also sleep the microcontroller and the RN2483 module too.

What’s next?

If you want to get your own breakout PCBs, then they can be ordered from DirtyPCBs.