Thursday, February 25, 2016

LoRa FeatherWing Development Breakout

In this post I will document a LoRa FeatherWing Development Breakout board that I designed for the Adafruit Feather line of microcontroller boards.

LoRa FeatherWing Development Breakout for Adafruit Feather

What is LoRa?


LoRa is an ultra-long range wireless technology that uses sub-GHz ISM bands. It allows the interconnection of small, low-power sensor nodes and Internet of Things (IoT) devices. There are many LoRa transceiver modules on the market from manufacturers such as HopeRF and MicroChip. These modules can be used to connect small, isolated networks of nodes in custom applications. They can also be used to connect nodes to Low-Power Wide Area Networks (LPWANs), such as LoRaWAN.

The choice of module is quite important when designing your project. If you are interested in participating in LoRaWAN, you need to choose a module that is compatible with it. Importantly, significant coding is also necessary to enable the necessary features and functions required by the network. Unless you want to start coding from scratch, you should pick a module with existing library support for whatever development environment you are using.

Check out this great article on The Things Network website that covered various modules and their compatibility. They have documentation on building a LoRa node with an RFM95W module and a Teensy.

HopeRF RFM95/96(W)


The RFM95/96(W) series of modules by HopeRF is a good entry point into LoRa development. There is a substantial amount of documentation, source code, and example projects on the internet to help you get started. Numerous Arduino-compatible libraries have also been developed.

RFM95/96(W) modules can be purchased for as little as $10 from some suppliers. Please read the manufacturer's documentation to become more familiar with them.


As always, low cost comes at a price. The RFM95/96(W) modules interface with a microcontroller over SPI bus plus a few digital I/O lines. If you are interested in LoRaWAN, much of the processing necessary for that is offloaded to the microcontroller and must be implemented in software. By comparison, more complex and expensive modules from other manufacturers do all of the LoRaWAN processing for you, and you merely pass data in and out of the modem.

LoRa Development for Adafruit Feather


I became interested in LoRa technology some weeks ago, and decided to design a small LoRa FeatherWing. I am calling this a "Development Breakout" because it is not entirely ready to use after you solder on the RFM95/96(W) module. My board connects power and the MOSI, MISO, and SCK SPI lines from the Feather to the module. However, there are additional lines that need to be connected based on which library you are using. For maximum flexibility, I decided to break out the DIO, Reset, and SPI chip select pins from the module to a 2x5 0.1" header. This allows you to connect the pins any way you like to the Feather.

The antenna connects via an edge-launch SMA connector. You can select SMA or RP-SMA based on your antennas and requirements.

The example programs I will provide here are compatible with Feather M0, 32U4, and HUZZAH. If you plan to use this board for LoRaWAN, the Feather M0 is required. The LoRaWAN libraries I have seen are quite large, and the 8-bit AVRs do not have enough flash and RAM to support them.

This is only the first board I plan to design. If you want a more polished, ready-to-use board, please stay tuned as the project develops.

Feather HUZZAH ESP8266


I know there will be interest in using this board on the Feather HUZZAH, especially for creating small gateways. I have successfully gotten a Feather HUZZAH to operate in receive mode only, picking up the broadcast strings from a beacon. However, when I attempted to transmit with the Beacon Mode example program, I experienced reset issues on the ESP8266. I'm not sure yet if this is a power issue or an SPI issue, but it will require more experimenting.

Update: Both of the example programs are now compatible with the Feather HUZZAH. A small delay had to be added to the five second wait loop in the Beacon mode program to prevent the ESP8266's watchdog from timing out. Just change your digital pin definitions for the HUZZAH. I found that pins #4, #5, and #2 worked for controlling DIO0, DIO5, and NSS respectively.

Despite compatibility with these simple example programs, the Feather HUZZAH is limited in "clean" I/O pins that can operate as inputs for the DIO lines needed by many LoRaWAN libraries. I am exploring using an 8-bit I/O expander that communicates with the ESP8266 over I2C to enable further LoRa development on HUZZAH.


Shared as Open Source Hardware (OSHW)


LoRa FeatherWing Development Breakout: Order PCBs on OSHPark!

Eagle Files: Shared on Github



LoRa FeatherWing Development Breakout Schematic

LoRa FeatherWing Development Breakout Board Layout

Assemble Your Own


Here is the information you need if you'd like to order PCBs and make your own LoRa FeatherWings.

Parts List:
  • LoRa Module: HopeRF RFM95W or RFM96W (pick the correct frequency for the ISM bands used in your country)
  • RF Connector: SMA or RP-SMA Edge-Launch for 1.6mm/0.062" board thickness 
  • C1: 47uF 1410 Tantalum SMD capacitor, 10V rated minimum
  • C2: 1uF 0603 Ceramic SMD capacitor
  • C3: 100nF 0603 Ceramic SMD capacitor 
  • LED: 0805, color of your choice
  • R1: 680 ohm 0603, or adjust value to change brightness of LED
  • Headers to connect the FeatherWing to the Feather board 
  • Antenna suitable for the frequency range supported by your RFM module
