Close
0%
0%

WeAct Duino - Cheap and Powerful!

The purpose of this project is to show how to use the WeAct STM32G431 board as an ARM-based Arduino.

Similar projects worth following
Go on, admit it! The perfect Arduino doesn't exist. Most boards from Arduino don't have enough power (Uno, Nano) or are too large and expensive (most of the rest)> Sure, lots of good features and fun to experiment with, but not something to build into projects. There are many fine work-alikes (Teensy4, Feathers, etc.), but still too expensive. At the small end, there's the Xiao from Seeduino, but maybe too small and lacking in resources - and still costs five bucks.
What to do?
How about a 170MHz ARM M4 with 128K flash, 32K of ram, 4 serial ports, 3 I2C ports, 3 SPI ports, 10 ADC channels, 2 DAC channels, and more? Recently released by WeAct Studio and available on AliExpress, the G431 board offers significant power in a small, affordable package - less than three bucks!
My Project Logs below will explain how to make this into a powerful Arduino!
******** Revised March 27, 2025 ************

Complete update on how to get going. (3/25/25) You can read all about the project after this, but this is important!
As a preliminary, install Arduino 2.0 or later for your system. 

First you must install STM32 support to Arduino. Follow the instructions here . Start with "Installing STM32 Cores" and proceed through "Extra step" to install the STM32CubeProgrammer. 

Install the STM32CubeProgrammer following the instructions here. Download the software by scrolling down to Get Software and choose the correct version for your operating system. More information can be found here. To program the WeAct Duino, you will need an St-Link. The one from WeAct works well. You may need to install the ST-Link Driver. If using an ST-Link on a Nucleo board, you may need to update the software. Google should get you to the right areas. 

The final step is to install the files to support the WeAct Duino variant. That process is described in the below, but is included here for simplicity. Find your Arduino Sketchbook location from the Arduino IDE using File > Preferences. The Sketchbook location is the first entry in the window. In that location, create a new directory named "hardware" (without the quotes). Then download WeActDuino.zip from the Files area of this project. Unzip it into the hardware directory you just created. once the files are in place, select the tools menu in Arduino and click Reload Board Data. You should see an entry in the Tools -> Board menu named "WeActDuino Boads (in sketchbook)" with a single entry "weActDuinoG431". The old way to force new Board Data to be read was : "Once the files are in place in the hardware directory, you must close Arduino if it's open, delete ~/.config/arduino-ide, and restart Arduino. Do this anytime the files in the WeActDuino directory are changed. (It's a bug in Arduino.)" This is no longer necessary as of 4/15/25. I leave these old details just in case things don't work as expected, you can try the old method.

OK, now you can read about how we got here. Please note that all the items in tArmDuino that were indicated as "broken" have been fixed and are working well. Further, I'm now running Ubuntu 24.04 and using Arduino 2.3.4.

My first serious work with STM processors as powerful ARM-based Arduinos started with ST32L071 and is documented here. As part of that article, I found a way to integrate a custom board into the Arduino environment and how to use the ST-Link to upload a sketch from the Arduino IDE. Satisfied as I am with that work, I realize that no one is likely to build any of my L071 based Arduinos, even if they can be itsy-bitsy, low power, etc. However, my work may still be very useful!

Let's talk about the WeAct Duino. As discussed in the Description section above, the STM32G431 on the WeAct Mini Core Board offers a lot of power along with many peripherals. WeAct offers this unit at a very affordable price - less than three bucks! (Even in quantity, the G431 chip from Digikey costs more than the cost of the system from WeAct. How can they make it so cheap? Who knows! But we can all benefit!) While the G4xx draws more power than the L0xx, it is an M4 core with floating point hardware, runs over 4 times faster, and has additional resources. The version from WeAct is in a 48 pin package, so more of the resources are accessible. ST Nucleo versions of the G431 are available from Digikey (and others). The 32 pin version costs $12 and the 64 pin version is $16. Both are significantly larger than the WeAct  board, but not any more powerful (same chip).
As a useful bonus, WeAct also offers a clone of the ST-LINK_2.1 programmer. Not only does it cost half what the cheapest ST version costs, it also provides a serial interface. The usual sort of Serial.print() debug can be easily used for program debug; for harder problems, gdb (g-debugger) can be invoked as described here NOTE: As of 3/24/25, the STML071 project is fixed and the explanations and details are updated...

Read more »

WeActDuino.zip

WeActDuino variant definition. Now supports DAPLINK as well as ST-LInk.

Zip Archive - 12.29 kB - 04/15/2025 at 22:26

Download

G431HC_SR04_interrupts.zip

Arduino file for Digital, Analog, and Serial Capabilities Project Log External Interrupt Example. - Using Interrupt.

Zip Archive - 1.54 kB - 04/10/2025 at 18:02

Download

G431HC_SR04_Demo.zip

Arduino file for Digital, Analog, and Serial Capabilities Project Log External Interrupt Example. - Without interrupt.

Zip Archive - 959.00 bytes - 04/10/2025 at 18:00

Download

WeAct_Pin_Map_R1.png

Portable Network Graphics (PNG) - 166.33 kB - 03/27/2025 at 22:10

Preview

WeAct-STM32G431Board.pdf

WeAct Duino Circuit board.

Adobe Portable Document Format - 1.55 MB - 09/04/2023 at 00:15

Preview

View all 6 files

  • Using DAPLINK

    doctek04/15/2025 at 22:43 0 comments

    As of 4/15/2025, I'm using STM 2.10.1 instead of STM 2.8.1. DAPLINK hardware is now supported along with ST-Link. The upload method menu allows choosing either one. OpenOCD can be used for debug also. The idea is to support debugging from the Arduino IDE. OpenOCD is required for that. Unfortunately, debug doesn't quite work for the WeActDuino yet. I'm still working on figuring that out. At least you can use DAPLINK fro uploading!

  • Digital, Analog, and Serial Capabilities

    doctek04/10/2025 at 05:04 0 comments

    The pins of the WeAct Duino are shown in WeAct_Duino_Pin_Map_R1.png, available in the Files section. The physical pin numbers are highlighted in green. Usually, we won't refer to them by physical number. Let's discuss their capabilities.

    Digital Pins: All pins indicated in the WeAct_Duino_Pin_Map_R1.png as digital pins (highlighted in gray) work as expected except D1 and D2. These pins (C14 and C15) are connected as clock oscillator pins for the 32.768KHz crystal for the Real Time Clock module. It is possible to remove the crystal and the two associated capacitors, then install jumpers SB1 and SB2, then D1 and D2 will function as expected. Note D0,D1, and D2 all have very limited output drive and should not be used to drive leds or other moderate current loads. Since it seems that these pins are intended as inputs (pushbutton on D0) or clock drive, I can't really get excited about testing them as digital I/O. I'm more interested in using the Real Time Clock capabilities. (That will be the subject of a Project Log soon.) So just ignore D1 and D2; D0 is the user button. All digital pins can source or sink 20mA except D0,D1, and D2 (C13, C14. C15). Those pins are limited to 3mA. The total current from all I/O pins is 100mA max. 

    Analog Read: All pins A0-A15 (mustard highlight) have analog read capability. The default resolution is 10 bits (0 to 1023) and the input level can be 0 to 3.3V. Using analogReadResolution() allows the resolution to be set to 6,8,10,12,14, or 16 bits (all tested). Note that the setting will apply to all analog input channels. They can't be set individually.

    Analog Write: All digital pins with the letters "pwm" beside them are capable of pwm output. The default frequency is 1KHz and the resolution is 10 bits (0 to 1023). Using analogWriteResolution(),the resolution can be set to 6,8,10,12,14, or 16 bits. With analogWriteFrequency(), the pwm frequency can be set from 1Hz to as high as 400KHz. Using analogWrite() with plns A4 and A5 (digital pins 7 and 8) will use the DAC so a true analog voltage level will be output. The default resolution is 8 bits and analogWriteResolution() may be used to increase the DAC resoution - 12 bits is the maximum regardless of the setting.

    5V tolerance: The pins indicated with a red dot next to the pin number are 5V tolerant. This means that an input signal from a device powered by 5 volts can be use without damaging the WeAct Duino. Configure the pin as an INPUT only, do not use a pull-up or pull-down. Providing a suitable 5V output is less of a problem. A 3.3 volt output is a sufficient 5V high input, so no pull-up is usually required. If one is needed, then use OUTPUT_OPEN_DRAIN and pull up to 5V to control the 5V peripheral. Any digital pin can be used like this. 

    External Interrupts (digital pin interrupts): External interrupts are described here. An Uno has two external interrupts; but the WeAct Duino has one available on every digital pin. There are two restrictions. The first is that only 16 total external interrupts are available. (That's still a lot!) Although any digital pin is a potential external interrupt, the rule is that pins having the same physical pin number in different ports conflict (like A5 and B5). They get mapped to the same EXTI line. Only the last one used by attachInterrupt() will actually cause an interrupt. There is no compiler warning of this behavior. Refer to WeAct_Duino_Pin_Map_R1.png for the physical pin numbers. The only modes supported by attachInterrupt() for the WeAct Duino are RISING, FALLING, or CHANGE, not LOW or HIGH. It is unnecessary to use the digitalPinToInterrupt() function, just the digital pin number is enough for attachInterrupt(), but you must be aware of the physical pin number to avoid possible conflicts.

    Serial I/O: Using the USART (serial) capability of the WeAct Duino is actually pretty easy. All that's required is to instantiate a HardwareSerial object (call it mySerial, for example), and use it as you...

    Read more »

  • Getting Started and Blinky

    doctek09/05/2023 at 01:05 0 comments

    Blinky, of course! But this really explains how to download a program using the ST-Link.

    Connect your ST-Link as follows. If you're using the WeAct ST-Link version of their Mini Debugger, these wire colors apply. Be sure to note that the black wire is NOT ground (as much as we all want it to be). Ground is green! The WeAct ST-Link also supplies 3.3V; no separate supply is needed.

    ST-Link pinWeAct Duino pinwire color
    3v3Vcc (NOT 3.3V)Red
    GndGndGreen
    SWCLKCLKYellow
    SWDIODIOBlack
    NRSTNRSTWhite

    It is important to hook 3.3V from the ST-Link to Vcc, NOT 3.3V.

    Connection of an ST-Link from a Nucleo board is described in tDuino. That description should all still be correct. Note that SWC is the same as SWCLK is the same as CLK.
    Time to navigate the menu items on the Tools Menu!
    Be sure you have selected the weArmDuinoG431 as described above.
    Then for U(S)ART support:, you can choose "Disabled (No serial support)". We'll get to that in the next Project Log.
    Next, Optimize: "Smallest (-Os default)". More details to follow. I haven't played with this much.
    Now, C Runtime Library: "Newlib Nano (default)". Again, I haven't messed with this.
    Finally, Upload method: "STM32CubeProgrammer (SWD)".
    The program we will use will be File -> Examples -> 02 Digital -> BlinkWithoutDelay. No changes are necessary. Verify the sketch. If all goes well, upload. The blue led on the WeAct Duino should be blinking.

    You want to Run stand-alone? Easy! Disconnect the ST-Link and hook up a battery or power supply providing 3.3 to 20 Volts to either Vcc pin - NOT to 3v3. Hook Ground to any ground pin. The led should blink.

View all 3 project logs

Enjoy this project?

Share

Discussions

Rich text editor

Doug wrote 04/13/2025 at 03:36 point

I followed the clear instructions and got my WeAct STM32G431 board running Blink pretty quick. I am now trying to figure out how to use the 4 UART interfaces in ways that I am used to using the single UART of the other Arduino capable boards! Thanks Doktek

  Are you sure? yes | no

Ken Yap wrote 04/10/2025 at 21:30 point

Interesting. I clicked on your link to the WeAct listing for the module and it showed a price of  $1.64, but this jumped to $5.99 after I logged in. Sneaky AliExpress. Still, pretty amazing capability for a few bucks.

  Are you sure? yes | no

doctek wrote 04/10/2025 at 23:16 point

Our Arduino group ordered some two weeks ago for three bucks each. Your price could be thanks to the trade war we're now in. As you observe, still a pretty decent price for the capability!

  Are you sure? yes | no

Ken Yap wrote 04/10/2025 at 23:23 point

After conversion to my currency that's about right. I think they show a cheap price for people who have never registered, or for the sake of search engines.

Later: I opened the WeAct page from one browser where I was signed in, and another where I wasn't. When I clicked buy on the latter, it said that new shoppers get 70% off. Seems to be an AliExpress intro offer. Of course one could register a new account every purchase, if one is that hard up.

  Are you sure? yes | no

trimarco232 wrote 09/30/2023 at 20:44 point

Thanks , some thoughts , imho :

1) I don't now what could be the + of WeAct Duino , as stm32duino supports the chip , and can give support on the forum or on github

2) there is no need for ST-Link , the chip can be natively programmed in DFU mode through USB , and CDC mode can be selected in order to interact with the monitor . Nevertheless ,  one have to push the boot0 and the rst buttons before each upload ; I have connected the boot0-PB8 to 3v3 , so I just have to push the rst button ; it is better to close the monitor before uploading ; yes , one have to install STM32CubeProgrammer before

3) i have got old $3 stlinks , with STM32GC102CB chip : they can be upgraded for G4 , there is a good video how to

4) they are "forbidden" pins :

// PA11 , PA12 : USB , not on the headers
// PA13 , PA14 : SW (ST-Link)
// PG10 : NRST  ;  PB8 : BOOT0
// PC14 , PC15 : OSC32
// PB4, PB6 , PA10, PA9 : USB C : The pull-down effect on the CC lines can be removed by using the bit UCPD1_DBDIS =1 ???  I have to clarify ...

5) it has 5 u(s)arts ; didn't try lpuart ; and yes , much more

6) the reason why the board is cheap is that the chip itself is cheap in china  : 100+ US$1.451 at LCSC ; maybe a commercial effort from ST , in order to fight the clones ; so , not the perfect arduino , but one of the top bests

  Are you sure? yes | no

doctek wrote 09/30/2023 at 23:29 point

Thank you for your interest and comments. Here are my responses to each item.
1) The purpose of WeAct Duino is to integrate both the board and the chip (with its unique pinout) into the Arduino environment. The stm32duino project does not offer this specific support.

2) Perhaps the WeAct board can be configured for programming in this mode, but I don't think it can be done without some effort. The ST-Link supports easy uploading as well as debug (using gdb), plus a uart to usb connection. So no fooling around with buttons to upload.

3) By all means, use what you have if it works. Not everyone has these units sitting around.

4) I'm not sure what STMG431 board you are using, but the WeAct board pins out several of the pins you say are forbidden. Specifically, PA11, PA12, PB8, PB4, PB6, PA9, and PA10 are all pinned out to headers and may be used with full capabilities.

5) You are correct. I have not tried using the LPUART, but I will. Thanks for calling it to my attention.

6) Thank you for explaining this. I don't source many parts directly from China and hadn't tried to find a source for the G431.

  Are you sure? yes | no

trimarco232 wrote 10/04/2023 at 11:22 point

PB4, PB6 , PA10  PA9 works ; jumpers give the possibility for advanced users to develop USB C

but PA13 , PA14 : SW (ST-Link)// PG10 and PB8 : BOOT0 are reserved if you use USB (as an average arduino fan)

  Are you sure? yes | no

doctek wrote 08/29/2023 at 03:54 point

Thanks for the encouragement! Yes, there will be a complete Arduino IDE based toolchain. The CLI is only needed to use gdb for advanced debug - that's not supported by Arduino yet. (Actually, it may be in 2.0, but I haven't tried it yet.)

  Are you sure? yes | no

Ken Yap wrote 08/29/2023 at 06:30 point

I'm sure somebody will work out something for debugging using PlatformIO too.

  Are you sure? yes | no

Ken Yap wrote 08/29/2023 at 03:20 point

This should be interesting, especially if there will be an Arduino IDE based toolchain. But I can handle CLI toolcnains too.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates