BrainPad V2 (STM32F401 RE) I2C display problems with Arduino code

Gus nice video tutorial explained how Arduino sketches can be run on the new BrainPad V2

It turned out to be easy to use the LEDs and the Buttons of the BrainPad in Arduino code.
However there were problems to use the I2C oled display in Arduino code (see discussion on the above thread).
To prevent pollution of this video tutorial thread with to many details I suggest to continue the discussion about the display in this separate thread.

@valon_hoti_gmail_com Yes, the I2C pins should be configured with internal pullups, but I don’t consider this to be the reason as I can see no impulses at all on the I2C lines.

@trent1098s I tried with external 4.7 k resistors, did not help.

1 Like

Well I don’t have either piece of kit so the stronger pull up resistor idea was the full extent of what I can offer this party. :slight_smile:

I found a schematic for the BrainPad V2.

It shows 2.2K on PB6 and PB7

1 Like

That jives with the G30 datasheet and recommendations for the CPU. It’ll work for tons of stuff. Should work for this just fine.

Still always good practice to check the datasheet of the slave devices. Like I mentioned above, I’ve run across certain IC’s that need less impedance. That MCP23017 I mentioned recommends 1k. But that value can also change depending on implementation depending on what devices you have chained together.

Not sure what exactly to do when the datasheets conflict. If one master or slave calls for, say, 2.2k but the other calls for 1k, you split the difference? Use the weaker one? Use the stronger one?

Perhaps someone with more knowledge can give some insight.

using GHIElectronics.TinyCLR.BrainPad;

namespace BrainPadApplication1
class Program
public void BrainPadSetup()
//Start OLED SSD1306
BrainPad.Display.DrawSmallText(0, 0, “Temperature!”);

    public void BrainPadLoop()
        //Turn On Bulb
        //Turn Off Bulb
        //Clear part of early display 
        //BrainPad.Display.ClearPartOfScreen(0, 18, 20,20);
        //Show result of temperature on display 
        BrainPad.Display.DrawText(0, 18, BrainPad.TemperatureSensor.ReadTemperatureInCelsius().ToString().Substring(0,5).ToString()+" C");


by TinyCLR OS (0.6.0) it work well

So just need to call in ARDUINO IDE in same way

i’m going to check/search deep for more behind software side how it was doing by TinyCLR :slight_smile:

Had a deeper look in the code. Seems that the wire library does not use the proper pins.

First check on Arduino IDE I2C pins are PB8 and PB9 (D15,D14) for Nucleo 401 on Brainpad was used PB6 and PB7 so i will try to create Brainpad template based on Nucleo Template but to correspodent pins (that ones used for Braibpad).

You guys can try software i2c.

if we are talking for i2c software i tested pice of code which :

On nucleo work well same code
On arduino work well but
On brainpad do not work (compile is ok) seems need something to trigger before “using I2C” ??

First successes



what you did ,to success it , please can you explain it :slight_smile:

Say more. Don’t tease us.

1 Like

I took parts of the Adafruit_SSD1306 library in a new Arduino sketch and created a new instance of wire with the correct pins and used this instance for the commands.

TwoWire Wire2(pinNametoDigitalPin(PB7), pinNametoDigitalPin(PB6));

for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) {
  // send a bunch of data in one xmission
  for (uint8_t x=0; x<16; x++) {

Now we have to search how it can be achieved that the original wire library takes the correct pins.


O.K., the Adafruit_ssd1306_128x64 library now works perfectly on the BrainPad.

The pin definitions in the file variants.h in the folder:

had to be adpted for the BrainPad to:

//I2C Definitions
##define SDA D22
##define SCL D10

1 Like

Great news.

Just so there is no confusion. There is only one BrainPad. We do not call it v2.

The old large BrainPad called the original, was only a test. What we are selling today is simply the BrainPad.

1 Like

new version STM32Core for Arduino fixed problem with declaration of pins

The pin definitions in the file variants.h in the folder:

C:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\ 2017.8.31 \variants\NUCLEO_F401RE

so just enought is now

//I2C Definitions

define SDA 22
define SCL 10

thanx to @RoSchmi for this tips and worked well brainpad ssd1306 now without problem I can confirm too :slight_smile:


i created a variant board for BRAINPAD from NUCLEO_F401RE variant from version 2017.08.31 and make sure you have this version installed

files and instructions step by step you can find HERE

so we can contribute to Arduino STM32 Core for Brainpad board

(but we are not authorized for this because we need to support it so i published just on my gdrive just for internal usage between us on this forum) and just to say Brainpad is excellent tools that could be used with ARDUINO IDE too for learning.

if we can apply SERIAL _ UPLOAD (without need for DFU as part of ARDUINO IDE) that will be perfect tools for ARDUINO IDE too.

with Arduinos default libraries test

  • Display - tested OK (Ardafruit SSD1306 libraries for I2C)
  • Led - tested OK (simple default test)
  • Bulbs - tested OK (simple default test)

to be tested with Arduinos default libraries

  • Temperature Sensor
  • Servo Motors
  • Buzzer

next step of works to provide all samples for Brainpad for Arduino IDE (similiar to .NET Framework / TinyCLR OS samples just to recreate them for Arduino IDE) if all works with Arduino Default Libraries (and information which libraries to be used)


Great idea ! I think it should also be posted in Gus’ Tech Talk thread.


@Gus_Issa more job for you :smile: about Tech Talk

and/or maybe Arduino STM32 Core publish/support (include could be mBED too)

1 Like

@valon_hoti_gmail_com Hello, did you make any progress loading Arduino code to the Brainpad using a Ftdi-Adapter or ST-Link?