Cannot make OLED display to work with hardware I2C in Adafruit_SSD1306 library

vagaus
Sat Aug 01, 2015 5:32 pm
Hi.

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);

RogerClark
Sat Aug 01, 2015 9:48 pm
Welcome

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.


mrburnette
Sun Aug 02, 2015 12:33 am
I have only been using software SPI with my OLED projects
https://www.hackster.io/rayburne
But I have used both h/w and s/w SPI with the ILI9341

Ray


vagaus
Sun Aug 02, 2015 2:09 pm
RogerClark wrote:Welcome

vagaus
Sun Aug 02, 2015 2:21 pm
mrburnette wrote:I have only been using software SPI with my OLED projects
https://www.hackster.io/rayburne
But I have used both h/w and s/w SPI with the ILI9341

marekic
Tue Sep 27, 2016 10:28 pm
I know this is an old topic, but…

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.


RogerClark
Tue Sep 27, 2016 11:29 pm
Software I2C is the default option, so should work on any GPIO pins

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.


marekic
Wed Sep 28, 2016 1:46 am
I’ll look into that. I kinda don’t want to go back to Pro Micro, and want to explore possibilities of this board.

madias
Wed Sep 28, 2016 6:45 am
search for my oled libraries provided in this forum I think they are also in the repo. HW i2c is working on both, but you need to change it in the library file. I’m sure that I made a comment in the cpp or h file

marekic
Sat Oct 01, 2016 7:00 pm
madias wrote:search for my oled libraries provided in this forum I think they are also in the repo. HW i2c is working on both, but you need to change it in the library file. I’m sure that I made a comment in the cpp or h file

fari
Tue Feb 28, 2017 10:04 am
Hi Vagaus!

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?


Leave a Reply

Your email address will not be published. Required fields are marked *