Introduction: Quick Start to STM Nucleo on Arduino IDE
Nucleo boards are the highly affordable and powerful boards from the ST Microelectronics. STM32 Nucleo boards allow anyone to try out new ideas and to quickly create prototypes with any STM32 MCU.
However, Arduino is unbeatable in this segment due its simplicity and ease of its IDE. The performance to the cost ration of the Arduino boards is very low, which make some hobbyists to look into other boards. STM has bought up the Nucleo development boards, whose performance to the cost ratio is pretty high as compared to that of Arduino.
Thanks to "STM32 Core" (Official) team for porting some of their popular Nucleo boards into Arduino IDE and helping all the Arduino users happy to the core.
Step 1: In the Arduino IDE
Firstly open the Arduino IDE
Go to files and click on the preference in the Arduino IDE
Enter the 'https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/master/STM32/package_stm_index.json' into the "Additional Boards Manager URLs"
Click "Ok" toclose the preference tab.
Step 2: Installing the Package
Now Click on "Tools", click on "Board" a drop-down menu will be popped. Click on "Boards Manager". This opens the Boards Manager, scroll down and navigate to the "STM32 Core" package by ST-Microelectronics and install it.
And that's it, you've done with installing the Nucleo board packages into the Arduino IDE.
Step 3: Pin Mapping
I have remapped the default pin map of Nucleo board to the Arduino IDE such that it would be much convenient to remember the pin notation.
The Header file can be downloaded from my GitHub profile, Click here.
Copy the downloaded folder to the Arduino-Library directory.
Default directory in Windows: 'C:\Program Files (x86)\Arduino\libraries'
Let's look at a basic example.
Step 4: Blink Example
Before going to the coding part, firstly we have to select the Board and the port to which the board has been connected. For this;
Click on "Tools", click on "Board"- a drop-down box appears. scroll down and navigate to Nucleo-X (in my case, it is Nucleo-64) and select it, click on "Tools", click on "Board part number" and select your board (in my case, it is Nucleo F401RE) and again click on "Tools", click on "Port" and select the port on which your Nucleo board is mounted.
Now, let's head towards the coding part;
The source code for the basic blink program;
//Program to blink the onboard LED
#include <f401reMap.h>
int a = pinMap(12); //pinMap(Mapped Pin) - for mapped pin refer the attacted image int b = pinMap(1); void setup() { pinMode(a, OUTPUT); pinMode(b, OUTPUT); }
void loop() { digitalWrite(a, HIGH); digitalWrite(b, HIGH); delay(500); digitalWrite(a, LOW); digitalWrite(b, LOW); delay(500); }
15 Comments
1 year ago
The URL you provide is outdated, when I made this the package had a title like "pls use https://github.com/stm32duino/BoardManagerFiles/ra... so I did that and now it works. It might be nice that you update this.
Question 3 years ago on Introduction
is STM32 nucleo f44re board can operate using arduino IDE?
Question 4 years ago
i have followed the same steps as instructed but i am getting
// exit status 1
Error compiling for board Nucleo-64.//
as an error message please guide me
4 years ago
real nice , its alive !! tks
Question 4 years ago
Hi, I configured Arduino IDE, when compile and upload the sketch on the board it run with success, but when I plug out power and after I pluged in the power the board not execute with success the sketch. Can you help me please?
4 years ago
I have STM32F103RB
Can I use f401reMap.h?
And i dont understand how to use serial monitor. It isn't working(
Reply 4 years ago
It doesn't work in full-fledged condition, rather I suggest you create a header having the map as per your board. That works much efficiently.
Question 5 years ago
Thank you for the clear, complete instructions. I followed them, got the sketch to compile, but I get the error:
Arduino: 1.8.5 (Windows 10), Board: "Nucleo-64, Nucleo F401RE, Mass Storage, Generic Serial, None, Smallest (-Os default)"
Archiving built core (caching) in: C:\Users\bjfur\AppData\Local\Temp\arduino_cache_286105\core\core_STM32_stm32_Nucleo_64_pnum_NUCLEO_F401RE,upload_method_MassStorage,xserial_generic,usb_none,opt_osstd_d724efeaa56f34424fff8f97231228d4.a
Sketch uses 11064 bytes (2%) of program storage space. Maximum is 524288 bytes.
Global variables use 1044 bytes (1%) of dynamic memory, leaving 97260 bytes for local variables. Maximum is 98304 bytes.
NODE_F401RE not found. Please ensure the device is correctly connected.
An error occurred while uploading the sketch
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
So, I notice that in plugging in my Nucleo F401RE, that it pops open a file explorer window with the MBED.HTM file and DETAILS.TXT showing in the window. Might that be the problem? How to get my Nucleo board, so the Arduino IDE will see it?
Answer 4 years ago
If you've followed the step-1 and step-2 correctly, the Arduino is already set ready to identify the Nucleo board. After the Step-2, identify the COM port number assigned by your PC to your Nucleo board. Open the Arduino IDE, head towards "Tools" tab and go to the "port" option and select the assigned COM port and try uploading. I hope this should solve the problem.
Question 5 years ago on Step 4
Actually I am working on STM32L476RG Development Board already I have developed the code on arduino IDE based on arduino uno board now i am facing problem in dumping the code to STM board. Can someone please help me out to solve this problem
Answer 5 years ago
Could you please inbox me regarding the problem? you could write to me at shrihari.hari420@gmail.com
And yeah, if the same header file didn't work on STM32L476RG you could a custom header of your own. if so, let me know I would be happy to help. Thank you.
Question 5 years ago on Step 3
Will this pin mapping header file also work for STM32L476RG nucleo Board
Answer 5 years ago
It should work, but it might not hold good with some pins. However, I haven't tried this header on STM32L476RG.
5 years ago
Thanks for this, awesome!
Reply 5 years ago
@cwalger Thank you