Developer
Ask a QuestionBlecon WebsiteBlecon Console
  • Learn Blecon
    • Introduction
    • Blecon Modems
      • Device Identity and Network Security
      • Modem Firmware vs Modem Library
      • Using the Modem
      • Communicating with the cloud
      • Sending data from the cloud to a device
    • Blecon Hotspots
    • Blecon Networks
      • Blecon Accounts
      • Registering devices
        • The Blecon Scanner
        • Blecon Scanner Developer Guide
      • Blecon Events
      • Cloud Integrations
  • Cloud Integrations
    • Webhook
    • AWS S3
    • AWS SQS
    • AWS EventBridge
    • Memfault
  • Getting Started Guides
    • Getting started index
    • Install the Blecon Modem Firmware
    • Set up a Blecon Hotspot
    • Use Blecon from your computer with the Blecon CLI
    • Create a Network and register a device
    • Send device requests and events to your web service
    • Use Blecon from a Development Board
    • Use the Blecon Modem from an MCU
  • Device Guides
    • KKM S5-BCN
  • Development Board Guides
    • Supported Development Boards
    • Ezurio DVK-BL54L15
    • Fanstel EV-BM15C
    • InsightSiP ISP2454-LX-EB
    • Nordic nRF52840DK
    • Nordic nRF54L15DK
    • Minew ME54BE01
    • Panasonic PAN-B511 EVB
    • Raytac AN54L15Q-DB
    • u-Blox EVK-NORA-B20
  • Modem Reference
    • Modem Firmware Releases
      • nRF54L15 DK
      • nRF52840 Dongle
      • nRF52840 DK
    • CLI Releases
    • SDK Releases
    • Modem API Reference
    • Modem Protocol Reference
      • Request Frames
      • Command Protocol
      • UART Transport
    • Guides and best practices
      • Retrieve a device's identity
  • Cloud Reference
    • Configuration API
    • Advanced event routing
  • Hotspot Reference
    • Blecon Hub
Powered by GitBook

Get Support

  • Ask a question
On this page
  • Introduction
  • Prerequisite: Flash and Connect a Blecon Modem
  • Prerequisite: Set-up a Blecon hotspot
  • Set up your development environment
  • Build & flash the example application
  • Connect the device to you network
  • Make a first request
  • Summary
  1. Getting Started Guides

Use the Blecon Modem from an MCU

Using the Modem API from an MCU

PreviousUse Blecon from a Development BoardNextKKM S5-BCN

Last updated 5 months ago

Introduction

This guide covers getting started using the with a supported board. This example uses the , however most boards supporting with an UART supporting hardware flow control can be made to work as well.

The Blecon Device SDK allows you to use a Blecon modem directly from your device. Initially, the SDK supports the Zephyr operating system.

The aim of this getting started guide is to help you evaluate the Blecon Device SDK by compiling, flashing and running a simple example.

Prerequisite: Flash and Connect a Blecon Modem

You can then connect your modem to the Nucleo board.

For ease of use we have listed the corresponding nRF52840DK pins for this modem platform below. When using this platform, make sure the power switch is on, and SW6 is set to "nRF only" to prevent the modem board from drawing too much power.

See the Modem Firmware Releases page for the relevant pinout for other modems.

Nucleo Pin
Blecon Modem Pin
nRF52840DK

5V

5V

GND

GND

D0 / UART1 RX / PA10

TX

D0 / P1.01

D1 / UART1 TX / PA9

RX

D1 / P1.02

D2 / UART1 RTS / PA12

CTS

D3 / P1.04

D10 / UART1 CTS / PA11

RTS

D2 / P1.03

Prerequisite: Set-up a Blecon hotspot

Set up your development environment

We will start by setting up a west workspace containing the Blecon Device SDK.

Initialising the SDK's west workspace

First, initialise a west workspace for the SDK:

$ west init -m https://github.com/blecon/blecon-device-sdk
=== Initializing in /Users/blecon/ws/test
--- Cloning manifest repository from https://github.com/blecon/blecon-device-sdk
Cloning into '/Users/blecon/ws/test/sdk-test/.west/manifest-tmp'...
remote: Enumerating objects: 91, done.
remote: Counting objects: 100% (91/91), done.
remote: Compressing objects: 100% (62/62), done.
remote: Total 91 (delta 19), reused 86 (delta 14), pack-reused 0
Receiving objects: 100% (91/91), 143.61 KiB | 738.00 KiB/s, done.
Resolving deltas: 100% (19/19), done.
--- setting manifest.path to blecon-device-sdk
=== Initialized. Now run "west update" inside /Users/blecon/ws/test/sdk-test.

