868 MHz Adafruit Feather M0

TTN version: TTNv3
Activation: OTAA / ABP
Device Class: Class A
Last updated: January 19, 2023

At the Feather M0‘s heart is an ATSAMD21G18 ARM Cortex M0 processor, clocked at 48 MHz and at 3.3 V logic. This chip has a whopping 256 KB of FLASH (8x more than the ATmega32u4) and 32 KB of RAM (16x as much).

The Adafruit Feather M0 with RFM95 LoRa Radio – 900 MHz uses the extra space left over to add an RFM95 LoRa 868/915 MHz radio module. This is the 900 MHz radio version, which can be used for either 868 MHz or 915 MHz transmission/reception. See complete specification here.Adafruit Feather M0

Prepare

  • Adafruit Feather M0 with RFM95 LoRa Radio – 900 MHz
  • 1x wire
  • breadboard (optional)
  • PC + micro USB cable

 

Assembly

Wire up the Adafruit Feather M0’s IO1 pin with pin 6.Adafruit Feather M0 assembly

 

Arduino IDE setup

  1. Download Arduino IDE.
  2. Run Arduino IDE.
  3. In the Arduino IDE File -> Preferences copy and paste the link below into the Additional Boards Manager URLs.
    https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
  4. Click OK.Adafruit 32u4 Arduino2 Setup
  5. Install the Adafruit boards via Boards Manager -> search Arduino SAMD Boards -> Install.
  6. Install the Adafruit boards via Boards Manager -> search Adafruit SAMD Boards -> Install.M0 Setup Arduino IDE
  7. You should see in Tools -> Board -> Adafruit SAMD the Adafruit Feather M0.M0 Setup Arduino IDE
  8. Connect the Adafruit Feather M0 using micro USB cable to your computer.
  9. Choose the appropriate COM port which is used for communication with Adafruit.M0 Setup Arduino IDE

 

Activation

Over The Air Activation (OTAA) – the most secure and recommended activation method for end devices. Devices perform a join procedure with the network, during which a dynamic device address is assigned and security keys are negotiated with the device.

Activation By Personalization (ABP) – requires hardcoding the device address as well as the security keys in the device. ABP is less secure than OTAA and also has the downside that devices can not switch network providers without manually changing keys in the device.

See the documentation for more information on activation.

 

Over The Air Activation (OTAA)

MCCI LoRaWAN LMIC library setup

  1. In the Arduino IDE Library Manager search MCCI LoRaWAN LMIC library by Terry Moore and install it.Adafruit 32u4 Arduino2 Setup
  2. On Windows open lmic_project_config.h located in \Documents\Arduino\libraries\MCCI_LoRaWAN_LMIC_library\project_config\
  3. Change project definitions to definitions listed bellow and save it.
// project-specific definitions
#define CFG_eu868 1                  //for Europe (change it based on your location)
#define CFG_sx1276_radio 1
#define DISABLE_PING 1
#define DISABLE_BEACONS 1

 

Add Feather M0 into The Things Stack

  1. Create an account on The Things Network if you don’t have one.
  2. Login on The Things Network.
  3. Click on your username and choose Console.
  4. Select a network cluster.
Add application
  1. Go to applications.
  2. Click on button + Create application.
  3. Write something into Application ID.
  4. Click on button Create application.
Add end device
  1. In your application click on button + Register end device.
  2. Input Method – Choose Enter end device specifics manually.
  3. Frequency plan – Europe 863-870 MHz (SF9 for RX2 – recommended)
  4. LoRaWAN version – LoRaWAN Specification 1.0.3
  5. Click on Show advanced activation, LoRaWAN class and cluster settings
  6. Activation mode – Over the air activation (OTAA)
  7. Additional LoRaWAN class capabilities – None (class A only)
  8. Deselect – Use network’s default MAC settings
  9. Rx2 data rate = 3
  10. Rx2 frequency = 869,525 MHz
  11. JoinEUI – 0000000000000000
  12. Click on Confirm.
  13. DevEUI – Generate
  14. AppKey – Generate
  15. End device ID – here you can name your device
  16. After registration – View registered end device
  17. Click on button Register end device
  18. Click on General settings
  19. Network layer – Expand
  20. Click on Advanced MAC settings
  21. Desired Rx1 delay = 1
  22. Rx1 data rate offset = 0
  23. Add Frequency = 868100000
  24. Add Frequency = 868300000
  25. Add Frequency = 868500000
  26. Add Frequency = 867100000
  27. Add Frequency = 867300000
  28. Add Frequency = 867500000
  29. Add Frequency = 867700000
  30. Add Frequency = 867900000
  31. Adaptive data rate (ADR) – Dynamic mode
  32. Click on button Save changes

 

