STM32 with Arduino IDE | Schematic & custom PCB | NRF24 radio | Bootloader

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today i'll start working with the stm32 actually the stm32f103c series or the so called bluepill i've already prepared a few projects with this microcontroller for future videos this board is way more powerful than the arduino nano for example having more memory has a 32-bit architecture and it could run up to 72 megahertz or more in this video i will show you how to program this microcontroller using the arduino ide but that process is very easy and there are already a lot of videos about that so that's why i want to try to show you something new such as how to make your own pcbs using this microcontroller just as we have done with the atmega320a for some previous projects so i will show you the basic configuration of this chip what component it needs in order to run and additionally to that i will add an ftdi chip on the board so we could program this board using the usb connector without the need of an external programmer and by the way my board has an usb type-c connector now and on top of that i want to show you how to burn a bootloader to the stm32 and also i want to test if we could use this microcontroller with the nrf24 radio modules because i would really like to make a new version of the radio controller project that could run at much more speed so guys let's get started [Music] video sponsored by pcb way you should try their services for flexible pcbs you could get the rigid flex or the totally flexible pcbs of one up to eight layers you could apply different settings such as the pcb thickness from 0.08 up to above 0.4 millimeters so go to pcbway.com and try one of their services for pcb prototype the flexible pcbs components assembly or the smd stencil and their new services for injection molding printing and cnc milling of 3d parts and laser cutting depending on your project pcb way adapts to your needs so place your order now for prices starting from only five dollars what's up my friends welcome back this is the blue pill board that uses the stm32f103c microcontroller this video will have four parts first i want to show you the specs and how to use this microcontroller with the arduino ide in the second part i want to test this chip and the needed libraries with the nrf24 radio modules for the third part i want to show you how to burn a bootloader to the stm32 so it could be programmed with the usb connector that it has and finally i want to show you my pcb the basic configuration of this chip solder the components and upload the codes directly with the usb connector sounds good then let's start the stm32f103c is a 32-bit architecture microcontroller compared with the arduino uno nano or the mega for example which are 8-bit microcontrollers this chip has 32 bits so it could move 4 times more bits on a single clock pulse so just with that it would be at least four times faster but on top of that it could run by default at 72 megahertz and if you remember the arduino uno nano or the mega are running at just 16 megahertz so that is once again 4.5 times faster you could also overclock the stm32 up to 128 megahertz which is crazy so this is the pin out of this microcontroller and it has 26 io pins with interruptions for all it has 10 analog inputs and the adc is of 12 bits so it will have 4 times more resolution than the atmega 328 for example which only has 10 bits adcs internally it has seven timers two square c ports three uart ports two spi ports and the pwm pins are of 16 bits so 65 000 values so yeah this microcontroller is awesome okay so let's see how to program this microcontroller using the arduino ide platform first you need to get one of these external ftdi programmers mine is from ebay and cost me just two dollars make sure that you switch the jumper from 5 volts to 3.3 volts because the stm32 works at that voltage then we make these connections between the programmer and the stm32 connecting ground to ground 3.3 volts to 3.3 the tx from the programmer to the pin 810 and the rx to the pin a9 and those will be the uart port pins okay so now open the arduino ide copy this link from below and go to preferences and then here in the additional boards you have to paste that link and if you already have a link there just add a comma and then paste the link now you have to go to tools board and select boards manager and wait a few seconds then you have to search for the stm32f1 and install these boards here once you do that if you now go to tools boards you should have the stm32 boards installed so now we can work with the blue pill okay so let's make a simple code from the pinout before we know that we have an led connected to the pin pc13 so in arduino i make a blink code and i set the pc13 as an output and set it to high and low for one second now go to tools board and select the generic stm32f103c board select this variant and for the upload method select serial because we are using the serial ftdi programmer and also select the 72 megahertz speed for the clock but now before you connect the usb cable make sure that you move this jumper from position 0 to 1 and that will put the microcontroller into programming mode then you can connect the usb cable to the fta programmer now go back to the arduino ending tools select the com of that programmer and click upload the leds of the programmer will blink and there you go the led on pc13 is now blinking each second so we have successfully uploaded a code to this chip but now if you reset the pcb at this point the code will be erased as you can see the led is not blinking anymore so if you want to keep the code before you reset the board you have to switch back the jumper for one to a zero and then you can reset the board and the code will run forever as you can see if i now pour off the board when i pour it back on the code is still running you can use the stm32 pretty much the same as the arduino using the serial to print data using the annual grid or digital read to detect values on the digital pins you could set pull ups or pull downs resistors in the code and so on just remember to change the name of the pins according to the pins of the stm32 so till here was the introduction of this microcontroller you have a few examples below in the description on electrolubes.com for pwm write anal grid serial and more basic stuff okay so for the second part i wanted to test these micro controllers with the nrf24 radio library now remember that the nrf24 uses spi communication so if we take a look at the board pinout we can see that we have the default spa port on pins a7 for mossy a6 for miso and a5 for clock and the cs and the csn pins could be any digital pin and those could be declared in the code and in my case i will connect them to pb0 and pa4 so make these connections between the stm32 and the nrf24 module now download this code and open it in arduino ide we change the cs and csn pins from 9 and 10 in case of the arduino to pb0 mpa4 for the stm32 and the rest of the code is the same i read the potentiometer value from the analog input pa00 and we send that value with the nrf24 connection so i upload the code for the transmitter to the stm32 and i'll send the values from this potentiometer and to test and receive the data i will use my nrf24 tester and this will print the receive values on the oled screen and also change the brightness of an led and as you can see i received the values from the potentiometer so the transmitter with the stm32 works good and i think we can get even more speed so i'm working on an stm32 based radio controller which will be awesome so stay tuned you have more about the nrf24 connection with the stm32 on electronics.com and links are below okay so for the third part how about we program the stm32 by using the usb connector that it has and for that we need to burn a bootloader to the chip so for that download these three files from below the arduino stm32 master the flash loader software and the stm32 bootloader master folder unzip the files first we go into the arduino stm32 master folder two drivers win and here run the installdrivers.bat we wait for a few minutes and this will install the drivers so your pc could detect the stm32 as a new com input now you have to make the same connections between the external f3i programmer and dstm32 as before and remember to switch the jumper from 0 to 1. then connect the usb connector to the programmer now go to the flashloader folder and install the software and run it now here select the com of the ftdi programmer and click next click next again and again on this page you have to mark the download to device dot and then press the three dots button and here you have to go to the stm32 bootloader master folder to binaries and select the generic boot 20 pc13 file now press next and the bootloader will be uploaded to the microcontroller and very important once finished before you remove the power you must change the jumper back to zero then just connect the usb cable to dstm32 and it should appear on your pc as maple mini and in the arduino ide you have to change the upload method from serial to stm32duino bootloader and upload the codes without the external programmer and that's it okay guys so for the fourth part finally let me show you the pcb that i've made based on the same microcontroller it has the same pinout all around since this pcb is just for tests and here it also has the spi pins for the nrf24 radio module so i could test the connection okay so first of all this here is the basic configuration of this microcontroller so in order to make it work at least we need these components it will need a pull up on the reset pin it also needs the 8 megahertz crystal and the 32 kilohertz resonator each with two capacitors of 20 picker frets to get the 3.3 volts i've used the ms-1117 regulator and supplied that output to the vdd pins for the boot 1 and boot 2 connections i've placed 6 pins so i could also use the jumpers to make the switch and apart from the basic configuration i've also added the ch 240 uart programmer and this will be connected to the d plus and d minus pins from the usb type-c connector and from this programmer is connected to the rx and tx pins of the uart port so that's how this board could be programmed using the usb connector ok so i gather all the needed components such as resistors capacitors the crystal oscillators the regulators the microcontroller and so on i have the ch240 programmer from an old arduino nano that doesn't work anymore so i solder everything on the pcb i connect the usb cable a new comp appears on my arduino ide and once again using the serial method i upload another code that will make the led blink each 200 milliseconds and remember to place the jumper in the one position so upload the code and there you go the pcb works with no problems so i could use this setup for my future pcbs pretty nice right so guys we have seen the main specs of this microcontroller the pins that it has the ports the speed and so on also how to program it with the arduino ide and how to make your own pcbs with this microcontroller so now i can go and start other projects and one will arrive soon so stay tuned for more details please see the links below in the description for electronics.com for tutorials with photos text and code examples so i hope that you have learned something new and if so give me a like or comment below thanks again and see you later guys hey guys so that was the video for this week i hope that you like it and as always the most important part for me is that you have learned something new and i would like to thank you to all of you who are supporting me on patreon because that for me is huge and by the way if you would like to support my projects you have all my links below for this patreon page for my social media for my shop and so on so thanks again and see you later guys
Info
Channel: Electronoobs
Views: 59,010
Rating: undefined out of 5
Keywords: stm32, STM32F103, blue pill, Arduino IDE, how to program, FTDI, bootloader, USB, NRF24, radio, PCB, schematic, design, controller, starting with
Id: 3crGb1RbknY
Channel Id: undefined
Length: 13min 59sec (839 seconds)
Published: Sun Jun 06 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.