SSD1306_i2c display not working

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
Steven_SS
Posts: 46
Joined: Wed Jul 18, 2018 6:33 pm
Has thanked: 18 times
Been thanked: 3 times
Contact:

SSD1306_i2c display not working

Post by Steven_SS »

I've looked thru the forum and yet I still can't manage to figure this out. I cannot get my display to turn on and actually print.
It's a OLED 128 x 64 dot display that has a SSD1306 graphics driver using I2C, targeted with an Atmega 328P.
Can someone help me figure this out please!

I created a sample flowcode project to make it simple to just print out basic words, as well as getting a led to light on/off to make sure the firmware is fine(which it is) and there is power going to the display but nothing occurs on it.
Attachments
Sample.fcfx
(40.06 KiB) Downloaded 274 times
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers :)
Steven

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: SSD1306_i2c display not working

Post by mnf »

Hi Steven,

Your code does work (at least as far as display is concerned): Change the connection to 'hardware' rather than 'software' an the SSD1306 component (and you do have pull-ups on SDA/SCL) If you leave connection as software - change the speed to 100kHz.

I don't think you need the SendCommand(0xAF) in OLED_DisplayStart - and remove the SetBackgroundColour(1) - which just seems to screw up the display (albeit in reverse video).
The positioning and size of your 'Ethanol Pro' text means that the 'Pro' part wraps around to the top of the display too so will need adjusting (when something shows up :) )

Martin
PS - I used Jan's code at viewtopic.php?f=63&t=19871&p=86875&hili ... ten#p86875 to test my hardware was working AOK before trying your code.

Steven_SS
Posts: 46
Joined: Wed Jul 18, 2018 6:33 pm
Has thanked: 18 times
Been thanked: 3 times
Contact:

Re: SSD1306_i2c display not working

Post by Steven_SS »

Hey Martin!
Yeah I didn't think I'd need to send the command as turning on the display should already be in place with the components that flowcode has. I also took out the SetBackgroundColour as you stated. I checked the i2c address and that seems fine as well.
As far as changing the connection, there is software and Channel1. Is "Channel1" what you mean by hardware? I've tried that and still nothing appears on the display :cry:
What could some reasons be for this to be happening?
Thanks a lot.
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers :)
Steven

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: SSD1306_i2c display not working

Post by mnf »

Yes - sorry - channel 1 uses the hardware i2c on the MCU.

A5 (Port C5) to SCL and A4 (C4) to SDA with pullup resistors (4.7k work aok) Note that FC doesn't use the inbuilt pullups - using external pullups is regarded as more reliable.
How are you powering the display? The MCU and display must have a common ground.

Try using 100kHz instead of 400kHz?

Can you get the display working from other code?

Martin

Steven_SS
Posts: 46
Joined: Wed Jul 18, 2018 6:33 pm
Has thanked: 18 times
Been thanked: 3 times
Contact:

Re: SSD1306_i2c display not working

Post by Steven_SS »

mnf wrote: A5 (Port C5) to SCL and A4 (C4) to SDA with pullup resistors (4.7k work aok) Note that FC doesn't use the inbuilt pullups - using external pullups is regarded as more reliable.
How are you powering the display? The MCU and display must have a common ground.

Try using 100kHz instead of 400kHz?

Can you get the display working from other code?
Martin
I have the ports as stated respectively C5 and C4. I'm not sure where to check the pullup resistors?
The MCU and display are both powered by a battery. The voltage levels are fine throughout the unit.
I've now tried both 100kHz and 400kHz. No I haven't gotten the display to work at all but it is a new display so it shouldn't have any problems!
I feel it might have to be something with the addressing but I think I have the right addresses to it, so maybe not...
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers :)
Steven

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SSD1306_i2c display not working

Post by Benj »

Hi Steven.

The pull up resistors can maybe be configured in software depending on your chosen target device.

For the AMEGA328P your looking at something like this C code to enable pullups for C4 and C5.

Code: Select all

DDRC &= ~0b00110000;
PORTC |= 0b00110000;
I'm not sure if they will stay in effect for the software channel. I would try using the hardware channel and adding the C code icon after the I2C initialise component macro. If this fails then try before :D

The alternative is to add two resistors between the scl and sda pins of the micro and the vcc on your slave device probably either 5v or 3v3. Common values for the pull ups are 10K or 4K7.

More info on I2C bus can be found here if you wish to know what the pull up resistors are for.
https://www.matrixtsl.com/blog/simplifi ... c-and-spi/

