Giter Club home page Giter Club logo

atsamr34_rn487x_lorawan_ble's Introduction

ATSAMR34_RN487x_LORAWAN_BLE

“Wireless Made Easy!" - Adding BLE features & provisioning to an existing LoRaWAN Application

Microchip_logo

This sample code demonstrates how to provision & control a LoRaWAN end-device over a BLE connection between Smartphone App and a RN4870/71 module.

For more information on Microchip ATSAMR34 LoRa SiP and RN4870/71 BLUETOOTH 5 certified module, visit Microchip webpages:

https://www.microchip.com/design-centers/wireless-connectivity/low-power-wide-area-networks/lora-technology/sam-r34-r35 https://www.microchip.com/wwwproducts/en/rn4870 https://www.microchip.com/wwwproducts/en/rn4871

Get a Microchip ATSAMR34 Xplained Pro evaluation kit

The ATSAMR34 Xplained Pro evaluation kit (DM320111) is a hardware platform used to evaluate the ATSAMR34 Low Power LoRa® Sub-GHz SiP. It is supported by Atmel Studio 7.0 IDE and a collection of sample codes are available from Advanced Software Framework (ASFv3) since the 3.44.0 release. The Xplained Pro MCU series evaluation kit includes an on-board Embedded Debugger (EDBG), and no external tools are necessary to program or debug the ATSAMR34. The kit offers a set of features that enable the user to get started with the ATSAMR34 Low Power LoRa® Sub-GHz SiP peripherals right away, and to understand how to integrate the device in your own design. The ATSAMR34 Xplained Pro kit contains the following items:

  • One ATSAMR34 Xplained Pro
  • One external antenna

https://www.microchip.com/DevelopmentTools/ProductDetails/dm320111

Get a Microchip RN4871-PICTAIL evaluation kit

The RN-4871-PICtail is a development board based on the ultra-compact Bluetooth 5 Low Energy RN4871 module. The RN4871 uses a simple ASCII command interface over the UART.

https://www.microchip.com/DevelopmentTools/ProductDetails/PartNO/RN-4871-PICTAIL

Get a RN4870/71 click board

Alternatively, you can use a RN4870 or RN4871 click board from Mikroe.

https://www.mikroe.com/rn4870-click https://www.mikroe.com/rn4871-click

And use mikroBUS Xplained-Pro board (ATMBUSADAPTER-XPRO).

https://www.microchip.com/Developmenttools/ProductDetails/ATMBUSADAPTER-XPRO

Software

