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

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

Postby Steven_SS » Mon Dec 17, 2018 5:27 pm

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 71 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: 626
Joined: Wed May 31, 2017 11:57 am
Has thanked: 56 times
Been thanked: 346 times
Contact:

Re: SSD1306_i2c display not working

Postby mnf » Mon Dec 17, 2018 10:19 pm

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&hilit=ssd1306+jan+lichten#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

Postby Steven_SS » Tue Dec 18, 2018 12:13 am

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: 626
Joined: Wed May 31, 2017 11:57 am
Has thanked: 56 times
Been thanked: 346 times
Contact:

Re: SSD1306_i2c display not working

Postby mnf » Tue Dec 18, 2018 9:10 am

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
These users thanked the author mnf for the post (total 3):
Benj (Tue Dec 18, 2018 12:06 pm) • Steven_SS (Tue Dec 18, 2018 10:04 pm) • AbhijitR (Sun Oct 27, 2019 5:11 am)
Rating: 15%
 

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

Postby Steven_SS » Tue Dec 18, 2018 8:14 pm

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: 14671
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4655 times
Been thanked: 4280 times
Contact:

Re: SSD1306_i2c display not working

Postby Benj » Tue Dec 18, 2018 8:45 pm

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/
These users thanked the author Benj for the post:
Steven_SS (Tue Dec 18, 2018 9:49 pm)
Rating: 5%
 

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

Postby Steven_SS » Tue Dec 18, 2018 10:03 pm

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 73 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: 626
Joined: Wed May 31, 2017 11:57 am
Has thanked: 56 times
Been thanked: 346 times
Contact:

Re: SSD1306_i2c display not working

Postby mnf » Tue Dec 18, 2018 10:20 pm

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

Postby Steven_SS » Tue Dec 18, 2018 10:40 pm

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: 626
Joined: Wed May 31, 2017 11:57 am
Has thanked: 56 times
Been thanked: 346 times
Contact:

Re: SSD1306_i2c display not working

Postby mnf » Tue Dec 18, 2018 10:52 pm

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

Postby Steven_SS » Tue Dec 18, 2018 11:23 pm

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: 626
Joined: Wed May 31, 2017 11:57 am
Has thanked: 56 times
Been thanked: 346 times
Contact:

Re: SSD1306_i2c display not working

Postby mnf » Tue Dec 18, 2018 11:35 pm

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

Postby Steven_SS » Tue Dec 18, 2018 11:49 pm

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: 626
Joined: Wed May 31, 2017 11:57 am
Has thanked: 56 times
Been thanked: 346 times
Contact:

Re: SSD1306_i2c display not working

Postby mnf » Wed Dec 19, 2018 12:03 am

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

Postby Steven_SS » Wed Dec 19, 2018 4:52 pm

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

Postby Steven_SS » Wed Dec 19, 2018 7:26 pm

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: 626
Joined: Wed May 31, 2017 11:57 am
Has thanked: 56 times
Been thanked: 346 times
Contact:

Re: SSD1306_i2c display not working

Postby mnf » Wed Dec 19, 2018 8:46 pm

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

Postby Steven_SS » Wed Dec 19, 2018 9:12 pm

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.
These users thanked the author Steven_SS for the post:
Benj (Thu Dec 20, 2018 11:05 am)
Rating: 5%
 
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers :)
Steven

mnf
Valued Contributor
Valued Contributor
Posts: 626
Joined: Wed May 31, 2017 11:57 am
Has thanked: 56 times
Been thanked: 346 times
Contact:

Re: SSD1306_i2c display not working

Postby mnf » Thu Dec 20, 2018 12:10 am

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
These users thanked the author mnf for the post:
Benj (Thu Dec 20, 2018 11:04 am)
Rating: 5%
 

mnf
Valued Contributor
Valued Contributor
Posts: 626
Joined: Wed May 31, 2017 11:57 am
Has thanked: 56 times
Been thanked: 346 times
Contact:

Re: SSD1306_i2c display not working

Postby mnf » Thu Dec 20, 2018 8:43 am

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
These users thanked the author mnf for the post:
Benj (Thu Dec 20, 2018 11:04 am)
Rating: 5%
 

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8609
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2477 times
Been thanked: 3559 times
Contact:

Re: SSD1306_i2c display not working

Postby medelec35 » Thu Dec 20, 2018 9:13 am

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.
These users thanked the author medelec35 for the post:
Benj (Thu Dec 20, 2018 11:05 am)
Rating: 5%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Re: SSD1306_i2c display not working

Postby Benj » Thu Dec 20, 2018 11:06 am

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.
These users thanked the author Benj for the post:
Steven_SS (Thu Dec 20, 2018 4:09 pm)
Rating: 5%
 

mnf
Valued Contributor
Valued Contributor
Posts: 626
Joined: Wed May 31, 2017 11:57 am
Has thanked: 56 times
Been thanked: 346 times
Contact:

Re: SSD1306_i2c display not working

Postby mnf » Thu Dec 20, 2018 2:43 pm

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
These users thanked the author mnf for the post:
Steven_SS (Thu Dec 20, 2018 4:09 pm)
Rating: 5%
 

User avatar
AbhijitR
Posts: 105
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 158 times
Been thanked: 33 times
Contact:

Re: SSD1306_i2c display not working

Postby AbhijitR » Sun Oct 27, 2019 5:18 am

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