Jump to content

How to program OLED with STM32

RTX 3090

Hi, I am trying to program a 0.91" 32x128 oled using SSD1306 library in Arduino IDE, but when I compile the example sketch for STM32 and upload it, nothing comes on the screen. It did not say where SDA and SCL were so I googled which pins they were and connected it to those. I have the I2C version of the OLED btw

Please tag me @RTX 3090 so I can see your reply

Link to comment
Share on other sites

Link to post
Share on other sites

https://www.buydisplay.com/white-2-2-inch-128x32-i2c-oled-display-module-serial-spi-ssd1305

 

This thing? Or something similar to it? If it's something else, link the datasheet.

 

Show the circuit you built. I'm in the process of making a PCB for (among other things) controlling this OLED, and here's the circuit I've built (with a lot of help from the datasheet and some friends):

Spoiler

Screenshot_20201029_072030.png.16b5f5a8e0fed77e80a5c5c556d8de03.png

Keep in mind you should also have pullup resistors on SCL and SDA (I have them controller-side) and need at least 20ma of available current for the 12v line (preferably 28ma).

Quote me to see my reply!

SPECS:

CPU: Ryzen 7 3700X Motherboard: MSI B450-A Pro Max RAM: 32GB I forget GPU: MSI Vega 56 Storage: 256GB NVMe boot, 512GB Samsung 850 Pro, 1TB WD Blue SSD, 1TB WD Blue HDD PSU: Inwin P85 850w Case: Fractal Design Define C Cooling: Stock for CPU, be quiet! case fans, Morpheus Vega w/ be quiet! Pure Wings 2 for GPU Monitor: 3x Thinkvision P24Q on a Steelcase Eyesite triple monitor stand Mouse: Logitech MX Master 3 Keyboard: Focus FK-9000 (heavily modded) Mousepad: Aliexpress cat special Headphones:  Sennheiser HD598SE and Sony Linkbuds

 

🏳️‍🌈

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Anonymous015 said:

Hi, I am trying to program a 0.91" 32x128 oled using SSD1306 library in Arduino IDE, but when I compile the example sketch for STM32 and upload it, nothing comes on the screen. It did not say where SDA and SCL were so I googled which pins they were and connected it to those. I have the I2C version of the OLED btw

For one, you're not specifying which STM32 MCU you are using: there are hundreds of different STM32 MCUs and they don't all have the same pinout. Secondly, are you sure you are using the right I2C-address? If you are using one of those premade OLED-modules, there's typically solder-pads to choose the address with; writing to the wrong address will obviously not display anything on the display.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

6 hours ago, Anonymous015 said:

Hi, I am trying to program a 0.91" 32x128 oled using SSD1306 library in Arduino IDE, but when I compile the example sketch for STM32 and upload it, nothing comes on the screen. It did not say where SDA and SCL were so I googled which pins they were and connected it to those. I have the I2C version of the OLED btw

A common, frustrating, issue is the i2c address. the back of the OLED should have two hexadecimal digits on either side of a resistor. The resistor can be moved around to change the address (if you want to have two independent screens on the same bus or you have another device with a conflicting address). IIRC, the Adafruit library default address is incorrect for the common SSD1306 we all buy from Aliexpress. Try changing the address in your code to the address on the back of your screen closest to the selection resistor.

 

Also it's possible something is wrong with your code so you should post that too.

ASU

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 months later...
On 10/29/2020 at 4:54 PM, Hackentosher said:

A common, frustrating, issue is the i2c address. the back of the OLED should have two hexadecimal digits on either side of a resistor. The resistor can be moved around to change the address (if you want to have two independent screens on the same bus or you have another device with a conflicting address). IIRC, the Adafruit library default address is incorrect for the common SSD1306 we all buy from Aliexpress. Try changing the address in your code to the address on the back of your screen closest to the selection resistor.

 

Also it's possible something is wrong with your code so you should post that too.

Which code would you recommend me to use (as a base for my project)

Here are pic of the MCU and OLED @WereCatf@kelvinhall05

1610923837892.thumb.jpg.832b1b07e5387aca31b08f68d2574a85.jpg1610923837905.thumb.jpg.97135845c2f6e747a049ce3a7ed0d2ea.jpg

 

IMG-20210117-WA0023.thumb.jpeg.ffc48348dcee82b40e6c3c6dbccf535f.jpeg

Please tag me @RTX 3090 so I can see your reply

Link to comment
Share on other sites

Link to post
Share on other sites

Also just want to double check, which core should I use and which pins should I connect the OLED to

Please tag me @RTX 3090 so I can see your reply

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, RTX 3090 said:

Also just want to double check, which core should I use

Are you talking about Arduino-core for STM32 or what?

5 minutes ago, RTX 3090 said:

and which pins should I connect the OLED to

SCL to SCL and SDA to SDA, obviously. Where they are on the board depends on the board.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, WereCatf said:

Are you talking about Arduino-core for STM32 or what?

