Skip to main content

Getting Started with Seeed Studio XIAO MG24


Getting Started with Seeed Studio XIAO MG24(Sense)

Seeed Studio XIAO MG24Seeed Studio XIAO MG24 Sense

Introduction

Seeed Studio XIAO MG24 is a mini development board based on Silicon Labs' MG24. XIAO MG24 is based on ARM Cortex-M33 core, 32-bit RISC architecture with a maximum clock speed of 78MHz, supporting DSP instructions and FPU floating-point operations, possessing powerful computing power, and built-in AL/ML hardware accelerator MVP, which can efficiently process AI/machine learning algorithms. Secondly, it has excellent RF performance, with a transmission power of up to+19.5 dBm and a reception sensitivity as low as -105.4 dBm. It supports multiple IoT and wireless transmission protocols such as Matter, Thread, Zigbee, Bluetooth LE 5.3,Bluetooth mesh etc.

Specification

ItemSeeed Studio XIAO MG24Seeed Studio XIAO MG24 Sense
ProcessorSilicon Labs EFR32MG24
ARM Cortex-M33 @ 78MHz
WirelessComplete 2.4GHz Wi-Fi subsystem
BLE: Bluetooth 5.3, Bluetooth mesh
Built-in Sensors - 6-Axis IMU(LSM6DS3TR-C)
Analog Microphone(MSM381ACT001)
Memory256kB RAM & 1538KB + 4MB Flash256kB RAM & 1538KB + 4MB Flash
Interface2x UART, 1x IIC, 2x SPI, 18x Analog, 18x Digital, ALL PWM, 1x User LED, 1x Charge LED
1x Reset button,
2x UART, 1x IIC, 2x SPI, 18x Analog, 18x Digital, ALL PWM, 1x User LED, 1x Charge LED
1x Reset button,
Dimensions21 x 17.8mm21 x 17.8mm
PowerInput voltage (Type-C): 5V@14mA
Input voltage (BAT): 3.7V@7mA
Charging battery current: 200mACharging battery current: 200mA
Low Power Consumption ModelNormal: 3.7V/6.71 mA
Sleep Model: 3.7V/1.91mA
Deep Sleep Model: 3.7V/1.95μA
Normal: 3.7V/6.71 mA
Sleep Model: 3.7V/1.91mA
Deep Sleep Model: 3.7V/1.95μA
Working Temperature-20°C ~ 70°C

Features

  • Powerful CPU:ARM Cortex-M33 core, with a maximum clock speed of 78MHz, supporting DSP instructions and FPU floating-point operations, 32-bit RISC architecture.
  • Ultra-Low Power:RX current 4.6mA/TX current 5mA (0dBm), multiple low-power sleep modes
  • Powerful AI:Built in AI/ML hardware accelerator MVP, capable of efficiently processing AI/machine learning algorithms.
  • Multi style wireless transmission:Integrated 2.4GHz multi protocol wireless transceiver, supporting multiple IoT protocols such as Matter, OpenThread, Zigbee, Bluetooth LE 5.3, Bluetooth mesh, etc.
  • Better RF Performance:Excellent RF performance, with a transmission power of up to+19.5 dBm and a reception sensitivity as low as -105.4 dBm (250kbps DSSS)
  • Powerful security:Powerful security features of Secure Vault, including secure boot, encryption, random number generation, tamper proof, secure debugging, etc.
  • Ultra-small size:
  • Rich on-chip resources:Maximum 1536KB Flash and 256KB RAM, with ample storage space.
  • Rich interfaces:Integrated with 12 bit 1Msps ADC, temperature sensor, analog comparator, DCDC and other rich peripherals, and up to 22 Pin, 2 USART, 2 low-power UART, 1 IIC and other interfaces.

Hardware overview

XIAO MG24 Sense indication diagram
XIAO MG24 indication diagram
XIAO MG24/ XIAO MG24(Sense) Pin List
tip

The difference between the two development boards is that MG24 Sense has a microphone sensor and a six axis acceleration sensor, while MG24 does not have one.

  • 5V - This is 5v out from the USB port. You can also use this as a voltage input but you must have some sort of diode (schottky, signal, power) between your external power source and this pin with anode to battery, cathode to 5V pin.
  • 3V3 - This is the regulated output from the onboard regulator.
  • GND - Power/data/signal ground

Getting started

To enable you to get started with the XIAO MG24 faster, please read the hardware and software preparation below to prepare the XIAO.

Factory procedure

We pre-program each new XIAO MG24 and XIAO MG24 Sense with a simple factory program.

  1. XIAO MG24

The factory program preset in the regular version is Blink Light. When you power up the XIAO,the orange user indicator will light up.

  1. XIAO MG24 Sense

The factory program preset in the regular version is The louder you shout, the brighter the light will be.

Hardware Preparation

You need to prepare the following:

tip

Some USB cables can only supply power and cannot transfer data. If you don't have a USB cable or don't know if your USB cable can transmit data, you can check Seeed USB Type-C support USB 3.1.

Software Preparation

The recommended programming tool for the XIAO MG24 is the Arduino IDE, so you need to complete the Arduino installation as part of the software preparation.

tip

If this is your first time using Arduino, we highly recommend you to refer to Getting Started with Arduino.

  • 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

To install the XIAO MG24 board, follow these steps:

