Spark Logic

SSD1306 OLED problems

STM32F103C8T6 LQFP48 Pinout

Hi,

Yesterday I installed STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog for Arduino following this Youtube video:

I’m running Arduino 1.8.1 IDE and I’m using OLED_I2C library found on this forum.

Problem is, i wrote a simple TEST code, and code compiles and upload to MCU via ST-LINKST-LINKModules, instruments and finished devices…ot add the serial usb device… suspect flashing failed…. Do I need to debrick it with st-link ? (which I don’t have lol) BennehBoy Mon Jan 23, 2017 8:11 pm NM managed to rescue it…View in hardware catalog v2 interface (MCU is STM32F103C8T6STM32F103C8T6Microcontrollers and processors…e 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 w…View in hardware catalog , standard ebay Blue PillBlue PillDevelopment and computing boards…as become my new favorite board. I am calling it “blue pad” and it is kind of super “ blue pill ”. Pito Thu Jul 27, 2017 8:53 pm [victor_pv – Thu Jul 27, 2017 3:58 pm] – Just for…View in hardware catalog with 20k RAM and 128k ROM).

I tried every I2C output from MCU and nothing… blank screen. Tried example code, nothing, blank screen.
Tried on Arduino UnoArduino UnoDevelopment and computing boards…ime debugging. konczakp Mon Jul 18, 2016 12:18 pm OK, so I took working example from Arduino UNO . I’ve cut off everything from library that I don’t need and from rest I have crea…View in hardware catalog to test OLED, and is working propertly.

Example of my test code:

#include <OLED_I2C.h>
OLED myOLED(SDA,SCL);
void setup() {
}
void loop() {
myOLED.begin();
myOLED.setBrightness(255);
myOLED.print("Hello World",CENTER,0);
myOLED.update();
delay(2000);
}

Replies12

Sat Mar 18, 2017 10:37 am

Double check the SDA SCL pins are set properly. You need pull-ups on those pins too.

Sat Mar 18, 2017 11:47 am

What OLED library is that, it looks to me like it’s bitbanging the i2C, can’t understand why it would need to know the pins otherwise.

If it is bitbanging then it’s probably an implementaion issue.

Perhaps try adafruit’s SSD1306SSD1306Displays, touch panels and LEDs…SPI bus for the tf card from the board anyway. I had one of those 0.96″ oled modules( ssd1306 ) connected to mks sbase v1.3 before I fried the board so I think I’ll try that displ…View in hardware catalog library.

Sat Mar 18, 2017 12:09 pm

Nothing happens, i tried all three I2C and nothing…

Sat Mar 18, 2017 12:17 pm

I found Adafruit STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog I2C example, here is compiler output C:\Program Files (x86)\Arduino\hardware\STM32\STM32F1\libraries\Adafruit_SSD1306\Adafruit_SSD1306_STM32.cpp: In member function 'virtual void Adafruit_SSD1306::drawPixel(int16_t, int16_t, uint16_t)':

C:\Program Files (x86)\Arduino\hardware\STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog \STM32F1STM32F1Microcontrollers and processors…w I am not able to compile. Error message: “C:\arduino-1.6.12\hardware\Arduino_STM32\ STM32F1 \cores\maple/boards.h:39:25: fatal error: board/board.h: No such file or directory” I…View in hardware catalog \libraries\Adafruit_SSD1306SSD1306Displays, touch panels and LEDs…SPI bus for the tf card from the board anyway. I had one of those 0.96″ oled modules( ssd1306 ) connected to mks sbase v1.3 before I fried the board so I think I’ll try that displ…View in hardware catalog \Adafruit_SSD1306SSD1306Displays, touch panels and LEDs…SPI bus for the tf card from the board anyway. I had one of those 0.96″ oled modules( ssd1306 ) connected to mks sbase v1.3 before I fried the board so I think I’ll try that displ…View in hardware catalog _STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog .cpp:115:14: error: 'swap' was not declared in this scope

swap(x, y);

^