Yes, STM32 with arduino IDE (I dont mind using another so long as it isn't too complicated like cube IDE

Please tag me @RTX 3090 so I can see your reply

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, WereCatf said:

SCL to SCL and SDA to SDA, obviously. Where they are on the board depends on the board.

I have been using this diagram from Google. Am wondering if it is correct tho

STM32L433CCT6 - Boring_TECH Black Pill | STM32-base project

 

Please tag me @RTX 3090 so I can see your reply

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, RTX 3090 said:

Yes, STM32 with arduino IDE (I dont mind using another so long as it isn't too complicated like cube IDE

An IDE is an IDE, an Arduino-core is an Arduino-core. They are not the same thing, so I still don't know what you're trying to ask.

 

AFAIK there are only two useable Arduino-cores for STM32, namely Stm32duino and Roger's Clark's Arduino STM32

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, RTX 3090 said:

I have been using this diagram from Google. Am wondering if it is correct tho

No idea. You only posted a picture of the MCU, not the board, so how would I be able to tell? If the board looks identical, then it probably is identical.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, WereCatf said:

An IDE is an IDE, an Arduino-core is an Arduino-core. They are not the same thing, so I still don't know what you're trying to ask.

Which is the thing I should use, stm32duino or roger's core ?

Which is more compatible for my project ?

Please tag me @RTX 3090 so I can see your reply

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, RTX 3090 said:

Which is the thing I should use, stm32duino or roger's core ?

Which is more compatible for my project ?

I'd probably try with Stm32duino first.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, WereCatf said:

An IDE is an IDE, an Arduino-core is an Arduino-core. They are not the same thing, so I still don't know what you're trying to ask.

Which is the thing I should use, stm32duino or roger's core ?

Which is more compatible for my project ?

1610925853071.thumb.jpg.8fea9364c9a9b8993f9c9bd8e3f7c9ea.jpg1610925853080.thumb.jpg.5ecdd197943fa38d85ba426e7e219065.jpg

Please tag me @RTX 3090 so I can see your reply

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, WereCatf said:

I'd probably try with Stm32duino first.

Should I use my FTDI as USB bootloader is not working for some reason or is it better for me to try and fix that first

Please tag me @RTX 3090 so I can see your reply

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, RTX 3090 said:

Should I use my FTDI as USB bootloader is not working for some reason or is it better for me to try and fix that first

Doesn't matter, do whatever you feel is best. Both ways are fine.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

8 minutes ago, RTX 3090 said:

Pictures

That looks to be about the same board as here: https://stm32-base.org/boards/STM32F411CEU6-WeAct-Black-Pill-V2.0.html

This pinout-diagram is probably correct:

Blackpill_Pinout1.thumb.png.024091c753bcb5da5aacc26de8b70447.png

 

The SCL and SDA are probably on PB8 and PB9, but you'll just have to try.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, WereCatf said:

The SCL and SDA are probably on PB8 and PB9, but you'll just have to try.

I just wanna test if my board is working first. Will this line work to test the LED

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(10000);                       // wait for a second
}

 

Please tag me @RTX 3090 so I can see your reply

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, RTX 3090 said:

I just wanna test if my board is working first. Will this line work to test the LED

If LED_BUILTIN points to the correct pin (according to the pinout, the LED is connected to PC13), then sure. If it doesn't, then no. If it doesn't work, try with PC13 instead.

 

That's not an official Arduino-board, it's just a random Chinaman-board and you'll just have to google details or suss things out on your own. I, also, do not have that board.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, WereCatf said:

If LED_BUILTIN points to the correct pin, then sure. If it doesn't, then no. That's not an official Arduino-board, it's just a random Chinaman-board and you'll just have to google details or suss things out on your own. I, also, do not have that board.

Thanks for info. Is this error because I did not do a setup or because I am using the wrong pin as you sugested

image.thumb.png.f1250eb3df9e9c310a4f48e29fbb8ee8.png

Please tag me @RTX 3090 so I can see your reply

Link to comment
Share on other sites

Link to post
Share on other sites

Turns out it was because I did not do a set-up, it is now compiling fine but the LED is not blinking so trying to debug that

Please tag me @RTX 3090 so I can see your reply

Link to comment
Share on other sites

Link to post
Share on other sites

It is now giving this error. Do I have to hold a button or something while uploading the code ? Does boot mode config mean I never pressed the button before plugging it inimage.thumb.png.3d885ca440bd123b164ed8e3b238ecc8.png

Please tag me @RTX 3090 so I can see your reply

Link to comment
Share on other sites

Link to post
Share on other sites

21 minutes ago, RTX 3090 said:

It is now giving this error. Do I have to hold a button or something while uploading the code ? Does boot mode config mean I never pressed the button before plugging it in

Press and hold the boot0 - button down until it has successfully begun the flashing - process. Or, if that doesn't work, press the boot0 - button down and hold it, then press nrst, then release the nrst and then release boot0, after which it should be in flashing-mode.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

9 hours ago, WereCatf said:

Press and hold the boot0 - button down until it has successfully begun the flashing - process. Or, if that doesn't work, press the boot0 - button down and hold it, then press nrst, then release the nrst and then release boot0, after which it should be in flashing-mode.

Hi, thanks, it is flashing perfectly with LED_Builttin now

So should I install the GFX library for Adafruit or is there one made specifically for STM32

Please tag me @RTX 3090 so I can see your reply

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×