Sending “Hello LoRa!” to TTS

  1. In TTS -> Applications -> YourAppName -> YourEndDeviceName -> Payload formatters -> Uplink change Formatter type to Custom Javascript formatter and to Formatter code copy and paste code bellow:
    function Decoder(bytes, port) { 
       return {
              mydata: String.fromCharCode.apply(null, bytes) // Decode plain text
       };
    }
  2. Save changes
  3. To your Arduino IDE copy and paste program Sending Hello LoRa – OTAA.
  4. In program replace APPEUI, DEVEUI and APPKEY with keys in TTS. Keys are in TTS -> Applications -> YourAppName -> YourEndDeviceName -> Overview -> Activation information.
  5. Connect Adafruit Feather M0 using micro USB cable to your computer.
  6. Choose the appropriate COM port which is used for communication with Adafruit.M0 Setup Arduino IDE
  7. In Arduino IDE click on Upload button to upload program to your Adafruit Feather M0.
  8. In Arduino IDE click on Serial Monitor button and you should every +-30 seconds see “Sending – Hello, LoRa!”:
  9. In TTS -> Applications -> YourAppName -> YourEndDeviceName -> Live data you should see this:

 

Activation By Personalization (ABP)

MCCI LoRaWAN LMIC library setup

  1. In the Arduino IDE Library Manager search MCCI LoRaWAN LMIC library by Terry Moore and install it.Adafruit 32u4 Arduino2 Setup
  2. On Windows open lmic_project_config.h located in \Documents\Arduino\libraries\MCCI_LoRaWAN_LMIC_library\project_config\
  3. Change project definitions to definitions listed bellow and save it.
// project-specific definitions
#define CFG_eu868 1                  //for Europe (change it based on your location)
#define CFG_sx1276_radio 1
#define DISABLE_JOIN 1
#define DISABLE_PING 1
#define DISABLE_BEACONS 1

 

Add Feather M0 into The Things Stack

  1. Create an account on The Things Network if you don’t have one.
  2. Login on The Things Network.
  3. Click on your username and choose Console.
  4. Select a network cluster.
Add application
  1. Go to applications.
  2. Click on button + Create application.
  3. Write something into Application ID.
  4. Click on button Create application.
Add end device
  1. In your application click on button + Register end device.
  2. Input Method – Choose Enter end device specifics manually.
  3. Frequency plan – Europe 863-870 MHz (SF9 for RX2 – recommended)
  4. LoRaWAN version – LoRaWAN Specification 1.0.3
  5. Click on Show advanced activation, LoRaWAN class and cluster settings
  6. Activation mode – Activation by personalization (ABP)
  7. Additional LoRaWAN class capabilities – None (class A only)
  8. Deselect – Use network’s default MAC settings
  9. Rx1 data rate offset = 0
  10. Rx1 delay = 1
  11. Resets frame counters – Enabled
  12. Rx2 data rate = 3
  13. Rx2 frequency = 869,525 MHz
  14. Add Frequency = 868100000
  15. Add Frequency = 868300000
  16. Add Frequency = 868500000
  17. Add Frequency = 867100000
  18. Add Frequency = 867300000
  19. Add Frequency = 867500000
  20. Add Frequency = 867700000
  21. Add Frequency = 867900000
  22. DevEUI – Generate
  23. Device address – Generate
  24. AppSKey – Generate
  25. NwkSKey – Generate
  26. End device ID – here you can name your device
  27. After registration – View registered end device
  28. Click on button Register end device
  29. Click on General settings
  30. Network layer – Expand
  31. Click on Advanced MAC settings
  32. Desired Rx1 delay = 1
  33. Adaptive data rate (ADR) – Dynamic mode
  34. Click on button Save changes

 

Sending “Hello LoRa!” to TTS

  1. In TTS -> Applications -> YourAppName -> YourEndDeviceName -> Payload formatters -> Uplink change Formatter type to Custom Javascript formatter and to Formatter code copy and paste code bellow:
    function Decoder(bytes, port) { 
       return {
              mydata: String.fromCharCode.apply(null, bytes) // Decode plain text
       };
    }
  2. Save changes
  3. To your Arduino IDE copy and paste program Sending Hello LoRa.
  4. In program replace NWKSKEY, APPSKEY and DEVADDR with keys of your end device registred in TTS. Keys are in TTS -> Applications -> YourAppName -> YourEndDeviceName -> Overview -> Session information
  5. Connect Adafruit Feather M0 using micro USB cable to your computer.
  6. Choose the appropriate COM port which is used for communication with Adafruit.M0 Setup Arduino IDE
  7. In Arduino IDE click on Upload button to upload program to your Adafruit Feather M0.
  8. In Arduino IDE click on Serial Monitor button and you should every +-1 minute see “Sending – Hello, LoRa!”:
  9. In TTS -> Applications -> YourAppName -> YourEndDeviceName -> Live data you should see this:TTS_Hello_Lora