element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Wireless
  • Technologies
  • More
Wireless
Blog RAK Wireless WisBlock Starter Kit
  • Blog
  • Forum
  • Documents
  • Polls
  • Quiz
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Wireless to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ralphjy
  • Date Created: 29 Apr 2022 9:43 PM Date Created
  • Views 3762 views
  • Likes 2 likes
  • Comments 2 comments
  • ble
  • lora
  • wisblock_starter_kit
  • rakwireless
Related
Recommended

RAK Wireless WisBlock Starter Kit

ralphjy
ralphjy
29 Apr 2022

Many wireless transceivers are now available as pluggable modules using high density connectors like the M.2 edge connector or plug and socket board-to-board connectors.  This provides to implement custom PCBs where you can quickly add or customize wireless capability.

I've been looking for a module that has both BLE and LoRa protocols and I found the RAK4631 from RAK Wireless - RAK4631 LPWan Node.

Key Features:

  • RAK4631: LoRaWAN® 1.0.2 protocol stack (supports Class A & C)
  • RAK4631-R: LoRaWAN® 1.0.3 protocol stack (supports Class A, B & C)
  • Bluetooth Low Energy 5.0 protocol stack
  • Nordic nRF52840:
    • Ultra-low-power MCU
    • 32-bit ARM® Cortex-M4F CPU
    • 64MHz CPU clock
    • 1 MB Flash, 256 KB RAM
  • Wide range of connections:
    • I2C, SPI, Analog inputs,
    • Digital inputs and outputs
  • Semtech SX1262:
    • Low power high range
    • LoRa® transceiver

The module does require a carrier (base) board, either a custom one or RAK offers a variety of base boards that also provide connectors for sensors and other accessories plus a USB interface.  I decided to buy a starter kit that included the RAK4631 and WisBlock Base RAK 5005-O plus LoRa and BLE u.FL antennas.  The board also provides a micro USB connector and power connectors for a LiPo battery or solar.  It also has connectors for 4 sensor modules and 1 IO module (e.g. GNSS, display).

WisBlock Starter Kit

image

The daughter boards connect to the base board using either a 24 pin (Sensor) or 40 pin (IO/Core) WisConnector.

image

Good news for me - the RAK boards are supported in the Arduino IDE and Platform IO.  Since I'm familiar with the nRF52840, I thought I'd try out a quick BLE example.

image

I decided to try a simple BLE UART and connect it to the Adafruit Bluefruit LE Connect app that I have running on my iPad.

Here's my setup:

image

The Arduino sketch

RAK4631_ble_uart.ino

/*
   file ble_uart.ino
   author Bernd Giesecke
   brief BLE example shows how to implement UART over BLE
   version 0.1
   date 2020-07-27

   copyright Copyright (c) 2020

   note RAK4631 GPIO mapping to nRF52840 GPIO ports
   RAK4631    <->  nRF52840
   WB_IO1     <->  P0.17 (GPIO 17)
   WB_IO2     <->  P1.02 (GPIO 34)
   WB_IO3     <->  P0.21 (GPIO 21)
   WB_IO4     <->  P0.04 (GPIO 4)
   WB_IO5     <->  P0.09 (GPIO 9)
   WB_IO6     <->  P0.10 (GPIO 10)
   WB_SW1     <->  P0.01 (GPIO 1)
   WB_A0      <->  P0.04/AIN2 (AnalogIn A2)
   WB_A1      <->  P0.31/AIN7 (AnalogIn A7)
*/

#include <Arduino.h>
#include <bluefruit.h>

// Forward declarations for functions
void ble_connect_callback(uint16_t conn_handle);
void ble_disconnect_callback(uint16_t conn_handle, uint8_t reason);

/**
   @brief  BLE UART service
   @note   Used for BLE UART communication
*/
BLEUart g_BleUart;

/** Flag if BLE UART client is connected */
bool g_BleUartConnected = false;

