Arduino Mini Pro+MCP23017 or STM32

I want make device, which reads 17 digital buttons and 4 analog, process it somehow and send the result to I2C bus. Also there is a LED to be managed. I may want to attach some wireless too later, but I am not really sure, if I woud do it (which would need 5-6 mor digital pins). I need to update the firmware often, as it is under heavy developement just now. I should make the PCB as soon as possible, but programming can wait some time.

The PCB would have buttons and analogs on it (and MCP in the arduino case). Also lot of connectors, like I2C, programming interface and some power regulators, the LED (or maybe more of them, if there was few free pins, but it is not mandatory). The processor will be connected via wires for space reasons (and maintainability and the board may be redesined later), so only long row of soldering pads on PCB for it.

Main decision: If I opt to Arduino, then MCP will be part of the PCB and connected to I2C bus, if I use STM32, no MPC will be present and buttons would go directly to output connector.

Making the HW is no problem for me, the logic inside is also easy (basically read all inputs, normalize analogs to some range, make some simple tests and if desired, send result over I2C. Reply to some simple I2C too.)

I have a lot of Arduino Mini Pro, but it is few legs short for the task, so I would use MCP23017 expander for 16 of that digital buttons.

I also got some these STM32 https://www.aliexpress.com/item/STM32F103C8T6-ARM-STM32-Minimum-System-Development-Board-Module-For-Arduino/32279776568.html but did not open the package yet. Anyway I want to learn to use them "sometimes soon".

Maybe it is just the kind of starter project, which I would like to do.

Now I am just not sure about the number of available pins on the STM32, on first look it have more pins, but each description I found yet states too much details about additional functions, but I got confused about the basics here. So my question is:

Can mentioned STM be easilly programed as Arduino, manage I2C communication, and still have comfortable 18+4 I/O pins free? And 23+4 I/O free?

  • Have you heard the word "Multiplex"?
    – Majenko
    Apr 23, 2017 at 16:03
  • like in tronixstuff.com/2011/08/26/… with the mentioned MCP23017 expander? Yes, I did. I am also aware about resistor dividers to read more buttons. But the question goes other way - can STM32 do it without such tricks? If so, I will start learning it today, if not, I will postpone it to next month or two.
    – gilhad
    Apr 23, 2017 at 16:13
  • Nice, but I am not going to use this device, and I want to be able read all combination of buttons. Also I would like to be able to use interrupts to detect change, which is not possible with scanning methods.
    – gilhad
    Apr 23, 2017 at 16:28
  • 2
    @gilhad Why it shouldn't be possible? You can set all columns to zero and enable pin change interrupts on all rows. And when the interrupt is detected, you can start scanning for a while (with pin change interrupts disabled). Or it can be used for waking up from the sleep mode.
    – KIIV
    Apr 23, 2017 at 16:38

1 Answer 1


Can mentioned STM be easilly programed as Arduino, manage I2C communication, and still have comfortable 18+4 I/O pins free? And 23+4 I/O free?

it can be programed as Arduino, manage I2C communication, and still have 18+4 I/O pins free or 23+4 I/O free.

it is only knowable to the person programming it whether it can be done easily or comfortably.

  • I am the person and I need to learn that. In "easily" I mean like in arduino with the usual digitalRead(pin) for pin in 2..13 and A0..A7 and analogRead(pin) for pin in A0..A7 (avoiding A4/A5 for I2C). Just link Wire library, set some callback function like void receiveEvent(int howMany) . Without going to disable reset, repurpose Xtal pins and so on to get more available pins or other black magic. I consider the whole task easy on Arduino Mini Pro with MCP23017. So the question is like would it be on equal "easy" on STM32 ?
    – gilhad
    Apr 23, 2017 at 15:53
  • 1
    Putting aside the additional task of setting up too chains for STM32, yes, the tasks would be equally easy if you have the corresponding libraries.
    – dannyf
    Apr 23, 2017 at 21:09
  • if you don't have the corresponding libraries, the task is not difficult if you reasonably proficient in reading / understanding datasheet and coding to it.
    – dannyf
    Apr 23, 2017 at 21:10
  • I can for example basically write a set of code that runs across the arduino and pretty much any chips I want, by hooking in the appropriate libraries as middleware.
    – dannyf
    Apr 23, 2017 at 21:11
  • Thank you, so it is decided and I wil go with STM32. I will set the compile/upload chains anyway, and I just found Wire library for STM32, so everything should go reasonable well :)
    – gilhad
    Apr 23, 2017 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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