How do you convert an Arduino project to an equivalent STM32 project? - Page 1
Forum section: electronics / beginners

author: dastructhm
author_rank: Contributor
timestamp: May 10, 2022, 03:27:49 pm
content: Say I have managed to use HDC1080 module with my Arduino uno with someone's GitHub code. Like what this guy did:https://youtu.be/t1vCKlzr2W8But what do I do to make this project more professional using STM32? Please would you let me the steps? thanks!

author: MasterT
author_rank: Frequent Contributor
timestamp: May 10, 2022, 11:00:06 pm
content: You can program stm32 within arduino IDEhttps://github.com/stm32duino/Arduino_Core_STM32#boards-availableCode becomes more "professional" when internal arduino functions "delay", "digitalWrite" etc. replaced by direct registers manipulation, but arduino IDE is supporting whatever style you choose, HAL drivers as well.Only times spend to write your own "functions sets" is may be important.

author: rstofer
author_rank: Super Contributor
timestamp: May 11, 2022, 02:48:43 am
content: Does the project work? Is it satisfactory in every way? If so, drop the UNO board and design your own board around the ATmega 328P and ICSP rather than the Arduino bootloader. If you want real professional, use the SMD version of the ATmega and sand off the part number. All the big kids do it!A lot of manhours went into developing the various Arduino libraries and unless you want to do the work from scratch, probably copying line for line from the Arduino code with just a few changes here and there, you might decide the old ATmega is just fine.There's a 600 MHz Teensy 4.1 from PJRC and, guess what? It not only uses the Arduino IDE, it provides libraries with the same functionality as the original Arduino libraries. Same IDE, same library APIs, same bootloader concept and nobody would dare call a 600 MHz ARM unprofessional. It could be an easy port to move your code to the Teensy!I don't know if there are 'Arduino like' libraries for the STM32s. Probably... But you're back to the same thing, using API calls to libraries you didn't write.Or, you can grab the datasheet and start reading. The modern chips are VERY complex and you will be reading for a long time. Or, you will put the datasheet away and used somebody else's libraries. Kind of like the Arduino.The Arduino and its libraries were created to allow non-CS type folks to work with mechatronics. They have been highly successful.From the above, you might conclude that I don't consider the Arduino (or the ATmega328P) unprofessional. You would be correct. When I want something working right now, I grab an UNO and get started even though I have many other choices. If the Arduino can fill the requirements, I'll use it.BTW, I think the PSOC 6 is a very interesting device! As is the Teensy 4.1. I used an early Teensy to connect knobs and dials to Microsoft Flight Simulator for the simple reason that RawHID USB was already written.

author: rstofer
author_rank: Super Contributor
timestamp: May 11, 2022, 02:57:48 am
content: You could search Google for Arduino libraries for STM32. It has been done:https://www.arduino.cc/reference/en/libraries/stm32duino-examples/

author: Doctorandus_P
author_rank: Super Contributor
timestamp: May 11, 2022, 03:14:29 am
content: I think stm32duino was started by Roger Clarke Melbourne and it was later taken over by ST and they now directly support "arduino".There is no reason whatsoever to think that one microcontroller family is "more professional" then any other family, and almost any uC can read some I2C based sensor chip.If you want your product to look more professional, then design a PCB for it (I like KiCad), and put the uC directly on the PCB instead of using development board (though they are great for prototyping).Also, don't worry to much about your product. Put effort into becoming a professional yourself."arduino" is never meant t be a learning platform, it was / is just a "quick fix" to get people with no programming experience to a state they can do blinking led projects.Especially the java contraption they call an "IDE" is atrocious and only tolerated by people who have never seen a real IDE (or are not capable of working with it).If you want to become a professional, then learn to work with better tools.

author: rstofer
author_rank: Super Contributor
timestamp: May 11, 2022, 03:40:14 pm
content: Many development boards come with headers spaced like the Arduino. I tend to prefer the 'stamp' layout of the mbed LPC1768 which is just a couple of rows of pins.Attached, I just created a daughter card to hold the Magjack, I used the mbed online toolchain and I see they have expanded the concept to include MANY STM32 boards. Approximately 71 of them... BTW, that ethernet connection supports Berkeley Sockets with no pain at all. Just a little Finite State Machine to keep track of the connection status.https://os.mbed.com/platforms/I will almost always go for the 'stamp' form factor unless I specifically want to use an Arduino shield.