/**
   @brief Arduino setup function. Called once after power on or reset
*/
void setup()
{
    // Initialize built in green LED
    pinMode(LED_BUILTIN, OUTPUT);
    digitalWrite(LED_BUILTIN, HIGH);

    // Initialize Serial for debug output
    Serial.begin(115200);

    // Wait for USB Serial to be ready or terminal to be connected
    time_t timeout = millis(); // Timeout in case the system runs on its own
    // Waiting for Serial
    while (!Serial)
    {
        if ((millis() - timeout) < 5000)
        {
            // Blink the LED to show that we are alive
            delay(100);
            digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
        }
        else
        {
            // Timeout while waiting for USB Serial
            break;
        }
    }

    Serial.println("================================");
    Serial.println("RAK4631 BLE UART example");
    Serial.println("================================");

    // Config the peripheral connection with maximum bandwidth
    // more SRAM required by SoftDevice
    // Note: All config***() function must be called before begin()
    Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
    Bluefruit.configPrphConn(92, BLE_GAP_EVENT_LENGTH_MIN, 16, 16);

    Bluefruit.begin(1, 0);
    // Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
    Bluefruit.setTxPower(4);
    // Set the BLE device name
    Bluefruit.setName("RAK4631_UART");

    Bluefruit.Periph.setConnectCallback(ble_connect_callback);
    Bluefruit.Periph.setDisconnectCallback(ble_disconnect_callback);

    // Configure and Start BLE Uart Service
    g_BleUart.begin();

    // Set up and start advertising
    // Advertising packet
    Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
    Bluefruit.Advertising.addTxPower();
    Bluefruit.Advertising.addName();

    /* Start Advertising
     - Enable auto advertising if disconnected
     - Interval:  fast mode = 20 ms, slow mode = 152.5 ms
     - Timeout for fast mode is 30 seconds
     - Start(timeout) with timeout = 0 will advertise forever (until connected)

     For recommended advertising interval
     https://developer.apple.com/library/content/qa/qa1931/_index.html
    */
    Bluefruit.Advertising.restartOnDisconnect(true);
    Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
    Bluefruit.Advertising.setFastTimeout(30);   // number of seconds in fast mode
    Bluefruit.Advertising.start(0);             // 0 = Don't stop advertising after n seconds
}

/**
   @brief  Callback when client connects
   @param  conn_handle: Connection handle id
*/
void ble_connect_callback(uint16_t conn_handle)
{
    (void)conn_handle;
    g_BleUartConnected = true;

    Serial.println("BLE client connected");
}

/**
   @brief  Callback invoked when a connection is dropped
   @param  conn_handle: connection handle id
   @param  reason: disconnect reason
*/
void ble_disconnect_callback(uint16_t conn_handle, uint8_t reason)
{
    (void)conn_handle;
    (void)reason;
    g_BleUartConnected = false;

    Serial.println("BLE client disconnected");
}

/**
   @brief Arduino loop. Runs forever until power off or reset

*/
void loop()
{
    // Forward anything received from USB Serial to BLE UART
    if (Serial.available() && g_BleUartConnected)
    {
        g_BleUart.print(Serial.readString());
    }

    // Forward anything received from BLE UART to USB Serial
    if (g_BleUart.available())
    {
        Serial.print(g_BleUart.readString());
    }
}

{gallery}BLE UART Test

image

Bluefruit LE Connect: Select Service

image

Bluefruit LE Connect: UART Send Message

image

Bluefruit LE Connect: UART Message Sent

image

Arduino Serial Monitor: UART Message Received

So, BLE UART is working.

I should have gotten a Sensor IO adapter module so that I could add Grove, Stemma QT or Click sensors - that's on my list to buy.  

Next to try is using LoRa and BLE together, or maybe just try LoRa separately first.

  • Sign in to reply
  • cstanton
    cstanton over 3 years ago in reply to ralphjy

    I guess there's /some/ pattern matching.

    Thanks for your patience.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • ralphjy
    ralphjy over 3 years ago

    Finally got this blog post published.  It had gotten stuck in moderation when I had saved a draft.  Something new that I learned is that you can't have an email address in your post or possibly even the "@" character.

    image

    I had not intentionally used an "@"  character, but there were some in the comments of the example code that I had used Disappointed.  And there actually was an email address of the original author.

    cstanton fixed it for me.  I'll need to remember to check text or code that I insert into a post.  It will be interesting to see if this comment has any problems...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube