Selecting the right board for my project (work in progress)

Hi there, I am looking for help choosing the right board for my needs. In order to get good answers and not wasting your time, I am writing a bit more about the project further down. Sorry for the long post.

The Situation: Working project, wiring 100 % done, programming 80 % done but memory capacity problem. Asking for help choosing a microcontroller replacement.

The problem: 99% of flash memory used and 50-60% of the RAM when the program starts. But I have not integrated everything I would like to (see below for the actions I have performed to decrease memory usage)

The question: Which is the best board to use that has more RAM and flash but maintains full compatibility with the Arduino code? I came across ESP32, ESP8266, teensy, Arduino MEGA, but I don’t know more than the general pros and cons and also there might be other and better options.

Side note: Hope it is okay to ask for other boards in this forum. Feel free to move the topic if you think it should belong somewhere else...

My priorities:

  • Compatibility with Arduino code
  • No external programmer needed (I know that the MEGA can act as keyboard but you have to use an external programmer afterwards which I do not own and do not wish to buy)
  • Compatibility with the used hardware (see below)
  • Price (this is not crucial, but I don’t want to pay 30 bucks if I can get it for 10)

Size and power needed are no concern.

More about the project:

The idea: “Button box” with 52 buttons, 8 rotary encoders and 8 OLED displays showing dynamic text. Works as keyboard to a computer (pressing a button sends a keystroke)

The hardware:

1 x pro micro with AtMega32U4 5V at 16MHz

8 x 1,3 inch OLEDs with SSh 1106 controller (1,3 Zoll OLED Display I2C SSH1106 Chip 128 x 64 Pixel I2C Anzeigemodul – AZ-Delivery)

4 x MCP23017 IO expander (MCP23017 Serielles Interface Modul kompatibel mit Arduino – AZ-Delivery )

1 x PCA9548A IIC multiplexer (as displays have the same IIC address) (PCA9548A I2C IIC Multiplexer kompatibel mit Arduino – AZ-Delivery )

The libraries:

IoAbstraction (debouncing, rotary encoder functions, dead useful in general) (GitHub - davetcc/IoAbstraction: Rotary encoders, fully debounced switches, EEPROM support on Arduino and mbed - direct and over I2C)

U8G2 library for driving the displays (GitHub - olikraus/u8g2: U8glib library for monochrome displays, version 2 )

And some other more standard arduino libraries

My programming skills in C/C++: Beginner, sometimes intermediate. Yes, it could very well be that someone with better skills would make it happen with the current hardware. But unless I find a silver bullet…

What I have done to reduce memory usage: Used PROGMEM or F-macro where possible, deactivated parts of the used libraries, put parts of the text to display in the python program on the PC to only send relevant data in parts.

... as I said, really long post. Sorry for that!
And thanks for the help!

Tom

If you share your code here (using code tags), someone here might give you some pointers.

How is that possible ? The ATmega32u4 can only use one OLED display (maybe two) with the U8G2 library. What kind of magic do you use to control eight OLED displays ?

The OLED, MCP23017, PCA9548A are all compatible with a 3.3V system and a 3.3V I2C bus.

The IoAbstraction is compatible with the ESP32, but the normal ESP32 has no USB interface and can not act a keyboard.
That leaves the MKR Zero, but the ATSAMD21G boards pops up on this forum with I2C hang problems :dizzy_face:

The OLED displays need the most memory. In what mode do you use the U8G2 library ?

I was very reluctant to copy 1200 lines of (probably) badly written code into a forum and expecting people to understand and improve it. Are you sure that this is a good idea?

That is possible via the PCA9548A, which is a multiplexer. Whatever needs to be sent to the display is basically sent to the IIC adress of the multiplexer which then forwards the data to one of its 8 connected OLEDs. The arduino never "knows" that there is more than one display. Of course, you need to actively control the multiplexer output address.

Like this:

const byte TcaAddress = 0x70; // I2C address of the TCA I2C MUX

void DispSelect(byte Addr) {
  if (Addr > 7) return;
  if (CurrentDispAddr != Addr) {

    Wire.beginTransmission(TcaAddress);
    Wire.write(1 << Addr);
    Wire.endTransmission();
    CurrentDispAddr = Addr;
  }
}

Concerning the U8G2 lib: I am using the picture loop with the smalles buffer size available due to SRAM size. Full frame buffer would already have fill the SRAM of the pro micro...

Are you sure that there are no ESP32 boards with USB interface for uploading the code? I think I saw some of these.

Are you using one buffer and one U8G2 interface for all the OLED displays ? Do you need perhaps extra code to keep them all apart ?

The ESP32-S2 has a USB interface, but I don't see it with the Arduino-supported boards.

I have not seen an example of the Raspberry Pi Pico as a keyboard yet, but some Teensy boards can do that.

It's pretty much the only way to get meaningful help.

A Teensy has far more memory and is much faster too. Apparently it can act as a keyboard as well.

As all the hardware you're using basically relies on I2C, and that is an almost universal standard in the microcontroller world, you should be able to get it working on pretty much any MCU you listed. Same goes for the Arduino compatibility and USB programming - you can get that with any NodeMCU board (aka the ESPs), the Arduino MEGA, the ARM32-based Arduinos, the Teensy ...

Note that some libraries may only work on Arduino AVR boards so "full compatibility" is only possible as long as you stay within that processor family.

Note that buying microcontrollers is a bit difficult at the moment, so you may have to take what you can get... i'd like to get a Teensy 4 myself, but at the moment it seems you can only get them through scalpers.

Well, the point is that your particular attempts to "shrink" the code may not be optimum. For all we know it may (or indeed, may not) be possible to do much more with the hardware you already have.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.