Steven_SS
Posts: 46
Joined: Wed Jul 18, 2018 6:33 pm
Has thanked: 18 times
Been thanked: 3 times
Contact:

Re: SSD1306_i2c display not working

Post by Steven_SS »

Hey Ben,
Thank you for your help, Martin as well. I've placed a c code block before/after initializing the display yet nothing appears :cry:
I've been leaving it on the hardware channel.
Can you take a glance at it see if you notice anything that I may be missing?
I'm also using Atmel Studio7 to download the program(using the hex file) into the board if that helps any.
Attachments
Sample.fcfx
(40.01 KiB) Downloaded 257 times
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers :)
Steven

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: SSD1306_i2c display not working

Post by mnf »

Hi Steven,

For some reason - in the latest version of sample - the address for the display is set to ' ' (blank) - changing it to 0x78 (which is correct for my display - and was set in your previous upload) got things working again.

Turning on the inbuilt pullups worked too :-) - but see my previous comment about position/sizing of the text..

Only other thought is that your clock speed is set to 6MHz ? Did you mean 16?

Martin

Steven_SS
Posts: 46
Joined: Wed Jul 18, 2018 6:33 pm
Has thanked: 18 times
Been thanked: 3 times
Contact:

Re: SSD1306_i2c display not working

Post by Steven_SS »

That's nice that it's working on yours! haha
Martin, are you using an Atmega 328P or what?

And strange, I had the address set to b0111100 which from the documents I've been looking through is the right display address to write to. I've tried that, as well as the 0x78.
Yes, sorry it's supposed to be 16. Still nothing.
I'll deal with the sizing and positioning once I see something on the display first haha
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers :)
Steven

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: SSD1306_i2c display not working

Post by mnf »

Hi Steven,

Yes - using a 328p here on an Arduino Nano (clone)

The address is 0x3c - which is pre-shifted left one bit in the FC properties (it's been mentioned before - it might be a bit confusing - but that's the way of the components. I would expect to use

Code: Select all

addr << 1
(or

Code: Select all

addr << 1 | 1
for read) but - that's the way of the library and once you get used to it is ok.
I'm also using Atmel Studio7 to download the program(using the hex file) into the board if that helps any.
Can you get anything out of the display using Jan's program mentioned above? Do you have other hardware attached - i2c or other?
If this is a custom 328p 'build' (as opposed to an Arduino base) - can you get other programs working correctly - or display working with an Arduino?? - and, yes, clutching at straws now!

Martin

Steven_SS
Posts: 46
Joined: Wed Jul 18, 2018 6:33 pm
Has thanked: 18 times
Been thanked: 3 times
Contact:

Re: SSD1306_i2c display not working

Post by Steven_SS »

Okay cool.
The 0x03 address is the i2c address or slave address?
I've tried Jan's program changing the target to 328P and nothing still displays...
No sir i don't have any other hardware attached, the SSD1306 graphics driver is the only thing using i2c.
Yes, this is not arduino base, we have something customed identical to it but not arduino.
No I cannot get other programs working correctly with the display.
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers :)
Steven

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: SSD1306_i2c display not working

Post by mnf »

So,

Either something hardware based is wrong, or the upload is failing in some way (to either produce a running program, or a correctly running program)

Could be a duff display (can you test it with an Arduino? (or AVR Studio code rather than FC))

& I'm assuming programs are running correctly on the 328p (blinky or something more complicated working ?)

Is the sample uploaded here what you are testing - or is something more complicated going on (specifically is that interrupt routine enabled in your tests?)

MArtin

Steven_SS
Posts: 46
Joined: Wed Jul 18, 2018 6:33 pm
Has thanked: 18 times
Been thanked: 3 times
Contact:

Re: SSD1306_i2c display not working

Post by Steven_SS »

What kind of display are you using to test it?
Curious if we have the same one, I described it in the first post on this thread.
Programs are running onto the 328p where i have a led test blinking a few times before the printing is supposed to occur, so it looks like the program is being uploaded correctly.
If you mean "duff" as in "bad" then maybe, that's starting to seem like a potential.
Yes this "sample" program is the one i'm currently testing onto the display, nothing else.

Do I need to do anything with RES_LCD or DC_LCD or CS_LCD perhaps?
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers :)
Steven

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: SSD1306_i2c display not working

Post by mnf »

Hoped I was using a similar display.
Oled 128*64, ssd1306 i2c

https://m.banggood.com/0_96-Inch-4Pin-W ... mds=search

Yes, duff as in bad rather than as in beer?

Martin

Steven_SS
Posts: 46
Joined: Wed Jul 18, 2018 6:33 pm
Has thanked: 18 times
Been thanked: 3 times
Contact:

Re: SSD1306_i2c display not working

Post by Steven_SS »

mnf wrote:Hoped I was using a similar display.
Oled 128*64, ssd1306 i2c

https://m.banggood.com/0_96-Inch-4Pin-W ... mds=search

Yes, duff as in bad rather than as in beer?

Martin
That is a very similar display.
So I got a new display today, lets see if it is the display that is "duff".
I'll update ya of course!
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers :)
Steven

Steven_SS
Posts: 46
Joined: Wed Jul 18, 2018 6:33 pm
Has thanked: 18 times
Been thanked: 3 times
Contact:

Re: SSD1306_i2c display not working

Post by Steven_SS »

So I tested it with the new display... still nothing.
Then I took it to the oscilloscope and theres no SDA or SCL going through... Do you have any idea why?
It's set to Port C 4 & 5 respectively as it should. The slave address for the display seems correct.
Maybe it has something to do with the board, not sure still working on it.
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers :)
Steven

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: SSD1306_i2c display not working

Post by mnf »

That could be lots of reasons..
From a faulty MCU to a short. What version of Flowcode are you using too?

Can you try a different 328p??

Martin

Steven_SS
Posts: 46
Joined: Wed Jul 18, 2018 6:33 pm
Has thanked: 18 times
Been thanked: 3 times
Contact:

Re: SSD1306_i2c display not working

Post by Steven_SS »

I toggled the ports of data and clock from 0 and 1 and saw it toggle as expected.
So that means the microprocessor is working and the program is getting through.
That bit shifting you mentioned earlier "0x3c << 1", I tried with my address and nothing.
I'm using FC8...
Turns out it was the part display and there were foreign resistors on the board that was throwing the SCL & SDA off.
Got a display identical to Martin's and works! Thanks for the help again ya'll.
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers :)
Steven

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: SSD1306_i2c display not working

Post by mnf »

Sorry, I'm about out of ideas.

Of you look at any i2c docs then most give address in the form I have, but then transmit as bits 7 to 1 with bit 0 indicating direction.

It could still be a faulty MCU - is possible to 'damage' individual pins (for example by passing too much current - so if possible try with a replacement?

I usually find the hardware side of things hardest to debug, and have certainly been caught out by using a jumper wire with a break in it, and also a breadboard which has a break in the gnd rail (easily fixed with a fixed jumper)

So, good luck - and over to Ben and co for more thoughts...

Martin

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: SSD1306_i2c display not working

Post by mnf »

Three last ideas.

Try powering the display off 5v and gnd pins on the MCU

Try swapping SDA and scl connections.

Try software mode on different pins at 100khz

Martin

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: SSD1306_i2c display not working

Post by medelec35 »

What about the I2C sniffer idea?
At least then it will allow you to determine if it's a hardware or address issue?
Little point in digging into hardware if an address issue and vice versa.
Of course best to determine the reason for no data first?

What is the voltage on the data and clock lines measured with a scope?

Edit:
Read all the posts and it appears you have resolved the issue.
Will leave this for anyone else faced with a similar problem.
Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SSD1306_i2c display not working

Post by Benj »

Got a display identical to Martin's and works! Thanks for the help again ya'll.
Glad it's working well for you now, thanks for letting us know.

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: SSD1306_i2c display not working

Post by mnf »

Turns out it was the part display and there were foreign resistors on the board that was throwing the SCL & SDA off.
Got a display identical to Martin's and works! Thanks for the help again ya'll.
Missed that bit!

Glad to hear it's up and running :)

Martin

User avatar
AbhijitR
Posts: 298
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 279 times
Been thanked: 78 times
Contact:

Re: SSD1306_i2c display not working

Post by AbhijitR »

Hello! Martin
mnf wrote:
A5 (Port C5) to SCL and A4 (C4) to SDA with pullup resistors (4.7k work aok) Note that FC doesn't use the inbuilt pullups - using external pullups is regarded as more reliable.
I was about to loos my patience why the display do not work with hardware option, on contrary with software option every thing works well, finally got the answer.

Thanks a lot, cheers...

Regards
Abhi

Post Reply