Programming the “Blue Pill” with Arduino IDE

Using STM32F103C8T6 “Blue Pill” Development Board with Arduino IDE.

I have recently bought an STM32F103C8T6 “Blue Pill” from Cytron Technologies for around $USD 3.21

Today I will show you how to use the Arduino IDE to program this board.

Please Note:
There is however a problem with many “Blue Pill” boards that the Resistor on the USB d+ line is a wrong value ( 4k7 or 10k where it should be 1k5 or 1k8). This error does not prevent the board from functioning, but it prevents you from uploading code with the Native USB port!

You can, however, use a USB to UART converter to upload code to the board. I have used Cytron’s UC00C, which has a selector switch to select the UART voltage between 5v and 3v3.

USB to UART Connections to the STM32 “Blue Pill”
Connections from UART to STM32 “Blue Pill”

My connections are as follows

UART PIN“Blue Pill” Pin
VCC (Red)5v or 3v, depending on UART Selector switch setting
GND(Blue)Any GND Pin
TxD(Yellow)Pin A10 (RxD)
RxD(Green)Pin A9 (TxD)
Connections from USB to UART Adapter to STM32 “Blue Pill”

Be sure that you dont connect 5v to a 3v3 pin, as you will damage the development board!

Configure the Arduino IDE

Next is to configure the Arduino IDE to allow us to write code and upload it to the STM32

Open the IDE and Click on File -> Preferences

Paste the following url

http://dan.drown.org/stm32duino/package_STM32duino_index.json

into the additional board manager URL list and click on OK

Adding Custom URL to Arduino IDE

Then Click on Tools -> Board: -> Boards Manager

Type STM32 and select STM32F1xx/GD32F1xx by stm32duino

Click on install and when that is done, click on close

Loading additional boards into Arduino IDE

Close and restart the Arduino IDE.

Programming the “Blue Pill”

You are now ready to program the “Blue Pill” board with the Arduino IDE

To test it, Click on File -> Examples -> A_STM32_Examples->Digital->Blink

Please change PB1 to PC13 in the code, as our builtin led is connected to pin 13 on port c ( other boards may be different )

Click on Tools->Board: and select Generic-STM32F103C Series

Click on Tools->Upload Method and Select “Serial”

Change the jumpers on the “Blue Pill” as in the photograph to enable us to upload to system memory.

Note the position of the jumpers. You need to set them this way every time before you upload code with UART. Remember to change them back to original state after uploading code. If you leave them like this, the boad will not automatically run your code at startup!

Plug the usb cable into the usart and computer, the red power light will light up.

Click Tools->Port and select the port of the USB to UART converter.

Now you may click on upload and if you are lucky the led will start flashing once a second, as programmed …

Change back the jumpers to their original position to have the board automatically run your code at startup

On Linux ( Ubuntu 18.04 ) I was not so lucky to have it work immediately, and after some additional reading and testing, found that there is some issue with the CH340 USB UART Chip and Linux CH340 Driver. I have a similar issue with ESP32 Wroom Modules..

The workaround is easy, but a bit of a pain. Press and hold down the reset button on the “Blue Pill”

Click and Hold Upload button in the IDE, Release Reset Button and Then Upload .. All should be well …

I hope this helps someone. Please note that this may not be an issue with Windows, but i wont know as my OS of choice is Linux.

By the way, there is an Arduino bootloader available to enable you to upload software to the “Blue Pill” via the USB port. In my next tutorial, I will show you how to use the Native USB Port

4 thoughts on “Programming the “Blue Pill” with Arduino IDE”

  1. QuintinZahl33611@hotmail.com

    I抳e been exploring for a little for any high quality articles or blog posts on this sort of area . Exploring in Yahoo I ultimately stumbled upon this website. Reading this info So i am glad to show that I have an incredibly good uncanny feeling I came upon exactly what I needed. I most without a doubt will make sure to don抰 omit this web site and provides it a look regularly.

  2. NathanAndren75062@hotmail.com

    Wonderful items from you, man. I’ve consider your stuff previous to and you’re just too excellent. I really like what you have bought right here, really like what you’re stating and the best way wherein you are saying it. You’re making it enjoyable and you continue to care for to stay it sensible. I cant wait to learn much more from you. That is actually a terrific web site.

  3. YerZelinsky19484@hotmail.com

    We’re a bunch of volunteers and opening a new scheme in our community. Your web site provided us with useful info to work on. You’ve done an impressive activity and our whole group will probably be thankful to you.

  4. AdrianNeidenbach76602@hotmail.com

    Very well written story. It will be useful to anybody who utilizes it, as well as myself. Keep doing what you are doing – looking forward to more posts.

Leave a Reply

Your email address will not be published. Required fields are marked *