Skip to content

Contributed by sujingliang, organized by Ai-Thinker

[Ai-WB2 Review] AiXing IoT Platform Practice

Currently, AiXing IoT mainly implements IoT applications using module firmware + MCU SDK.

This article practices this process with an Ai-WB2 module + PICO2.

1. Platform Preparation

AiXing IoT address: https://www.iot-aithings.com/

1. Register a user on AiXing IoT and create a product

You can create a product, or directly use 彩灯_demo; click 彩灯_demo to enter its configuration

2. Hardware development

Select the WB232S module, choose firmware version 1.2.6, and download.

This firmware needs to be flashed into the Ai-WB2; the flashing process is omitted here.

Firmware protocol reference: Serial Port Protocol Documentation

3. MCU SDK download

This MCU SDK needs to be downloaded

I develop with PICO2, so the downloaded SDK needs to be added to the PICO2 project.

4. Triplet

In Production Management: generate a triplet

Send AT commands through a serial port tool to activate the triplet in the module

With the module firmware downloaded and the triplet activated, the Ai-WB2 preparation is complete. The following is mainly about PICO2.

2. PICO2 Software Preparation

The MCU SDK includes:

src files: mcu_api.c; protocol.c; system.c

inc files: config.h; mcu_api.h; protocol.h; system.h

According to the MCU SDK Development Manual, the following need to be implemented:

1. The UartProtocolInit() function needs to be initialized immediately after the MCU starts, so that it can receive and process serial data

Click to expand full code
java
int

main
()
 {

    UartProtocolInit();
//按MCU SDK要求调用初始化

    stdio_init_all();

    uart1_init();
    lcd_init();

    xTaskCreate(led_task,
"LED_Task"
,
256
, NULL,
1
, NULL);
    xTaskCreate(uart_task,
"Uart_Task"
,
256
, NULL,
1
, NULL);
    vTaskStartScheduler();

while
(
1
){};
}

In the main function, initialize UartProtocolInit, and initialize uart1 for communication between PICO2 and Ai-WB2.

2. UartProcessPro() needs to be polled

Click to expand full code
java
void

uart_task
()
 {

while
 (
true
) {
        UartProcessPro();
        vTaskDelay(
100
);
    }
}

3. Call UartRevOneByte() in the uart1 interrupt receive function

Click to expand full code
java
// RX interrupt handler

void

on_uart_rx
()
 {

while
 (uart_is_readable(UART_ID)) {

uint8_t

ch

=
 uart_getc(UART_ID);
        UartRevOneByte(ch);
        putchar(ch);
    }
}

4. Implement the UartWriteData function in protocol.c

Click to expand full code
java
char

UartWriteData
(unsigned
char
 *dataBuff, unsigned
char
 dataLen)

{

//"请将MCU串口发送函数填入该函数,并删除该行"

    uart1_send_string(dataBuff, dataLen);

return

0
;
}

Note that the uart1 send function does not need to send a carriage return / line feed after the string.

Click to expand full code
html
void uart1_send_string(unsigned char *dataBuff, unsigned char dataLen)
{
    uint8_t i;
    for(i=0;i<dataLen;i++)
    {
        uart_putc(UART_ID, dataBuff[i]);
    }
}

5. Implement the light control in protocol.c

Click to expand full code
html
static void ControlPowerstateState(unsigned char *value)
{
    powerstate_status = ProGetdpidValueBool(value);
    if(powerstate_status)
    {
        // 开关开状态
        lcd_set_cursor(0,0);
        lcd_print("light on ");
        gpio_put(25U, 1);
    }
    else
    {
        // 开关关闭状态
        lcd_set_cursor(0,0);
        lcd_print("light off");
        gpio_put(25U, 0);
    }

    UartReportBoolTypeData(CMD_POWERSTATE, powerstate_status);
}

3. Running

Install the AiXing IoT APP on your phone; the pictures below are out of order.

Basically, complete adding the device, and then you can use your phone to control the LED on/off on the PICO2 and the display content of the LCD1602.

Released under the MIT License. Build Time 2026-09-11 14:52:23