Update the workspace:

$ west update
=== updating nrf (nrf):
--- nrf: initializing
Initialized empty Git repository in /Users/donatiengarnier/ws/test/sdk-test/nrf/.git/
--- nrf: fetching, need revision v2.4.0
warning: redirecting to https://github.com/nrfconnect/sdk-nrf/
remote: Enumerating objects: 169039, done.
...

Build & flash the example application

We will now build the application and flash it on the DK.

Compiling the example for the Nucleo L433-RC-P

$ west build -b nucleo_l433rc_p -s blecon-device-sdk/examples/zephyr/hello-world
...
[167/167] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       81532 B       256 KB     31.10%
             RAM:       52424 B        64 KB     79.99%
        IDT_LIST:          0 GB        32 KB      0.00%

Flashing the Nucleo L433-RC-P with the example

You can now flash the example with west.

$ west flash
-- west flash: rebuilding
ninja: no work to do.
-- west flash: using runner openocd
-- runners.openocd: Flashing file: /Users/blecon/ws/test/build/zephyr/nucleo_l433rc_p/zephyr/zephyr.hex
Open On-Chip Debugger 0.12.0
...
wrote 81536 bytes from file /Users/blecon/ws/test/build/zephyr/nucleo_l433rc_p/zephyr/zephyr.hex in 1.980365s (40.207 KiB/s)

Connect the device to you network

Reading the device's URL

Connect a serial terminal (baudrate 115200bps) to the DK to read the device's unique URL.

$ screen /dev/tty.usbmodem0006836592911 115200
uart:~$ *** Booting Zephyr OS build v3.6.0 ***
uart:~$ Device URL: https://blecon.dev/27c6dcd1-1920-4a27-b80c-03debc122c4b

You can also type blecon announce command in the Zephyr shell to identify your device with your hotspot.

uart:~$ blecon announce

Once obtained, you can register this device with your network.

Make a first request

The hello world example makes requests to a globally available integration. In the request parameters, the namespace field is set to "global:blecon_util" and method field to "echo". To send data to your own integration instead, set those to NULL.

Making requests

You can now go back to the serial terminal - you should shortly see a first request being made!

$ screen /dev/tty.usbmodem0006836592911 115200
...
Connected, sending request.
Got response: Hello blecon!

To make further requests, use the blecon connection_initiate command:

uart:~$ blecon connection_initiate
uart:~$ Connected, sending request.
Data sent
Data received
Frame: Hello blecon!
All received
Request successful
Disconnected

What is happening behind the scenes?

Once the Blecon library is initialised, a connection is requested. Once the connection is made (and a corresponding callback is raised), the program sends a request. As part of preparing the request, the program queues one operation to send data (the ASCII string "Hello blecon!") and one to receive the response.

Callbacks are raised when these operations complete.

Refer to the Modem API Referencefor details on the various functions calls and callbacks.

Summary

This simple example showcases how you can use Blecon from an MCU running Zephyr to send and receive data to a cloud service using Bluetooth Low Energy.

If you're not familiar with Zephyr, please head first .

The Nucleo board will drive a Blecon modem connected to its UART. First, you'll need to flash a supported Blecon modem platform with the latest modem firmware. Follow the for more details.

Install the or Set up a Blecon Hotspot.

If you don't want to change the example's source code, prebuilt firmware images for supported boards are also available in the

Make sure your environment is set up to build for Zephyr by following through the . This guide shows you how to install all the tools you will need for this quickstart.

Use west build to compile the example. You can have a look at the application's configuration in the its .

Please have a look at the and review the program's control flow.

To explore Blecon further, or email us at

to the relevant documentation
modem getting started guide
Blecon app
latest SDK's release
corresponding getting started guide
prj.conf file
example's source code
book a technical meeting
support@blecon.net
Blecon Device SDK
Zephyr
ST Nucleo L433-RC-P
Getting started with the Blecon Device SDK