Note: You can do away with the LED and R1 if you don't want an additional power indicator. Also, you might be tempted to do away with the capacitors C1 and C2 to simplify the bill of materials. The RFM module draws over 100mA during transmissions at the maximum power setting, and ramp-up can be quite quick depending on your configuration. I would recommend the extra bulk capacitance on the board, especially if you are loading the voltage regulator on the Feather with other devices.

Wiring


As noted, this is a development breakout, so you have some additional wiring to do to get the module fully connected to the Feather. I used the following pinout, which is compatible with the example programs I have provided. You can modify it as you like to fit your project or chosen library. The DIO and CS lines from the RFM module only need to go to standard digital I/O pins on the Feather, so you have many options with the 32U4 and M0.

When you try other libraries, you'll probably have to connect more of the DIO pins. Actually, if you look closely in the pictures below, you'll see that I have a different pinout wired up for experimentation. This board is very flexible.


Pinout used in the example programs.


Wiring completed with breadboard jumper wires and a 2x5 0.1" male header.
This allows maximum flexibility to change things, but it's messy.


 Wiring completed with small gauge, solid core wire.
Nice and neat. This is a ready-to-use LoRa beacon!


Example Programs


I debated on which RFM95W Arduino library to use for my example programs. I am aware that many people reading this know a lot about LoRa, have a library in mind, and just need the hardware for the Feather boards. If that's you, awesome. Please enjoy using this board and tell me what you would like to see on future versions. Other people might just need long range wireless connectivity in their project, and don't necessarily want to participate in a LPWAN yet.

I decided to use the RFM95W_Nexus library by Ideetron. This set of code seems to be set up for a specific LoRa development board, but it also has example programs for simple beacon and transceiver nodes operating independently. The portions of code I used don't actually rely on an included library at all, besides SPI. I think this is a great first example program, because it shows you what is actually necessary to drive the RFM module from your microcontroller, without obscuring things into routines. When you get interested in LoRaWAN, the library includes code for that. Additionally, with all of the DIO pins broken out from the RFM module, you can advance to any of the other libraries under development, such as the LMIC library.

The LoRa FeatherWing Beacon Mode program configures the Feather as a beacon that broadcasts a test count every five seconds. This is useful for testing the range of your nodes. The code is very simple, and you will see that modifying the program to send sensor data or anything else you like in the payload is straightforward. Simply load the program, connect a LiPo battery or some other means of power to the Feather, and it will broadcast autonomously.

The LoRa FeatherWing Transceiver Mode example configures the Feather to receive the messages from the Beacon node. There are also functions in there to transmit, so you could modify this into a bridge for long range wireless serial communications. In this example, received messages are echoed across USB Serial, allowing you to verify the receipt of broadcasts from your beacon nodes and test your boards.

Range


The range you can expect from your wireless link is very dependent upon your antennas and environment. Good line-of-sight between the modules is important. Additionally, the frequencies supported by your modules has an impact. Finally, the configuration options you choose for the wireless link will set your maximum data rate, but also affect your range. In the example programs, I set the modules up for 250kHz bandwidth, Spreading Factor 11, and a 4/8 coding rate. These settings favor longer range, with a nominal bit rate of 293bps. Much higher nominal bitrates are possible at the expense of range.

Bandwidth, Spreading Factor, and Coding rate are much too complicated to get into in this article. If you are interested in seeing a separate post explaining those concepts and how they can be use to customize your LoRa FeatherWing project, please let me know in the comments below.

I personally have tested these boards, with the above-mentioned link settings, out to 2.7 kilometers. With a Spreading Factor of 6 (high data rates), I was able to achieve reliable communications out to 500 meters with less than perfect line-of-sight.


Wrap Up


I do hope that you find this FeatherWing design useful. Please let me know if you build one and make a cool project with it, or get it linked into LoRaWAN. Also, please post below any corrections or necessary additions to the information I have presented here. LoRa is very popular in the IoT community, and I look forward to learning from your knowledge and experience in using it.

Thanks for reading!

- Dan W.

8 comments:

  1. hi Dan
    I've seen your enhanced board on twitter.
    could you send me two of them or can I order them soon?
    thanks, urs

    ReplyDelete
    Replies
    1. I have considered getting some LoRa and MultiNav featherwings available for sale on Tindie. If I make progress toward that I will certainly let you know. Thanks.

      Delete
  2. great work Dan !
    what about a 'microchip LoRaWAN feather board' ?

    cheers

    - http://s14.postimg.org/p7twj3kuo/microchip_featherboard.jpg

    ReplyDelete
    Replies
    1. This would greatly simplify the communication between the module and Feather, wouldn't it? It looks like it will be a tight fit to place the module between the header pins on the Feather form factor. I will certainly look into it though.

      Delete
    2. @wappi, I've done a shield, not a feather shield but a WeMos one. WeMos is an $4 ESP8266 board also so you can share the same code.
      See shield boards here https://github.com/hallard/WeMos-RN2483/blob/master/README.md

      Delete
  3. Dan,
    Excellent job, will the .brd and .sch files will be released or available somewhere ?

    Cheers from France ;-)

    ReplyDelete
    Replies
    1. Sorry for the long delay, but a link to the Github repo is now available in the article. Hopefully they will still be useful to you!

      Dan

      Delete