iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🧭

Getting Started with Wio BG770A and SORACOM: Overview

に公開

Introduction

The board I pulled out this time is the Wio BG770A Cellular IoT Development Board from Seeed Studio. It is a cellular IoT device equipped with a Quectel BG770A-GL LTE modem and a Nordic nRF52840.
This device was hugely popular last year (2024), and so many people have written articles about it that I have lost count, but I decided to write about it since I finally got around to running it.
Summarizing the same content from a different perspective might lead to new discoveries, and the fact that the internet is overflowing with articles about it only benefits the device itself.

The content today is almost identical to the official Seeed Studio wiki, with added points that I found noteworthy or was curious about, along with supplementary information when I was actually running it.

I plan to use the format of this device's article to summarize other backlog devices in the same way.

Let's get started.

Understanding the Hardware Overview

Basic information can be found in the official wiki hardware manual.
Here is what it looks like.

alt text

alt text

Before running it, let's grasp the rough hardware configuration of the Wio BG770A.
Everything else follows that.

Block Diagram

Let's take a look at the block diagram.

alt text
Reprinted from https://seeedjp.github.io/Wiki/Wio_BG770A/hardware

There are three key takeaways from the block diagram.
First, power from USB Type-C/PH is converted to VSYS_3V3 (3.3V) via a DC-DC converter and supplied commonly to the nRF52840 and the Grove domain. Second, the nRF52840 SoC directly controls the Grove Digital/Analog/I2C/UART ports and USB CDC, acting as the coordinator for sensors. Finally, it is connected to the cellular module BG770A-GL via UART/DIO, a structure where AT commands are sent out from the nRF52840.

Block Role
nRF52840 SoC Runs Arduino/FreeRTOS applications and manages Grove ports, USB logs, and UART to the BG770A.
Cellular Module BG770A-GL Built-in LTE-M / NB-IoT connectivity, TCP/HTTP/MQTT support, controlled by AT commands.
Power Block Converts USB/PH 2P input to 3.3V via DC-DC and supplies stable power to Grove, BG770A, and SoC.
Grove Domain Provides Digital/Analog/I2C/UART ports; power can be controlled via VGROVE_ENABLE.
Antenna & SIM Connect external LTE/GNSS antennas via u.FL and use SORACOM Air SIM from the nanoSIM/eSIM slot.

List of Interfaces

Connectable external interfaces are as follows:

Interface Role Notes
USB Type-C Power supply, UF2 writing, USB CDC (2 ports) 5V input is converted to VSYS_3V3 by DC-DC and supplied to nRF52840/BG770A via the DCDC block in the diagram
PH 2P (3.4-17V) External DC power input OR-ed to the same VSYS line as USB
Grove Digital (J1) General GPIO (D30/D31) Can also be used as Analog (A6/A7)
Grove Analog (J8) Analog/DAC (A4/A5) Can also be used as Digital (D28/D29)
Grove I2C (J6) I2C bus (SCL/SDA) Can also be used as Digital (D4/D5), Analog (A2/A3)
Grove UART (J7) Serial1 (TXD/RXD) Can also be used as Digital (D13/D14); separate UART from BG770A
SIM slot / eSIM SORACOM Air SIM nanoSIM
LTE Antenna (u.FL) External antenna for LTE-M/NB-IoT Included PCB antenna
GNSS Antenna (u.FL) GNSS antenna for BG770A Available exclusively from LTE
SWD (TC2030, 2x10) nRF52840 debug/writing Used with J-Link, etc.

Power Configuration

Inputs from USB Type-C (5V) and PH 2P (3.4-17V) are automatically switched via a power OR-ing circuit using diodes, and a TPS62148-based DC-DC seems to generate 3.3V.
Power supply to internal devices is neatly unified into a 3.3V system.
Power supply to the Grove ports can be controlled via the VGROVE_ENABLE pin, allowing sensors to be powered down during low-power operation. Energy saving is well-considered.

Software Architecture Details

Let's grasp the basics of the libraries.

Software Stack

alt text

The blue frames represent the layers compiled by the IDE, while the white frames (SoftDevice/UF2) are binary layers pre-installed on the MCU.