C:\Program Files (x86)\Arduino\hardware\STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog \STM32F1STM32F1Microcontrollers and processors…w I am not able to compile. Error message: “C:\arduino-1.6.12\hardware\Arduino_STM32\ STM32F1 \cores\maple/boards.h:39:25: fatal error: board/board.h: No such file or directory” I…View in hardware catalog \libraries\Adafruit_SSD1306SSD1306Displays, touch panels and LEDs…SPI bus for the tf card from the board anyway. I had one of those 0.96″ oled modules( ssd1306 ) connected to mks sbase v1.3 before I fried the board so I think I’ll try that displ…View in hardware catalog \Adafruit_SSD1306SSD1306Displays, touch panels and LEDs…SPI bus for the tf card from the board anyway. I had one of those 0.96″ oled modules( ssd1306 ) connected to mks sbase v1.3 before I fried the board so I think I’ll try that displ…View in hardware catalog _STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog .cpp: In member function 'virtual void Adafruit_SSD1306SSD1306Displays, touch panels and LEDs…SPI bus for the tf card from the board anyway. I had one of those 0.96″ oled modules( ssd1306 ) connected to mks sbase v1.3 before I fried the board so I think I’ll try that displ…View in hardware catalog ::drawFastHLine(int16_t, int16_t, int16_t, uint16_t)':

C:\Program Files (x86)\Arduino\hardware\STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog \STM32F1STM32F1Microcontrollers and processors…w I am not able to compile. Error message: “C:\arduino-1.6.12\hardware\Arduino_STM32\ STM32F1 \cores\maple/boards.h:39:25: fatal error: board/board.h: No such file or directory” I…View in hardware catalog \libraries\Adafruit_SSD1306SSD1306Displays, touch panels and LEDs…SPI bus for the tf card from the board anyway. I had one of those 0.96″ oled modules( ssd1306 ) connected to mks sbase v1.3 before I fried the board so I think I’ll try that displ…View in hardware catalog \Adafruit_SSD1306SSD1306Displays, touch panels and LEDs…SPI bus for the tf card from the board anyway. I had one of those 0.96″ oled modules( ssd1306 ) connected to mks sbase v1.3 before I fried the board so I think I’ll try that displ…View in hardware catalog _STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog .cpp:571:16: error: 'swap' was not declared in this scope

swap(x, y);

^

C:\Program Files (x86)\Arduino\hardware\STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog \STM32F1STM32F1Microcontrollers and processors…w I am not able to compile. Error message: “C:\arduino-1.6.12\hardware\Arduino_STM32\ STM32F1 \cores\maple/boards.h:39:25: fatal error: board/board.h: No such file or directory” I…View in hardware catalog \libraries\Adafruit_SSD1306SSD1306Displays, touch panels and LEDs…SPI bus for the tf card from the board anyway. I had one of those 0.96″ oled modules( ssd1306 ) connected to mks sbase v1.3 before I fried the board so I think I’ll try that displ…View in hardware catalog \Adafruit_SSD1306SSD1306Displays, touch panels and LEDs…SPI bus for the tf card from the board anyway. I had one of those 0.96″ oled modules( ssd1306 ) connected to mks sbase v1.3 before I fried the board so I think I’ll try that displ…View in hardware catalog _STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog .cpp: In member function 'virtual void Adafruit_SSD1306SSD1306Displays, touch panels and LEDs…SPI bus for the tf card from the board anyway. I had one of those 0.96″ oled modules( ssd1306 ) connected to mks sbase v1.3 before I fried the board so I think I’ll try that displ…View in hardware catalog ::drawFastVLine(int16_t, int16_t, int16_t, uint16_t)':

C:\Program Files (x86)\Arduino\hardware\STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog \STM32F1STM32F1Microcontrollers and processors…w I am not able to compile. Error message: “C:\arduino-1.6.12\hardware\Arduino_STM32\ STM32F1 \cores\maple/boards.h:39:25: fatal error: board/board.h: No such file or directory” I…View in hardware catalog \libraries\Adafruit_SSD1306SSD1306Displays, touch panels and LEDs…SPI bus for the tf card from the board anyway. I had one of those 0.96″ oled modules( ssd1306 ) connected to mks sbase v1.3 before I fried the board so I think I’ll try that displ…View in hardware catalog \Adafruit_SSD1306SSD1306Displays, touch panels and LEDs…SPI bus for the tf card from the board anyway. I had one of those 0.96″ oled modules( ssd1306 ) connected to mks sbase v1.3 before I fried the board so I think I’ll try that displ…View in hardware catalog _STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog .cpp:639:16: error: 'swap' was not declared in this scope

swap(x, y);

^

exit status 1
Error compiling for board Generic STM32F103CSTM32F103CMicrocontrollers and processors…doesnt work” mortenholm Fri Jul 24, 2015 10:05 pm Sure. I have selected the ‘Generic STM32F103C series’ and i have tried both the 64k and 128k versions (stm32flash reports 128k).…View in hardware catalog series.

Sat Mar 18, 2017 12:40 pm

