Some Usage Methods of Seeed Studio XIAO MG24 Sense and Standard

What are they?

Seeed Studio XIAO MG24 and XIAO MG24 Sense are ultra-low-power wireless development boards based on Silicon Labs' EFR32MG24 SoC, featuring a high-performance 78MHz ARM Cortex®-M33 core. Both boards are Matter® native over Thread® and Bluetooth® Low Energy 5.3, supported by the Arduino® Core, and include 4MB Flash, 19 GPIOs, LED, and a charging circuit. They boast extremely low operating current and ultra-low-power modes, making them ideal for IoT applications, especially battery-powered projects utilizing Matter® protocols. Additionally, the XIAO MG24 Sense includes an onboard analog microphone and six-axis IMU sensors, making it an excellent choice for TinyML applications like posture detection. For more details, please click here.

Seeed Studio XIAO MG24 Silicon Labs EFR32MG24 BLE 5.3 1.95μA

Seeed Studio XIAO MG24 Standard

View Product
Seeed Studio XIAO MG24 Sense Silicon Labs EFR32MG24 BLE 5.3

Seeed Studio XIAO MG24 Sense

View Product

Getting started

simple factory program

XIAO MG24

The Standard version comes with a factory preset program called Blink Light. When you power on the XIAO, the orange user indicator will illuminate.

XIAO MG24 Sense

The factory preset program in the Sense version is designed so that the louder you shout, the brighter the light will shine.

Hardware Preparation

  • 1 x Seeed Studio XIAO MG24
  • 1 x Computer
  • 1 x USB Type-C cable
note:Some USB cables can only supply power and cannot transfer data.

Software Preparation

For the XIAO MG24, the suggested programming tool is the Arduino IDE, so the first step in software preparation is to complete the Arduino installation.
  • Step 1. Download and Install the stable version of Arduino IDE according to your operating system.
  • Step 2. Launch the Arduino application.
  • Step 3. Add the XIAO MG24 on-board package to the Arduino IDE and click OK.
  • Step 4. Close the Arduino IDE and reopen it.

Add the XIAO MG24 Board

Add the URL below to the preferences of your Arduino IDE.

Download the XIAO MG24 board package.


Opt for XIAO_MG24 variant.


Begin Your First Blink Program

  • Step 1. Launch the Arduino application.
  • Step 2. Navigate to File > Examples > 01.Basics > Blink, open the program.
  • Step 3. Choose the XIAO MG24 board model and select the appropriate port number to upload the program.

After the program uploads successfully, you'll see the output message below and notice that the orange LED on the right side of the XIAO MG24 is blinking.

Battery Usage

Battery Connection and Management

The XIAO MG24 features a built-in power management chip that allows it to be powered independently using a battery or to charge the battery through the USB port.
If you plan to connect a battery to the XIAO, we recommend using a certified 3.7V rechargeable lithium battery. When soldering the battery, please ensure you correctly identify the positive and negative terminals. The negative terminal should be connected to the side closest to the USB port, while the positive terminal connects to the side farthest from the USB port.

Charging status display

We implemented a red indicator light to display the battery charging status, keeping users informed of the current state during charging.
  • Without a battery connected: The red light turns on when the Type-C cable is connected and automatically turns off after 30 seconds.
  • Charging with a battery connected: The red light flashes while the Type-C cable charges the battery.
  • When the battery is fully charged: The red light turns off, signaling the completion of the charging process.

Other notes

  • Use Qualified Batteries: Only use batteries that meet the specified requirements.
  • Data Cable Connection: The XIAO can be connected to your computer via a data cable while running on battery power. Rest assured that it has a built-in circuit protection chip for safety.
  • LED Indicator: When powered by a battery, the XIAO MG24 will not show any LED lights (unless you’ve programmed it to do so). Please do not assess whether the XIAO MG24 is functioning based on the LED status; rely on your program for proper evaluation.
  • Battery Level Monitoring: Unfortunately, we currently cannot provide a way to check the remaining battery level through software (due to the lack of available chip pins). You should charge the battery regularly or use a multimeter to monitor the battery level.

Battery Voltage Measurement

Software code:

 

/*
  AnalogReadSerial

  Reads an analog input on pin 0, prints the result to the Serial Monitor.
  Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

  This example code is in the public domain.

  https://www.arduino.cc/en/Tutorial/BuiltInExamples/AnalogReadSerial
*/

// the setup routine runs once when you press reset:
void setup() {
  Serial.begin(115200);
  pinMode(PD3, OUTPUT);
  digitalWrite(PD3, HIGH);
}

