You are on page 1of 19

DIS K91 .

CO M – TECH
TECH N O L OGY, HAR DWARE, SECUR

HopeRF RFM95 and arduin


LoRaWan solution
The HopeRF RFM95w module
cost. Its unitary price is aroun
version with a shield is also ex
from niceRF. These different t
SX1276 chip. It makes this kin
low cost LoRaWAN design in a
are going to use it with an Ard

T H E S E M T E C H S X 1276 C H I P

/
What is the difference between the different Semtech ch
first version of Semtech’s LoRa chips. The SX126x Semt
in January 2018. This new version, including SX1262, h
reception. It also offers higher transmission power (+15
smaller with 4x4mm.

So the RFM95w module is using the first version of Sem


the transceiver are using this chip, so it is not a negative

The SX1276 chip proposes a +14dB transmission for CE


datasheet can be found on Semtech website.

THE RFM95W MODULE

The HopeRF RFM95w module is a LoRa transceiver im


is nothing more than a SX1276 standard design on it. th
brand proposing equivalent circuit. Some with shield, so

The design is specific for each of the LoRa usual frequen


cover a specific zone: Europe, America, Asia.

Important point to notice: according to my tests


RFO power amplifier. It only rely on PA_Boost.
really unclear on that point. Depending on the b
to have transmission at 50mA for 14dB and som
/
experience measuring consumption at 93mA @
5dB. The reason is not yet establish, a bad anten
the reason. Not sure it is the only one.

The transceiver is LoRa and not LoRaWAN. It means th


LoRaWan stack and you need to use a MCU to impleme

For the comparison a Murata CMWX1ZZABZ transceive


stack on the STM32 incorporated MCU and is able to sw
configuration. This is why this solution have a higher co

The RFM95w soldering is easy thanks to 2mm pcb pads


solution will be loved by makers. The 2mm spacing doe
the standard 2.54 breadboard’s spacing. Luckily the pcb
same footprint as the ESP8266. You can use the easy to
ESP8266’s adapter plate to use it on a breadboard. This
adapter plate is on amazon, ebay, aliexpress for 0.2€. Y
remove the resistors soldered on the PCB plate.

If you don’t have a adapter pl


module pin thanks to the pin
to be able to plug them on the
male connector if you want to

/
The RFM95w powering is 3.3
is accessible on the HopeRF w

CABLING

I did look at Mobilefish tutor


of the following element will
modifications sounding bette
some personal feedback and comments.

At first, Arduino is powered with 5V when the Semtech


voltage and usually works with 3.3V. You can cable the
you need to know this powering source is coming from t
be supplied when a battery is in use. The Arduino’s 3.3V
50mA. For FCC (basically higher than 14dB) usage you
supply to provide the right currant.

On top of this point the Arduino’s GPIO is 5V when the


voltage. You can also use a tension divider bridge on the
and RESET. You can also select the Adafruit RFM95w m
shifter and DCDC powering.

As a consequence, by connecting your module to


in the next lines you understand you have a risk
lifetime largely reduced due to this over-voltage
/
The best solution are to use a 3.3V MCU (like a STM32)
operating a voltage conversion for the I/Os.

HopeRF RFM95 LoRa Arduino HopeR


transceiver module Pin transc

ANT – GND

GND GND DIO5

DIO3 – RESE

DIO4 – NSS

3.3V 3.3V SCK

DIO0 3 MOSI

DIO1 4 MISO

DIO2 – GND

ANT is the antenna Pin. On this pin I’m conne


GND can be connected to any of the GND pad
DIO0 is used by RFM95w module to trigger Rx
DIO1 is used by RFM95w module to trigger Rx
status.

/
NSS, MOSI, MISO, SCLK are for SPI communi
signal. Arduino is the master.
Reset is resetting the RFM95w module.

This is the Arduino Nano circuit where you can plug the
previous table mapping.

SOFTWARE LIBRARY

Arduino UNO / Nano do not have a large memory avail


LoRaWan library with a reduced footprint. The IBM LM
been ported on Arduino. You can check Matthis Kooijm

Add the library in the Arduino IDE going on Sketch >>


Libraries. Then search for LMIC and select MCCI Lo
IBM,Matthis Kooijman… Select the last version and

/
Now you can see in the example a directory related to th
example to getting started. Save it with a new name.

You now need to get the DEVEUI, APPEUI and APPKEY


and set the sketch according to it. To get these different
TheThingsNetwork tutorial.

You need to be careful on the byte order. DEVEUI and A


nee to put them in reverse order compared to what you
a byte block so you directly write it in the same order as

// This EUI must be in little-endian format, so least


// first. When copying an EUI from ttnctl output, th
// the bytes. For TTN issued EUIs the last bytes sho
// 0x70.
static const u1_t PROGMEM APPEUI[8]={ 0x00, 0x00, 0x
void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI

// This should also be in little endian format, see


static const u1_t PROGMEM DEVEUI[8]={ 0x00, 0x00, 0x
void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI

// This key should be in big endian format (or, since


// number but a block of memory, endianness does not
// practice, a key taken from ttnctl can be copied a
static const u1_t PROGMEM APPKEY[16] = { 0xC5,0x1F,0x
void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY

/
Now, you need to configure the pin mapping:

// Pin mapping
// Rq : dio2 is not used (it is needed only for FSK)
// pin 7 will be affected but nor used.
const lmic_pinmap lmic_pins = {
.nss = 6,
.rxtx = LMIC_UNUSED_PIN,
.rst = 5,
.dio = {3, 4, LMIC_UNUSED_PIN },
};

Before compiling the sketch we need to setup the LMIC


the zone (the frequencies) you need to edit the configur
directory named: project_config/lmic_project_co
comment the right lines and comment others. On top of
following lines:

// Ensure the setting is correct in the LMIC config f


// LMIC library/project_config/lmic_project_config.h
// These two defines have no more effect than creatin
// the library setting is not correct
#define CFG_eu868 1
#define CFG_sx1276_radio 1

In the project’s sketch you need to add the configuration

/
void setup() {
Serial.begin(9600);
Serial.println(F("Starting"));
// LMIC init
os_init();
// Reset the MAC state. Session and pending data
LMIC_reset();
LMIC_setClockError(MAX_CLOCK_ERROR * 2 / 100);
LMIC_setupChannel(0, 868100000, DR_RANGE_MAP(DR_
LMIC_setupChannel(1, 868300000, DR_RANGE_MAP(DR_
LMIC_setupChannel(2, 868500000, DR_RANGE_MAP(DR_
LMIC_setupChannel(3, 867100000, DR_RANGE_MAP(DR_
LMIC_setupChannel(4, 867300000, DR_RANGE_MAP(DR_
LMIC_setupChannel(5, 867500000, DR_RANGE_MAP(DR_
LMIC_setupChannel(6, 867700000, DR_RANGE_MAP(DR_
LMIC_setupChannel(7, 867900000, DR_RANGE_MAP(DR_
LMIC_setupChannel(8, 868800000, DR_RANGE_MAP(DR_

LMIC_setLinkCheckMode(0);
LMIC.dn2Dr = SF9;
LMIC_setDrTxpow(DR_SF7,14);

// Start job (sending automatically starts OTAA to


do_send(&sendjob);
}

LMIC_setClockError modify the timing du


oscillator lack of precision. You need to add th
clock precision.
LMIC_setupChannel defines the different c
channels are depending on the zone where you
/
channels will be available.

Now you can compile and transmit the sketch to the Ard
sketch processing on the Arduino console. The board wi
a message every minutes (+/- couple of seconds)

CONCLUSION

The RFM95w module is low cost and easy to use with A


with 3.3V. Arduino Nano or UNO are not the best choic
3.3V supply plus GPIO level adaptation even if, as you h
GPIO and FTDI powering at 14dB transmission.

The LMIC LoRaWan implementation is basic but offer a


well if you are not looking for all the LoRaWan features

SHARE :

 Twitter  Facebook  LinkedIn  Pinterest  Tum

 Email  Print

RELATED

What is LoRa ?
/
27 September 2015 First steps with LoRa Radio
In "IoT" Node (Arduino)
24 March 2019
In "IoT"

RELATED POSTS:

1. First steps with LoRa Radio Node (Ardu


Arduino board with a RFM95 LoRa module. This all-in
2. Simple LoRa GPS tracker based on RN2
make a simple GPS tracker communicating over LoRaW
LoRaWan gateway...
3. Kerlink LoRaWan Wirnet iFemtoCell re
and gateway to receive the device communication and
can...
4. Getting started with Arduino MKRWAN
making some post on Arduino MKRFOX1200, here I c
MKRWAN1300 board to send...

13 RE S P O N S E S TO HOPERF RFM95
COST LORAWAN SOLUTION
/
Tigran says:
28 JANUARY 2019 AT 15:56

Hi, could you send me or upload into post a w


REPLY

Paul says:
28 JANUARY 2019 AT 20:23

Basically it is. Just copy/paste t


example sketch.
REPLY

Ruben G Elmo says:


3 JULY 2019 AT 09:35

Just cloned the project you made. My issue is


once… and then stuck like “Starting
Packet queued
14335786: EV_TXCOMPLETE (includes wai
REPLY

Paul says:
5 JULY 2019 AT 21:09
/
Did you solder the DIO/GPOI p
REPLY

Robert Hancock says:


11 AUGUST 2019 AT 11:50

Followed your instructions to the letter and g

[…]

/Applications/Arduino.app/Contents/Java/h
undefined reference to `loop’
collect2: error: ld returned 1 exit status
Using library MCCI_LoRaWAN_LMIC_libra
/Users/roberthancock/Documents/Arduino/
Using library SPI at version 1.0 in folder:
/Applications/Arduino.app/Contents/Java/h
exit status 1
Error compiling for board Arduino Pro or Pr
REPLY

Paul says:
14 AUGUST 2019 AT 11:53

/
Just like it is written in you com
undefined reference to `loo
REPLY

Robert Hancock says:


14 AUGUST 2019 AT 01:58

Can you suggest modifications for connecting


Pro or Pro Mini?
REPLY

Paul says:
19 AUGUST 2019 AT 11:06

In the post you have a link to th


to add.
REPLY

Robert Hancock says:


14 AUGUST 2019 AT 23:06

Sorry to say this, but the Sketch you suggest


significant errors—did you debug it?
/
Compile error #1
/Users/roberthancock/Desktop/ttn-otaatest
onEvent(ev_t)’:
/Users/roberthancock/Desktop/ttn-otaatest
comparison between signed and unsigned in
for (int i = 0; i < sizeof(artKey); ++i) {
~~^~~~~~~~~

Compile error #2
/Users/roberthancock/Desktop/ttn-otaatest
comparison between signed and unsigned in
for (int i = 0; i < sizeof(nwkKey); ++i) {
~~^~~~~~~~~

Compile error #3
#pragma message: Board not supported — u
#pragma message("Board not supported — u

Compile error #4 (and most serious)


/var/folders/wg/cvn1t_xj5qzdjb0ktl5hfkjm0
In function 'main':
/Applications/Arduino.app/Contents/Java/h
undefined reference to `loop'

Thanks for the useful site, but some feedback


/
REPLY

Paul says:
19 AUGUST 2019 AT 11:16

Yes it compile and works … if y


elements into a sketch and corr
works well.
Here you have : 2 warning (we
1 error related to the “Board no
setting in your LMIC lib
1 error related to ” undefined re
to say an Arduino Sketch MUST

For helping you starting with R


example : https://github.com/d
demo (it has been made for LoR

[Side note] => on a blog, there


with your question sent 10 time
difficulties to solve your issues,
sometimes 😉 Have fun !
REPLY

/
pedro says:
29 SEPTEMBER 2019 AT 22:16

Hello
I have followed the guide you show here. But
sends the first data packet, when sending the
/Applications/Arduino.app/Contents/Java/l
master/src/lmic/radio. c: 429
Do you know what it is and how can I solve it
I am using a nano v.3, but Chinese version.
REPLY

Jules says:
30 OCTOBER 2019 AT 17:07

Hello.
I followed this tutorial but unfortunately I ge

‘LMIC_getSessionKeys’ was not declared in t

…but I’m not quite sure how and where I nee

I’m looking forward to hear from you soon.


Thank you
/
REPLY

Paul says:
10 NOVEMBER 2019 AT 09:26

Did you selected OTAA authent


REPLY

This site uses Akismet to reduce spam. Learn how your com

/
/

You might also like