Layer Role
User Sketch setup()/loop() and custom libraries. The app body that controls hardware via wio_cellular and Grove APIs.
Arduino Core (SeeedJP/Adafruit_nRF52_Arduino) Provides Arduino APIs such as pinMode, Serial, TinyUSB, Bluefruit, and board settings.
Real-time OS (FreeRTOS) Turns loop() into a task, providing multiple tasks, synchronization primitives, and timers.
nrfx HAL / CMSIS Abstracts UART/I2C/GPIO, etc., via Nordic's nrfx drivers and ARM CMSIS.
Nordic SDK Components Refers to auxiliary libraries other than nrfx (e.g., nrf_log, BLE helper, Flash Data Storage, etc.), linked by the Arduino Core as needed.
SoftDevice (BLE stack) Nordic's official BLE stack. Provided as a binary; applications simply call the API.
UF2 Bootloader A bootloader for writing .uf2 files via USB drag-and-drop.
User Sketch (setup/loop, FreeRTOS task)
 ├─ Seeed/Grove Libraries (Seeed_BME280, Grove_* etc.)
 │   └─ Wire/SPI/UART API (Arduino HAL)
 ├─ wio_cellular (HTTP/MQTT/UDP helper, power state helper)
 │   └─ HardwareSerial SerialBG77 (UART bridge)
 ├─ Adafruit_TinyUSB / Bluefruit
 │   └─ SeeedJP nRF52 Core
 │       └─ nrfx HAL / CMSIS
 └─ SoftDevice + UF2 (MCU resident)
 └─ BG770A AT firmware (Quectel RTOS)  ← via UART

As shown in the stack diagram above, libraries called by the user sketch (Grove, wio_cellular) sequentially pass through the Arduino HAL, SeeedJP nRF52 Core, and nrfx/CMSIS, eventually reaching the BG770A AT firmware via UART (SerialBG77). TinyUSB/Bluefruit are included in the Core as middleware for USB/BLE, providing Serial or BLEPeripheral APIs as needed. The SoftDevice and UF2 bootloader reside on the MCU, supporting BLE communication and writing processes.

FreeRTOS Task Design Overview

Let's touch on the key points of the task design to understand how FreeRTOS runs Arduino sketches.

Looking through the source code, it has the following characteristics:

  • The FreeRTOS scheduler starts after setup() execution, and loopTask (priority 1) repeatedly calls loop(). configMAX_PRIORITIES=5 and configTIMER_TASK_PRIORITY=2 are set in FreeRTOSConfig.h.
  • Additional tasks are created with xTaskCreate() to divide roles such as sensors, communication, and monitoring. They synchronize via queues and semaphores.
  • delay() and yield() call vTaskDelay / taskYIELD, so CPU relinquishment to other tasks occurs automatically.
  • For low-power operation, in addition to VGROVE_ENABLE control and PSM/eDRX settings, FreeRTOS tickless idle and vTaskSuspend are used to suppress unnecessary consumption.

The roles and priorities of major FreeRTOS tasks are as follows:

Task Priority (typical) Role
loopTask 1 (TASK_PRIO_LOW) Main task started after setup() that repeatedly calls the user sketch's loop().
TinyUSB Task 2 Processes USB CDC/HID/MassStorage. Necessary when using Serial for log output.
BLE/Bluefruit Task 2 BLE event processing in coordination with SoftDevice.
Timer Service 2 (configTIMER_TASK_PRIORITY) Processes software timers and xTimer* API callbacks.
Idle Task 0 Executes when the system is idle. Transitions to low power via tickless idle.
(User Added Task) Arbitrary (e.g., 2-3) Created via xTaskCreate(); priority set according to application.

On xTaskCreate()

User-added tasks are generated within the Arduino sketch using xTaskCreate(). For example, the following task design can be considered. We will confirm these while actually running them in the practical section.
Since there is no protocol stack on the FreeRTOS side, communication with the cloud is basically done using the wio_cellular library.

Task Example Role Example Library / API
Sensor Measurement Task Periodically reads Grove I2C sensors (e.g., SCD40) and puts them in a queue Wire, various Grove libraries
Communication Task Receives data from queue and performs HTTP/TCP/UDP transmission via wio_cellular, handles retries/reconnections WioCellular, WioNetwork
GPS/Metadata Task Obtains location info, voltage, or RTC time via UART (e.g., SIM28) and appends to payload Serial1, TinyGPS++, etc.
Monitoring / Watchdog Task Monitors task state, voltage, and events; performs reboot/log output on error xTaskGet*, analogRead, Log API
Log / Storage Task Saves logs to USB CDC or FRAM, debug output to host Serial, TinyUSB, FRAM

