RAK wireless has release the RAK815 module and I was happy to try out the new version of the board. With the onboard nrf52, I could only imagine the many possibilities of programming the device. The Nordic chipset is now one of the most versatile chipset in the market supporting a number programming methods.
Hardware:According to RAK Wireless:
RAK815(RAK813 BreakBoard) is a wireless remote solution based on the RAK813 + GPS + MEMS + HT+LCD design. It integrates the latest LoRaWAN 1.0.2 protocol and the latest Bluetooth 5.0 protocol, supports LoRaWAN working mode, supports Bluetooth transparent transmission, Bluetooth up to 300 meters away..
RAK815 (RAK813 BreakBoard) built-in GPS, acceleration, temperature and humidity sensors, expanded I2C LCD interface. We provide case applications that can configure LoRaWAN parameters using Bluetooth, display sensor data using LCD, and upload sensor data to the LoRaWAN network. And all the code open source. Users can find all the open source code in github. We also designed three customizable buttons and two customizable LED lights for our users, allowing users to implement they idea with open-source code.
RAK815 (RAK813 BreakBoard) is also a support for battery-powered products. Greatly expanded product application scenarios. We also designed the function to enter the low power mode when the device is detected to be stationary to ensure battery life. The device also supports RAK831 + Ri3 gateway to use, you can graphically display the various data of the sensor in the Cayenne platform, but also support the real-time observation of sensor data on the phone.
Of course the module is completely open source and the schematics are provided by RAK wireless in their document center:
http://www.rakwireless.com/en/download
Pinout:SWD debug interface (The numbers are sorted from top to bottom )
Pin Name and Description
- 1 VCC3.3 3.3V power supply
- 2 SWDIO SWD interface data pin for NRF52832
- 3 SWDCLK SWD interface clock pin for NRF52832
- 4 P0.21_NRST P0.21 for NRF52832, Can be used as Reset pin(Button3)
- 5 GND Ground
UART switch interface (The numbers are sorted from top to bottom )
Pin Name and Description
- 1 GPS_TXD UART TXD pin for GPS module
- 2 GPS_RXD UART RXD pin for GPS module
- 3 P0.28 P0.28 for NRF52832, Used as UART RXD
- 4 P0.29 P0.29 for NRF52832, Used as UART TXD
- 5 TXD The CP2102 converts the USB to the TXD pin of the UART
- 6 RXD The CP2102 converts the USB to the RXD pin of the UART
Extension interface P1( The numbers are sorted from top to bottom )
Pin Name and Description
- 1 GND Ground
- 2 P0.24 P0.24 for NRF52832, Used to control the expansion Button2
- 3 P0.25 P0.25 for NRF52832, Used to control the expansion LED6
- 4 P0.26 P0.26 for NRF52832, Used to control the expansion LED7
- 5 P0.27 P0.27 for NRF52832, Used to control the expansion Button1
- 6 P0.28 P0.28 for NRF52832, Used as UART RXD
- 7 P0.29 P0.29 for NRF52832, Used as UART TXD
- 8 P0.30 P0.30 for NRF52832, Used to control GPS module PPS
- 9 P0.31 P0.31 for NRF52832, Used to control GPS module power
- 10 GND Ground
- 11 GND Ground
- 12 GND Ground
- 13 VCC3.3 3.3V power supply
- 14 VCC3.3 3.3V power supply
Extension interface P3( The numbers are sorted from top to bottom )
Pin Name and Description
- 1 GND Ground
- 2 SWDIO SWD interface data pin for NRF52832
- 3 SWDCLK SWD interface clock pin for NRF52832
- 4 P0.20 P0.20 for NRF52832
- 5 P0.19 P0.19 for NRF52832
- 6 P0.18 P0.18 for NRF52832
- 7 P0.17 P0.17 for NRF52832
- 8 P0.16 P0.16 for NRF52832, Used as I2C SCL
- 9 P0.15 P0.15 for NRF52832, Used as I2C SDA
- 10 GND Ground
- 11 P0.21_NRST P0.21 for NRF52832, Can be used as Reset pin(Button3)
- 12 P0.04 P0.04 for NRF52832, Used to control LIS3DH module INT1
- 13 P0.03 P0.03 for NRF52832, Used to control LIS3DH module INT2
- 14 P0.02 P0.02 for NRF52832, Used as ADC to detect battery charge
RAK wireless provides a whole bunch of examples to get started with the board on their Github page:
https://github.com/RAKWireless/RAK813-BreakBoard
Basically the RAK815 is the RAK813 with a few extra peripherals on a board :)
However, we are makers and Arduino IDE is the choice for young maker who want to get started wuickly with the Board. I had taken up the task to see how easily we can integrate the development for this board into Arduino IDE.
Behold...Arduino IDE support for RAK815Yes....its true, the RAK815 board can now be completely programmed from the Arduino IDE. Some of the notable features supported:
- Serial DFU bootloader
- OTA DFU bootloader
- Support for BLEPeripheral library
- Support for all on-board sensors
My github repo below hosts all the files necessary to get the above features:
https://github.com/narioinc/nRF52832_Breakout
JTAG drivers:Before we proceed make sure that our system has the necessary JTAG JLink drivers for us to use the Jlink module to porgram the nrf52 device via the Arduino IDE.
Windows:
On Windows, proceed to download teh Link drivers form the SEGGER website. The driver is available for free and is downloadable at the link below:
https://www.segger.com/downloads/jlink
Linux:
For Ubuntu DEB packages or Fedora/Centos RPM packes please visit the link below:
https://www.segger.com/downloads/jlink
Once installed the JLink module should be visible as a CDC UART once connected to the machines. On windows it will appear like a CDC peripheral. On linux it will be available as a /dev/ttyACM0
Toolchain RequirementsTo compile this bootloader, you'll need armgcc and Nordic's nRF5_SDK_V11.0.0.
Documentation for the nRF5 SDK (v11.0.0) can be found at http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v11.0.0%2Findex.html. Follow along with the instructions there to install and set up the SDK. Note that GCC is used instead of Keil or IAR.
Serial DFU bootloader:Its worth the effort of pushing this to a seperate topic. It was because of the effort of awesome devs over at Sparkfun that I got the inspiration to port a Serial DFU bootloader to the RAK815. I was able to get it up and running with a few hiccups along the way. However you guys dont need to go through all that...
Just follow the steps below to flash the bootloader onto the board.
- Connect the Board to the SWD interface and JLINK module.
- Head over to my repo and clone it. https://github.com/narioinc/nRF52832_Breakout.git
- cd to nRF52832_Breakout folder and do make clean
- Then, execute the command "make sfe_nrf52832_dfu". For this command to run, make sure you have NRF SDK v11.0.0. and it is updated in the Makefile. Not tested with other versions
- Once the program successfully builds, just connect your RAK815 over SWD interface using your JLink module
- execute the command "./flash_bootloader.sh"
At the end of the steps, you Should have the board burnt with the Serial DFU bootloader.
Board Hardware details- SW3 is the board reset switch
- SW1 is the board bootloader switch
- LED6 is the bootloader time-bomb LED (currently not working, fix on the way)
When you want to enter bootloader mode, keep SW1 pressed, then press SW3 and release SW3 after a second and then release SW1.
Now lets get over to Editing the Arduino IDE for supporting our board.
Arduino IDE core editsThe repository consist of the board variant and other headers to ensure smooth support for Arduino programming
Download and Install the Board Package
The nRF52 Arduino cores are based on the great work by sandeepmistry. Sparkfun has added nRF52832 Breakout Board compatibility to his board files, and added an extra tool to enable serial bootloading.
Since the RAK wireless RAK815 is just having a few extra LEDs and Buttons that the Sparkfun board, it was easy to port the bootloader functionality.
- To install support for the nRF52 board in Arduino, begin by opening your Arduino preferences (File > Preferences). Then copy and paste the URL below into the “Additional Board Manager URLs” text box.
- Then hit OK, and navigate to the Tools > Board > Boards Manager… tool. A search for “nRF52” should turn up a SparkFun nRF52 Boards result. Select that and click install.
- The install may take a few minutes – the package includes arm-gcc and a few other tools totaling around 100 MB. Once the installation is complete, go to Tools > Board and select “SparkFun nRF52832 Breakout” under the “Nordic Semiconductor nRF5 Boards” section.
- You can now create Sketches using the BLEPeripheral library as well and compile them for the RAK815 board.
Install the RAKWireless RAK815 Board variant
It is easy to install the RAkWireless Board variant into the IDE (For ubuntu/other linux users)
- Copy the Boards.txt into.arduino15/packages/SparkFun/hardware/nRF5/0.2.3/boards.txt
- Copy the RAK815_nrf52832_Breakout folder in the variants folder in the path.arduino15/packages/SparkFun/hardware/nRF5/0.2.3
For Windows users, just search for the path that has the packages/Sparkfun folder :)
- Next, restart Arduino IDE, you should be able to see an entry for the RAK Wireless RAK815 board. Now you can flash as you normally do
Based on the details in the PR request here: https://github.com/sandeepmistry/arduino-nRF5/pull/205/files?utf8=%E2%9C%93&diff=split
I have made the necessary changes in the WInterrupt.c and header files to support the Software serial. I have tested uptil 38400 as baud rate and things work well.
Please replace the three files in your sparkfun/adafruit nrf5 core directory and enjoy SoftwareSerial.
Thanks to the awesome devs at the nrf5-arduino core.https://github.com/micooke
Phew...that was slightly complex isnt it. Well, now that your all setup, programming the board will be as easy as 1...2...3.
Example programsThe examples folder provides a number of arduino files for you to get started. Just open any of the projects. Make sure you have the dependencies (noted down below) installed for the particular examples.
Contents- /OLEDDemo : Demo program for the onboard OLED Screen
- /SHT31Demo : Demo program for the onboard SHT31 sensor
- /LIS3DH Demo : Demo program for the onboard LIS3DH Sensors
- /LIS3DH Spark Demos : Demo programs using the Sparkfun LIS3DH library with interrupt support
- /simple_test_GPS: Demo program for the Ublox MAX-7q GPS reciever.
- /BLEserial: Demo program showcasing the BLE UART example to send messages to the nrf UART profile. Use the Adafruit Bluefruit app to open the UART and see the messages.
The examples mentioned require the followin libraries
- Adafruit Sensor lib : https://github.com/adafruit/Adafruit_Sensor
- Adafruit LIS3DH lib : https://github.com/adafruit/Adafruit_LIS3DH
- Adafruit SHT31 sensor: https://github.com/adafruit/Adafruit_SHT31
- Acrobotic OLED lib: https://github.com/acrobotic/Ai_Ardulib_SSD1306
- Sparkfun LIS3DH lib: https://github.com/sparkfun/SparkFun_LIS3DH_Arduino_Library
- TinyGPS lib: https://github.com/mikalhart/TinyGPS
The GPS example uses the SoftwareSerial. Make sure you enable software serial by following the instruction in the README file inside Arduino Files folder
Once enabled, ensure that the p0.19 and p0.20 pins on the nrf52 are connected to RX and TX of the GPS module and initiate SoftwareSerial object.
Flashing the BoardNow your all set to flash your first program. Just select the BareMinimum example from Arduino IDE example menu
- Once you have BareMinimum example selected, head over to boards menu and select the "RAKWireless Rak815 nrf52832" board variant.
- Also select the port on which you are connected the board via micro USB cable. While connecting the board, make sure that on JUMPER HEADER P13, the jumper is as so:
P0.29 - > RXD
P0.28 -> TXD
- so in your code you will see that P0.29 would become Serial TX and P0.28 will become Serial RX. I have made the necessary changes in the Board variant files.
- Enter bootloader mode on the board as mentioned in the sections above and then click on the program button and see the magic happen. The board will be programmed over Serial and will reset. You can also reset the board anytime you want by using the SW3 button which is mapped to the N_RESET pin of the nrf52 chipset.
I have also made it possible for the RAK815 to support the OTA DFU bootloader. Using the OTA DFU, developers can push the new application zip generated by the nrfutil command-line utility over BLE and then flash on the chip.
https://github.com/narioinc/nRF52832_Breakout/tree/master/Firmware/bootloader-ota-dfu
The folder above consist of a "buttonless" OTA dfu. which means you can just reset the board and the board will remain in DFU mode for 30 seconds after which it will execute the application section.
Create nrfutil spplication zip
The pkg command generates a package to use for a Device Firmware Update. The package contains the new firmware image, an init packet, and a manifest file that indicates the package format. The command can also be used to display the package contents.
Run nrfutil pkg generate to generate a zip file that you can use later with a mobile application or another tool to update the firmware of an nRF5 IC. There are several options available, which you can view by entering the following command:
nrfutil pkg generate --help
Run nrfutil pkg display to display the contents of a package.
For example, enter the following command to generate an unsigned package called app_dfu_package.zip from the application file app.hex:
nrfutil pkg generate --application app.hex app_dfu_package.zip
Enter the following command to generate a package called app_dfu_package.zip from the application file app.hex with application version 4 that requires hardware version 51 and SoftDevice S130 v2.0.0 (0x80) and is signed with the private key that is stored in key.pem:
nrfutil pkg generate --hw-version 51 --sd-req 0x80 --application-version 4 --application app.hex --key-file key.pem app_dfu_package.zip
Enter the following command to generate an unsigned debug package without version information from the application file app.hex:
nrfutil pkg generate --debug-mode --application app.hex app_dfu_package.zip
Enter the following command to display the contents of the created package:
nrfutil pkg display app_dfu_package.zip
Steps to flash the application zip generated by nrfutil:
First, we need to transfer it from the computer to the smartphone (via an USB connection, email, Cloud drive or other means), and open the nRF Toolbox smartphone app.
Click DFU, and accept Bluetooth activation if requested
Click “Select Device”
Search for the “DfuTarg” device and select it.
Now hit “Select File” and select “Distribution packet (ZIP)”
In the file explorer, select the .zip folder you transferred
Click “Upload”
you should get a dialog popup (a toast actually !) that shows the app has been flashed:
That’s it ! The nRF52 board has been updated with the new application. However if you power off the board and power it back on while RESET button is pressed, it will restart in DFU mode so that you can flash another application.
We will cover some of the examples in a bit more detail in the upcoming tutorials on the RAK815
Comments