I want to start an electronic project, and found that an ARM based MCU, like STM32F103C, fits my needs more than AVR like Arduino Uno (mostly because of CPU and RAM.)

I was wondering if I can use any Arduino sensor with my STM32 board?

Looking a list of the sensors related to STM32, they seem much more expensive.


Yes, of course you can use those sensors. The sensors are not Arduino exclusive, just look up the datasheets to the parts and you should have no problem using them.

To make it easier, you can get an STM32 Nucleo board, which has the same header pin configuration as an Arduino for quick and easy prototyping.

  • \$\begingroup\$ Thanx for quick answer. I had in mind STM32F103C8T6 blue pill, because of low pricing and some protoboard for prototyping, but I got your point. So, bottom line is that sensors in the list I mentioned, matches smt32 gpio and can use all of them with stm32? \$\endgroup\$ – Creator May 23 at 10:17
  • \$\begingroup\$ Yes, it'll be fine. As long as you pay attention to where your leads are going. If doing I2C, hook up SDA and SCL on your sensor board to SDA and SCL on your STM32 board. The sensors will work on any microcontroller, the only reason those are sold as 'Arduino sensors' is because they will have a library in the Arduino IDE. This means ready made example code, but it isn't that difficult to translate most of it over to STM32 \$\endgroup\$ – MCG May 23 at 10:29
  • 1
    \$\begingroup\$ Upvoted your answer too, and thanks for your comment, I will add it. \$\endgroup\$ – Michel Keijzers May 23 at 10:35
  • 1
    \$\begingroup\$ @MichelKeijzers no problem! It made sense to add it to your answer rather than mine! \$\endgroup\$ – MCG May 23 at 10:39

As MCG already mentions, you can use in principle any sensor that also can be used by Arduino. The main issue is if you want to use libraries. For the Arduino, there are for almost any sensor a library available, for the STM32 this is much less the case. Writing a library can take quite some time (depending on the complexity of the sensor communication).

The Nucleo board can help if the sensor is placed on a board that can be pushed on top of an Arduino; otherwise you need to use separate wires anyway.

Another way that could be worthwhile checking, is STM32Arduino, which is a project to make some STM32's compatible with Arduino, and can be programmed like an Arduino, but not all libraries are compatible. See also MCG's comment below and check the following helpful starting point for STM32Duino: getting-started-with-stm32-development-board-stm32f103c8.

In most cases, Arduino is the most easiest solution, mostly because of the existence of a large library support, however, the Arduino also has some big advantages: very less SRAM, mostly bigger in size than STM32 boards, no (easy) debugging, very less peripherals.

Another problem with Arduino libraries (and probably STM32 libraries too), is to check if multiple (different) libraries work together; you get into problems when e.g. they use both the same timer.

  • 1
    \$\begingroup\$ I was just about to edit my answer to mention the STM32/Arduino compatibility, but no need now you mention it here! In fact, there is a page on how to set up the exact same board OP is using to the Arduino IDE here:circuitdigest.com/microcontroller-projects/… which may be useful to add to your answer. +1 from me too for the mention of the Arduino compatibility! \$\endgroup\$ – MCG May 23 at 10:31
  • \$\begingroup\$ Thanx, I have already checked links you sent me before. So basically, library repos is small when it comes to SMT32. What about some another MCU sensor libraries, is it better support for ESP32 or NodeMCU (I saw they are both programmable via Arduino IDE and C language)? Or in general, what would be your suggestions guys, in the case that I need ARM based platform (obviously because of performance), which is programmable via Arduino IDE in C/C++ and which support larger library set for sensors? \$\endgroup\$ – Creator May 23 at 11:01
  • \$\begingroup\$ I added some more comments, you also could check Arduino Due, but also there not all Arduino libraries will work ... first make a list of possible models you can use (which meet your performance), than check on which of those platforms your needed libraries will work and make a decision based on those. \$\endgroup\$ – Michel Keijzers May 23 at 13:55

May work for some, but definitely not for all.

Notice that the Arduino operates at 5V supply and I/O voltages, while the STM32 uses 3.3V!

While many of the STM32's I/O pins may be 5V-tolerant for input (see datasheet), they cannot output 5V signals which many Arduino-targeted sensor( board)s are built for.


  • best case: The sensor is ok with 3.3V signals at its inputs and sends 5V signals to 5V-tolerant pins on the µC.

  • good case: The sensor does not work (as expected) because the 3.3V signals are too low, but neither end takes any damage.

  • bad case: The sensor sends a 5V output signal to a non-5V-tolerant µC (input) pin and damages the µC and possibly the sensor by excessive current.

Check and make sure that the sensor's inputs can operate with 3.3V signals, and that the µC's inputs can handle the (likely 5V) signals from the sensor.

Some sensors can operate on a range of supply voltages, e.g. 3.3V~5V, so if you supply them with 3.3V they will work perfectly in a 3.3V system. And there are, of course, sensors which can only operate on 3.3V but not on 5V. For use with 5V Arduinos, these typically have some sort of level-shifting included on the board ("shield") they come mounted on. In these cases, even though the sensor could work on 3.3V, the board cannot.

  • \$\begingroup\$ It looks like voltage should not be a problem at MCU input side, but seems like you are most likely right regarding input voltage for sensors, since most of them operate at ~5V (or they are most reliable at that voltage) \$\endgroup\$ – Creator May 23 at 11:27
  • \$\begingroup\$ cdn1.imggmi.com/uploads/2019/5/23/… \$\endgroup\$ – Creator May 23 at 11:40
  • 1
    \$\begingroup\$ @Creator "It looks like voltage should not be a problem at MCU input side" - How do you get to that conclusion? Depending on the STM MCU some or most I/O pins are 5V-tolerant, but you have to make sure to connect 5V signals only to those pins, or use some sort of level shifter (e.g. a voltage divider). Otherwise, irreversible damage will occur. \$\endgroup\$ – JimmyB May 23 at 13:17
  • \$\begingroup\$ @Creator Notice that we're talking about too low "high" signal levels from MCU to sensor (3.3V instead of 5V expected), but too high "high" signal levels from sensor to MCU (5V instead of maximum permissible 3.3V). \$\endgroup\$ – JimmyB May 23 at 13:24
  • \$\begingroup\$ I understand your voltage concerns. Thanx. anyway, I am going to do some testing after all. \$\endgroup\$ – Creator May 23 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.