These are generated as xTaskCreate(taskFunc, "name", stackSize, NULL, priority, NULL); and cooperate within each task using xQueueSend, etc. Necessary libraries are included on the sketch side and used from within the tasks.

On Interrupts

Finally, here is a schematic diagram of the interrupt processing flow.

  • Peripherals of the nRF52840 (GPIO/GPIOTE, UART, I2C/SPI, TIMER/RTC, SAADC, etc.) issue IRQs to the NVIC, which are received by the nrfx HAL.
  • The nrfx notifies FreeRTOS tasks via xQueueSendFromISR or portYIELD_FROM_ISR, also processing BG770A URCs via SerialBG77.
  • SoftDevice and TinyUSB also generate IRQs internally, bridging BLE events and USB transfers to tasks.
  • API calls within loop() are normal task processing, not interrupts; if you want to use custom ISRs, implement attachInterrupt() or nrfx_* handlers.

PlatformIO Environment Setup

For Wio, development procedures using PlatformIO are detailed in the official wiki, so you can follow them.
https://seeedjp.github.io/Wiki/Wio_BG770A/kb/kb5.html

VS Code + PlatformIO Installation Steps

Install the PlatformIO IDE from the VS Code extensions.
My environment is as follows:

MacBook Pro 2022 M2  
macOS Sequoia 15.7.2
Visual Studio Code Version: 1.106.2
  1. In the Extensions view:
    alt text

  2. Search for "PlatformIO IDE" and click the install button.
    alt text

  3. Once installed, a PlatformIO icon (looking like a gray alien) will be added to the activity bar on the left.
    alt text

  4. Click the PlatformIO icon to open the PlatformIO Home.
    alt text

  5. Click "Create New Project".
    alt text

  6. Click "New Project", and in the dialog, enter the project name (e.g., 20251201wiotest), select Board: Nordic nRF52-DK, and Framework: Arduino, then click the "Finish" button.
    alt text

  7. The project will be created, and the workspace will open.
    alt text

  8. Open the platformio.ini file and edit it as follows:

    [platformio]
    src_dir = .
    
    [env:seeed_wio_bg770a]
    platform = https://github.com/SeeedJP/platform-nordicnrf52
    platform_packages =
        framework-arduinoadafruitnrf52 @ https://github.com/SeeedJP/Adafruit_nRF52_Arduino.git
    framework = arduino
    board = seeed_wio_bg770a
    build_flags =
        -DBOARD_VERSION_1_0 ; Board version 1.0
        -DCFG_LOGGER=3      ; 3:None, 2:Segger RTT, 1:Serial1, 0:Serial
        ;-D ENABLE_TRACE    ; Enable trace
        ;-O0                ; No optimization
    lib_archive = no ; https://github.com/platformio/platform-nordicnrf52/issues/119
    

    The PlatformIO project setup is now complete. You can now place source code in the src folder to build and upload.

  9. Open /src/main.cpp.
    alt text

  10. Copy and paste the following sample code:

    /*
     * blink.ino
     * Copyright (C) Seeed K.K.
     * MIT License
     */
    
    #include <Arduino.h>
    #include <Adafruit_TinyUSB.h>
    
    void setup() {
    }
    
    void loop() {
        digitalWrite(LED_BUILTIN, HIGH);
        delay(200);
        digitalWrite(LED_BUILTIN, LOW);
        delay(800);
        }
    
  11. Connect the Wio BG770A in UF2 mode.
    While connected via USB, press the reset button twice to enter UF2 mode.

  12. Build and upload. Click the "Upload" button in PlatformIO.
    alt text
    The arrow icon in the bottom left also works.
    alt text

  13. Once build and upload succeed, the built-in LED of the Wio BG770A will start blinking.

Conclusion

Now that we have grasped the hardware overview and the essentials of software design, the next basic section will explain the procedures and implementation for actually performing communication and manipulating interfaces using wio_cellular.

GitHubで編集を提案

Discussion