void loop() {
  int voltageValue = analogRead(PD4);
  float voltage = voltageValue * (5.0 / 4095.0);
  
  Serial.print("Voltage: ");
  Serial.print(voltage, 2);
  Serial.println(" V");
  delay(1000);  // delay in between reads for stability
}

Display Result

Deep Sleep and Sleep Example

Demo1 Sleep Mode and wake-up

 


/*
   ArduinoLowPower timed sleep example

   The example shows the basic usage of the Arduino Low Power library by putting the device to sleep for a period of time.
   The device will enter sleep mode for 2000ms. During sleep the CPU is stopped but the RAM retains its contents.

   This example is compatible with all Silicon Labs Arduino boards.

   Author: Tamas Jozsi (Silicon Labs)
 */

#include "ArduinoLowPower.h"

void setup()
{
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LED_BUILTIN_INACTIVE);
  Serial.println("Sleep with timed wakeup");
}

void loop()
{
  digitalWrite(LED_BUILTIN, LED_BUILTIN_ACTIVE);
  delay(500);
  digitalWrite(LED_BUILTIN, LED_BUILTIN_INACTIVE);
  delay(500);

  Serial.printf("Going to sleep at %lu\n", millis());
  LowPower.sleep(2000);
  Serial.printf("Woke up at %lu\n", millis());
}

Demo2 Deep Sleep Mode and wake-up

 

/*
   ArduinoLowPower deep sleep example with external or timed wakeup

   The example shows the basic usage of the Arduino Low Power library by putting the device into deep sleep.
   The device will remain in deep sleep until the sleep timer expires.
   During deep sleep the whole device is powered down except for a minimal set of peripherals (like the Back-up RAM and RTC).
   This means that the CPU is stopped and the RAM contents are lost - the device will start from the beginning of the sketch after waking up.

   This example is compatible with all Silicon Labs Arduino boards.

   Author: Tamas Jozsi (Silicon Labs)
 */

#include "ArduinoLowPower.h"

void setup()
{
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LED_BUILTIN_INACTIVE);
  Serial.println("Deep sleep timed wakeup");
}

void loop()
{
  digitalWrite(LED_BUILTIN, LED_BUILTIN_ACTIVE);
  delay(500);
  digitalWrite(LED_BUILTIN, LED_BUILTIN_INACTIVE);
  delay(500);

  Serial.printf("Going to deep sleep for 10s at %lu\n", millis());
  LowPower.deepSleep(10000);
}

 

Demo3 Deep Sleep Mode with flash and wake-up

To enable deep sleep for the flash, you must activate the 0xb9 register.
 

/*
   ArduinoLowPower deep sleep example with external or timed wakeup

   The example shows the basic usage of the Arduino Low Power library by putting the device into deep sleep.
   The device will remain in deep sleep until the sleep timer expires.
   During deep sleep the whole device is powered down except for a minimal set of peripherals (like the Back-up RAM and RTC).
   This means that the CPU is stopped and the RAM contents are lost - the device will start from the beginning of the sketch after waking up.

   This example is compatible with all Silicon Labs Arduino boards.

   Author: Tamas Jozsi (Silicon Labs)
 */
#include <Arduino.h>
#include "ArduinoLowPower.h"

#define CS_PIN PA6
#define CLK_PIN PA3
#define MOSI_PIN PA5
#define MISO_PIN PA4

#define READ_DATA 0x03
#define WRITE_ENABLE 0x06
#define PAGE_PROGRAM 0x02
#define SECTOR_ERASE 0x20

void sendSPI(byte data) {
  for (int i = 0; i < 8; i++) {
    digitalWrite(MOSI_PIN, data & 0x80);
    data <<= 1;
    digitalWrite(CLK_PIN, HIGH);
    delayMicroseconds(1);
    digitalWrite(CLK_PIN, LOW);
    delayMicroseconds(1);
  }
}

void writeEnable() {
  digitalWrite(CS_PIN, LOW);
  sendSPI(WRITE_ENABLE);
  digitalWrite(CS_PIN, HIGH);
}