Note: ASFv3 is an MCU software library providing a large collection of embedded software for AVR® and SAM flash MCUs and Wireless devices. ASFv3 is configured by the ASF Wizard in Atmel Studio 7.0 (installed as an extension to Studio). ASFv3 is also available as a standalone (.zip) with the same content as Studio extension (https://www.microchip.com/mplab/avr-support/advanced-software-framework).

Important: Until the next Atmel Studio IDE release, you have to manually install the Device Part Pack for developing with SAMR34/R35 on Atmel Studio 7.0 IDE. (all products released in between IDE releases of Atmel Studio should be manually added by user to develop applications).

  • Go to Tools -> Device Pack Manager
  • Check for Updates
  • Search for SAMR34 and click install
  • Repeat the same for SAMR35
  • Restart Atmel Studio 7.0 IDE

Hardware Setup

To demonstrate BLE applications as well as LoRaWAN end-device provisioning, follow the connection below :

  • In order to connect in LoRaWAN, you will need to be in range of your gateway. If you don’t have gateway, check the world map (https://www.thethingsnetwork.org/map) to see if your local community has gateway deployed around your location.
  • Plug the antennas and always make sure you have the antennas plugged to your boards before powering it up.
  • Connect the ATSAMR34-Xpro board to the PC through the micro-USB cables.
    USB cable must be connected to the EDBG USB connectors of the ATSAMR34 kit.
    The USB ports powers the board.
  • Connect the FTDI cable the host PC. A COM port will be mounted. This port mounted will be used to communicate with the kit.
  • Launch Tera Term program and configure the serial ports mounted with: 115200 bps, 8/N/1

Mobile Apps

This demo requires: Microchip Bluetooth Data (MBD) Apps for mobile:
https://play.google.com/store/apps/details?id=com.microchip.bluetooth.data&hl=en
https://apps.apple.com/us/app/microchip-bluetooth-data/id1319166097

Microchip Bluetooth Smart Data
https://apps.apple.com/fr/app/bluetooth-smart-data/id1004033562
or
BLE Terminal:
https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal&hl=en
https://apps.apple.com/fr/app/ble-terminal-hm-10/id1398703795

This demo is using QRbot apps to scan a QR code. This QRcode contains the LoRaWAN provisioning information.
https://play.google.com/store/apps/details?id=net.qrbot&hl=en
https://apps.apple.com/cy/app/qrbot/id1048473097

TTN Provisioning

  • Log in to your TTN account
  • Go to the Console
  • Create an Application and note the AppEUI generated by TTN
  • From the application created, add a Device
  • For the DevEUI, use the MAC address written in the back of the SAMR34 Xplained Pro board.
  • Let TTN generate the AppKey

When the device is created, note carrefully the OTAA credentials (DevEUI, AppEUI, AppKey). You will needed later to generate the QR Code.

You have done the provisioning of the end-device within the TTN Console.

Generating QR Code for End-device provisioning

A QR Code will be used to provision the LoRaWAN OTAA parameters (DevEUI, AppEUI, AppKey) over BLE.

To be recognized by the SAMR34 sample application, the QR code must contains a string of characters which respect the following format:

Create your own QR Code from: https://www.unitag.io/qrcode

  • As QR Code Type: select Other and Text
  • In the textbox, type your own string of characters with the help of your OTAA credentials
  • Click confirm to generate your own QR Code

You can download and print your QR Code.

From your smartphone, Open the QRbot apps and scan your QR Code.

You should retrieve the "mac set otaa" command with your credentials. Copy the text.

BLE + LoRaWAN in a single Application

This project integrates the Microchip LoRaWAN Stack (MLS) Software API which provide an interface to the different software modules.

This application is based on LoRaWAN Mote Application generated from ASFv3 and already contains drivers required to interface the RN4870/71 module.

It implements the Transparent UART service. This service exposes the characteristics to transfer serial data on both direction.

From the menu, you have the choice of the application:

Tutorial

  • Start Atmel Studio 7 IDE
  • Open this project
  • From the Atmel Studio menu, go to: Build -> Build Solution
  • Flash the firmware on the ATSAMR34 Xplained Pro board
  • To get console logs through EDBG interface, open a Tera Term session with 115200 bps 8N1 configuration.
  • Reset the board
  • The application will start and should expose a menu if the interface with RN4870/71 module is correct
Try to initialize BLE device ...

===============================================
Menu: select a BLE application from the list
===============================================
1) Serial bridge
2) Beacon mode - https://www.microchip.com URL
3) Transparent chat mode
4) Scan mode
5) Search mode
6) Search and connect
7) Sleep mode
8) Wake-up
9) LoRaWAN provisioning
-----------------------------------------------
>>
  • From here, simply select a BLE application you want to be executed
  • And follow the instructions displayed on the console

Serial bridge

Beacon mode

Transparent chat mode

Scan mode

Search mode

Search and connect

Sleep mode

Wake-up

LoRaWAN provisioning

  • From here, the SAMR34 will automatically send a Join Request message to activate the device within the LoRaWAN nettwork
  • If the activation succeed, you will be notified by a "Joining Successful" message on the BLE apps
  • Go back to the TTN Console, and observe the Application Data of your device
  • You should see the Join procedure
  • Go back to the TTN Console and observe the data received in HEX

atsamr34_rn487x_lorawan_ble's People

Contributors

gd91 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.