https://siliconlabs.github.io/arduino/package_arduinosilabs_index.json 
  1. Add the above board manager URL to the preferences of your Arduino IDE.
  1. Download the XIAO MG24 board package.
tip

If you cannot find it after entering, please reopen the Arduino IDE.

  1. Opt for XIAO_MG24 variant.

Now enjoy coding ✨.

  • Step 1. Launch the Arduino application.

  • Step 2. Navigate to File > Examples > 01.Basics > Blink, open the program.

  • Step 3. Select the board model to XIAO MG24, and select the correct port number to upload the program.

Once the program is successfully uploaded, you will see the following output message and you can observe that the orange LED on the right side of the XIAO MG24 is blinking.

MG24 BLink CodeLED BLink DisPlay

Battery Usage

The XIAO MG24 is capable of using a 3.7V lithium battery as the power supply input. You can refer to the following diagram for the wiring method.

pir
caution

Please be careful not to short-circuit the positive and negative terminals and burn the battery and equipment when soldering.

Instructions on the use of batteries:

  1. Please use qualified batteries that meet the specifications.
  2. XIAO can be connected to your computer device via data cable while using the battery, rest assured that XIAO has a built-in circuit protection chip, which is safe.
  3. The XIAO MG24 will not have any LED on when it is battery powered (unless you have written a specific program), please do not judge whether the XIAO MG24 is working or not by the condition of the LED, please judge it reasonably by your program.
  4. Sorry, we currently have no way to help you check the remaining battery level through software (because there are no more chip pins available), you need to charge the battery regularly or use a multimeter to check the battery level.

At the same time, we designed a red indicator light for battery charging, through the indicator light display to inform the user of the current state of the battery in the charge.

  1. When XIAO MG24 is not connected to the battery, the red light comes on when the Type-C cable is connected and goes off after 30 seconds.
  2. The red light flashes when the battery is connected and the Type-C cable is connected for charging.
  3. When connecting Type-C to charge the battery fully, the red light turns off.

Test voltage

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

pir

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

tip

If you want to set flash to deep sleep, you need to enable 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);
}

Preventing XIAO MG24 from Bricking During Deep Sleep

The XIAO MG24 is a powerful microcontroller board from Seeed Studio, but users have reported issues where the device becomes unresponsive ("bricked") after entering Deep Sleep mode. This tutorial explains the cause of the problem, provides a detailed recovery method, and offers preventive measures to avoid bricking your XIAO MG24.

The XIAO MG24 enters a Deep Sleep mode (EM4) to conserve power, but in some cases, it fails to wake up properly, preventing new sketches from being uploaded. Unlike other XIAO boards, the MG24 does not have a dedicated BOOT button or a documented method to enter boot mode, making recovery challenging.

Preventive Measures

To avoid bricking your XIAO MG24 while using Deep Sleep mode, follow these steps:

  1. Use the Escape Pin (PC0)

The XIAO MG24 has a built-in escape mechanism to prevent bricking. If PC0 is pulled LOW during reset, the device enters an infinite loop, allowing you to upload a new sketch.

  • Connect PC0 to GND before resetting the device.
  • After resetting, upload your sketch while the device is in the loop.
  1. Modify Your Sketch Add the following code to your sketch to detect a user switch and enter an infinite loop if pressed. This allows 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);
}
}
}
  1. Avoid Unnecessary Flash Sleep

Ensure that your sketch does not put the flash memory into sleep mode (Deep Power Down) unless absolutely necessary. This can prevent issues with uploading new sketches.

Acknowledgments

Special thanks to the Seeed Studio community for their valuable contributions and solutions to this issue. The recovery methods and preventive measures discussed in this tutorial were developed based on insights from community members like msfujino and PJ_Glasso.

For more details and discussions, visit the original forum thread:
DeepSleep bricks XIAO_MG24 - Seeed Studio Forum

Unbricking

The XIAO MG24 is currently the only XIAO model equipped with a serial port chip. Unlike other XIAO models, it does not have a BOOT button or a BOOT recovery method. This design oversight can cause issues when the device enters sleep mode or encounters software anomalies, making it impossible to upload a program via the serial port. To address this, we’ve provided a method to wake up the serial port and restore functionality.

Solution for Windows

  1. Download and Extract the Package

  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 locate the script flash_erase.bat.
    • Double-click the script to run it.
    • The script 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.

Solution for macOS

  1. Download and Extract the Package

    • Download the provided ZIP file (link will be added here).
    • Extract the contents to a folder on your computer.
  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 > Security & Privacy > Privacy.
    • Under Accessibility, ensure that Terminal is allowed to control your computer.
    • If Terminal is not listed, click the + button to add it manually.
  4. Run the Script

    • Open Terminal.
    • Navigate to the extracted folder using the cd command. For example:
      cd /path/to/extracted/folder
    • Run the script xiao_mg24_erase.sh using the following command:
      ./xiao_mg24_erase.sh
    • The script will use OpenOCD to 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 fails to recognize OpenOCD, ensure OpenOCD is installed and the correct path is used in the script.
  • The scripts provided are designed specifically for the XIAO MG24 and should not be used with other XIAO models.

Resources

For Seeed Studio XIAO MG24 Sense

For Seeed Studio XIAO MG24

Tech Support & Product Discussion

Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.

Loading Comments...