This is my first post!
First of all I’d like to say thank you for all the people involved in getting STM32 boards to work with the Arduino IDE. I love you all ![]()
Now, to my actual issue.
I have a generic STM board (this one) which I am trying to get this OLED (0,96″) display to work though I2C (using Adafruit_SSD1306 library) but I only managed to get it to work using soft I2C (TwoWire class).
Some information:
- Even though being a software developer I don’t do any embedded work for a living (it is more like a hobby
) - This is the code I’ve changed in Adafruit_SSD1306_STM32.cpp:
//HardWire HWIRE(2, I2C_FAST_MODE); // I2c2
#include <Wire.h>
TwoWire HWIRE(PB6, PB7, SOFT_FAST);
I would initially try just using the TwoWire rather than Hardwire, its a software implementation that works up to 250kbps ( can probably go faster in the future with some code optimisation), and works on any pins.
I think Hardwire works, but only on specific pins and I think it has some quirks.
However I’m not an expert on Wire, so its probably best to wait for some more people to reply.
https://www.hackster.io/rayburne
But I have used both h/w and s/w SPI with the ILI9341
Ray
https://www.hackster.io/rayburne
But I have used both h/w and s/w SPI with the ILI9341
I’m using blue pill board (STM32F103C8T6, version 3). With the current (modified) Adafruit library 0.96″ OLED display works on I2C channel 1 using hardware I2C, but I couldn’t make it to work with channel 2 (which is the default in library). Did someone else had any success with this?
I would use channel 1 (PB6, PB7), but when I do that, RTC DS3231 won’t work, since it tries to use software I2C on the same pins. I tried to remap software I2C to other pins, but it doesn’t work (at least not when using Hardwire for OLED) in my case. I tried to modify Sodaq library for this RTC, it works for several seconds after boot, but then the board hangs.
If OLED would work on second I2C channel, it would be great. If not, I would have to go back to Arduino Pro Micro for my project, and I would like to avoid that, since F103 offers more RAM. But slow software I2C is very unappealing to me.
But I’m not sure if anyone has tried running the Hardware I2C on anything other than I2C – 1.
There may be a bug in the library where its hard coding something to channel 1.
The Hwire lib hangs, since it enters an endless loop. (see my post hier http://www.stm32duino.com/viewtopic.php?f=14&t=462)
The wire lib hangs too, if the SDA pin does not go HIGH. It s because the polling function of the SDA pin has no exit condition, if the SDA does not go high.
Did you find a solution for your problem?