Use the stock adafruit library, not the STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog variant in the core.

Sat Mar 18, 2017 5:24 pm

Now its working but update speed is very slow… like every 500 ms, without any delay in code…

Sat Mar 18, 2017 5:54 pm

Can you share your code.

Sat Mar 18, 2017 6:38 pm

It is example code from Adafruit library, the only thing i changed is display address, from 0×3D to 0×3C
/*********************************************************************
This is an example for our Monochrome OLEDs based on SSD1306 drivers

Pick one up today in the adafruit shop!
------> http://www.adafruit.com/category/63_98

This example is for a 128x64 size display using I2C to communicate
3 pins are required to interface (2 I2C and one reset)

Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH  16
static const unsigned char PROGMEM logo16_glcd_bmp[] =

{ B00000000, B11000000,
B00000001, B11000000,
B00000001, B11000000,
B00000011, B11100000,
B11110011, B11100000,
B11111110, B11111000,
B01111110, B11111111,
B00110011, B10011111,
B00011111, B11111100,
B00001101, B01110000,
B00011011, B10100000,
B00111111, B11100000,
B00111111, B11110000,
B01111100, B11110000,
B01110000, B01110000,
B00000000, B00110000 };

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
void setup()   {
Serial.begin(9600);
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
// init done
// Show image buffer on the display hardware.
// Since the buffer is intialized with an Adafruit splashscreen
// internally, this will display the splashscreen.
display.display();
delay(2000);
// Clear the buffer.
display.clearDisplay();
// draw a single pixel
display.drawPixel(10, 10, WHITE);
// Show the display buffer on the hardware.
// NOTE: You _must_ call display after making any drawing commands
// to make them visible on the display hardware!
display.display();
delay(2000);
display.clearDisplay();
// draw many lines
testdrawline();
display.display();
delay(2000);
display.clearDisplay();
// draw rectangles
testdrawrect();
display.display();
delay(2000);
display.clearDisplay();
// draw multiple rectangles
testfillrect();
display.display();
delay(2000);
display.clearDisplay();
// draw mulitple circles
testdrawcircle();
display.display();
delay(2000);
display.clearDisplay();
// draw a white circle, 10 pixel radius
display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
display.display();
delay(2000);
display.clearDisplay();
testdrawroundrect();
delay(2000);
display.clearDisplay();
testfillroundrect();
delay(2000);
display.clearDisplay();
testdrawtriangle();
delay(2000);
display.clearDisplay();
testfilltriangle();
delay(2000);
display.clearDisplay();
// draw the first ~12 characters in the font
testdrawchar();
display.display();
delay(2000);
display.clearDisplay();
// draw scrolling text
testscrolltext();
delay(2000);
display.clearDisplay();
// text display tests
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("Hello, world!");
display.setTextColor(BLACK, WHITE); // 'inverted' text
display.println(3.141592);
display.setTextSize(2);
display.setTextColor(WHITE);
display.print("0x"); display.println(0xDEADBEEF, HEX);
display.display();
delay(2000);
display.clearDisplay();
// miniature bitmap display
display.drawBitmap(30, 16,  logo16_glcd_bmp, 16, 16, 1);
display.display();
delay(1);
// invert the display
display.invertDisplay(true);
delay(1000);
display.invertDisplay(false);
delay(1000);
display.clearDisplay();
// draw a bitmap icon and 'animate' movement
testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
}
void loop() {
}
void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
uint8_t icons[NUMFLAKES][3];
// initialize
for (uint8_t f=0; f< NUMFLAKES; f++) {

icons[f][XPOS] = random(display.width());
icons[f][YPOS] = 0;
icons[f][DELTAY] = random(5) + 1;

Serial.print("x: ");
Serial.print(icons[f][XPOS], DEC);
Serial.print(" y: ");
Serial.print(icons[f][YPOS], DEC);
Serial.print(" dy: ");
Serial.println(icons[f][DELTAY], DEC);
}
while (1) {
// draw each icon
for (uint8_t f=0; f< NUMFLAKES; f++) {
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, WHITE);
}
display.display();
delay(200);
// then erase it + move it
for (uint8_t f=0; f< NUMFLAKES; f++) {
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, BLACK);
// move it
icons[f][YPOS] += icons[f][DELTAY];
// if its gone, reinit
if (icons[f][YPOS] > display.height()) {
icons[f][XPOS] = random(display.width());
icons[f][YPOS] = 0;
icons[f][DELTAY] = random(5) + 1;
}
}
}
}
void testdrawchar(void) {
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
for (uint8_t i=0; i < 168; i++) {
if (i == '\n') continue;
display.write(i);
if ((i > 0) && (i % 21 == 0))
display.println();
}
display.display();
delay(1);
}
void testdrawcircle(void) {
for (int16_t i=0; i<display.height(); i+=2) {
display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
display.display();
delay(1);
}
}
void testfillrect(void) {
uint8_t color = 1;
for (int16_t i=0; i<display.height()/2; i+=3) {
// alternate colors
display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);
display.display();
delay(1);
color++;
}
}
void testdrawtriangle(void) {
for (int16_t i=0; i<min(display.width(),display.height())/2; i+=5) {
display.drawTriangle(display.width()/2, display.height()/2-i,
display.width()/2-i, display.height()/2+i,
display.width()/2+i, display.height()/2+i, WHITE);
display.display();
delay(1);
}
}
void testfilltriangle(void) {
uint8_t color = WHITE;
for (int16_t i=min(display.width(),display.height())/2; i>0; i-=5) {
display.fillTriangle(display.width()/2, display.height()/2-i,
display.width()/2-i, display.height()/2+i,
display.width()/2+i, display.height()/2+i, WHITE);
if (color == WHITE) color = BLACK;
else color = WHITE;
display.display();
delay(1);
}
}
void testdrawroundrect(void) {
for (int16_t i=0; i<display.height()/2-2; i+=2) {
display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, WHITE);
display.display();
delay(1);
}
}
void testfillroundrect(void) {
uint8_t color = WHITE;
for (int16_t i=0; i<display.height()/2-2; i+=2) {
display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color);
if (color == WHITE) color = BLACK;
else color = WHITE;
display.display();
delay(1);
}
}
void testdrawrect(void) {
for (int16_t i=0; i<display.height()/2; i+=2) {
display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
display.display();
delay(1);
}
}
void testdrawline() {
for (int16_t i=0; i<display.width(); i+=4) {
display.drawLine(0, 0, i, display.height()-1, WHITE);
display.display();
delay(1);
}
for (int16_t i=0; i<display.height(); i+=4) {
display.drawLine(0, 0, display.width()-1, i, WHITE);
display.display();
delay(1);
}
delay(250);
display.clearDisplay();
for (int16_t i=0; i<display.width(); i+=4) {
display.drawLine(0, display.height()-1, i, 0, WHITE);
display.display();
delay(1);
}
for (int16_t i=display.height()-1; i>=0; i-=4) {
display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
display.display();
delay(1);
}
delay(250);
display.clearDisplay();
for (int16_t i=display.width()-1; i>=0; i-=4) {
display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
display.display();
delay(1);
}
for (int16_t i=display.height()-1; i>=0; i-=4) {
display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
display.display();
delay(1);
}
delay(250);
display.clearDisplay();
for (int16_t i=0; i<display.height(); i+=4) {
display.drawLine(display.width()-1, 0, 0, i, WHITE);
display.display();
delay(1);
}
for (int16_t i=0; i<display.width(); i+=4) {
display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
display.display();
delay(1);
}
delay(250);
}
void testscrolltext(void) {
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(10,0);
display.clearDisplay();
display.println("scroll");
display.display();
delay(1);
display.startscrollright(0x00, 0x0F);
delay(2000);
display.stopscroll();
delay(1000);
display.startscrollleft(0x00, 0x0F);
delay(2000);
display.stopscroll();
delay(1000);
display.startscrolldiagright(0x00, 0x07);
delay(2000);
display.startscrolldiagleft(0x00, 0x07);
delay(2000);
display.stopscroll();
}

Sat Mar 18, 2017 6:58 pm

Not to point out the obvious, but you realise there are a LOT of 2000 ms delays in this code?

The other thing to keep in mind is that the library is running i2c at 400khz. Every time the lib calls .display it writes a 1KB framebuffer out over that 400khz i2c bus…

SPI will happily operate at 18MHZ… so is just a bit faster.

You’d have to hook up a logic analyser to the i2C and see how saturated the bus is to work out what’s going on.

Sun Mar 19, 2017 5:16 am

I know that there is 2 s delays, i tried same code on uno and its run much faster. Also i tried my simple code, just displaying ADC value, no delays in code, and screen is updated every 300 to 400 ms.

I dont have logic analyzer, just 2 channel dso

Sun Jun 25, 2017 1:57 pm

Hey can u tell me that on which pin did you connect the sda and scl of the oled to STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog .
i tried using the adafruit library example code with my STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog but nothing displayed….

Post a reply

Optional · up to 10 MiB