void setup()
{
  //Serial.begin(115200);
  pinMode(PA7, OUTPUT);
  digitalWrite(PA7, LOW);

  pinMode(CS_PIN, OUTPUT);
  pinMode(CLK_PIN, OUTPUT);
  pinMode(MOSI_PIN, OUTPUT);
  pinMode(MISO_PIN, INPUT);


  //SW
  pinMode(PD3, OUTPUT);
  pinMode(PB5, OUTPUT);
  pinMode(PB1, OUTPUT);
  pinMode(PB0, OUTPUT);
  pinMode(PA6, OUTPUT);
  digitalWrite(PD3, LOW); //VBAT
  digitalWrite(PB5, LOW); //RF_SW
  digitalWrite(PB1, LOW); //IMU
  digitalWrite(PB0, LOW); //MIC
  digitalWrite(PA6, HIGH);  //FLASH

  //Serial.println("Deep sleep timed wakeup");
  writeEnable();
  digitalWrite(CS_PIN, LOW);
  sendSPI(0xB9);
  digitalWrite(CS_PIN, HIGH);
}

void loop()
{
  delay(12000);  
  digitalWrite(PA7, HIGH);
  delay(500);

  //Serial.printf("Going to deep sleep for 10s at %lu\n", millis());
  LowPower.deepSleep(600000);
}

Protecting XIAO MG24 from Bricking When in Deep Sleep

The XIAO MG24 by Seeed Studio is a powerful microcontroller board, but users have encountered issues where the device becomes unresponsive ("bricked") after entering Deep Sleep mode. This guide addresses the root cause, details a recovery process, and provides tips to prevent bricking your XIAO MG24.
When the XIAO MG24 enters Deep Sleep mode (EM4) to save power, it may fail to wake properly, blocking the upload of new sketches. Unlike other XIAO boards, the MG24 lacks a BOOT button or a clearly documented method for entering boot mode, making recovery more complex.
For detailed recovery steps, continue reading below.

1.Use the Escape Pin (PC0)

The XIAO MG24 has a built-in escape mechanism to prevent bricking. If PC0 is pulled LOW during a reset, the device will enter an infinite loop, allowing you to upload a new sketch.
  • Connection: Connect PC0 to GND before resetting the device.
  • Upload: After resetting, upload your sketch while the device is in the loop.

2.Modify Your Sketch

Add the following code to your sketch to detect a user switch. If the switch is pressed, the device will enter an infinite loop, enabling you to upload a new sketch while the device is looping:
 

#define USER_SW  PC3   // Example pin for user switch

void setup() {
  // Other setup code...

  pinMode(USER_SW, INPUT_PULLUP);
  if (digitalRead(USER_SW) == LOW) {
    Serial.println("Enable to upload new sketch");
    while (true) {
      digitalWrite(LED_BUILTIN, LOW);
      delay(50);
      digitalWrite(LED_BUILTIN, HIGH);
      delay(50);
    }
  }
}

3.Avoid Unnecessary Flash Sleep

Make sure your sketch does not put the flash memory into sleep mode (Deep Power Down) unless absolutely necessary. Doing so can prevent issues when uploading new sketches. Keeping the flash memory active ensures a smoother upload process and avoids potential bricking of the device.

Solutions for Serial Port Access and Recovery

Windows Solutions

1.Download the provided ZIP file.

2.Connect the XIAO MG24

Use a USB cable to connect the unresponsive XIAO MG24 to your computer.

3.Run the Script

Open the extracted folder and find the flash_erase.bat script.
Double-click the script to run it. This will erase the flash memory and reset the device.

4.Verify Recovery

After the script completes, the XIAO MG24 should be restored and ready for use.

macOS Solutions

1.Download the provided ZIP file.

2.Connect the XIAO MG24

Use a USB cable to connect the unresponsive XIAO MG24 to your computer.

3.Allow Terminal Access

  • Open System Preferences: Go to System Preferences on your Mac.
  • Navigate to Security & Privacy: Click on Security & Privacy, then go to the Privacy tab.
  • Check Accessibility: Under the Accessibility section, ensure that Terminal is allowed to control your computer.
  • Add Terminal if Necessary: If Terminal is not listed, click the + button to manually add it. Select Terminal from your Applications folder.

4.Run the Script

  • Open Terminal.
  • Navigate to the extracted folder using the cd command. For example:
  • Run the script using ./xiao_mg24_erase.sh.This will erase the flash memory and reset the device.

5.Verify Recovery

After the script completes, the XIAO MG24 should be restored and ready for use.

Note

If macOS does not recognize OpenOCD, please verify that OpenOCD is installed and that the script is using the correct path. Additionally, the scripts provided are tailored specifically for the XIAO MG24 and should not be used with any other XIAO models.

Other information

FAQ

Is there any detailed information or parameters of Seeed Studio XIAO MG24 Sense or Standard?

 

Sidebar

Latest post

This section doesn’t currently include any content. Add content to this section using the sidebar.

Register for our newsletter

Get the latest information about our products and special offers.