Attiny85 and LCD using I2C

Hi everyone I have been trying to use an 1602 LCD with an Attiny85.
I am using an I2C but I still didn't manage it to work.

Everything that I try, just shows me a blue screen and nothing else...

I have tried all the libraries on the internet and followed dozens of different tutorials online, but nothing seems to work.

Furthermore, all the tutorials online seem quite outdated, so I was hoping that you guys could help me fix this.

My LCD is a regular 1602 lcd and my i2c is an FZ0519 as you can see in picture below.

Any help on how to use my lcd on a Attiny85 would be appreciated.

Regards,
Tiago

What core do you use to program the ATtiny85 with the Arduino-IDE?
I recommend this one: ATTinyCore

I2C functionality can be achieved with the hardware USI ... via the special version of the Wire library included with this core.

Code for those that works on more normal boards should work without modification with my ATTinyCore. I just finished a build using one yesterday, and it's running great.

Show a diagram of how everything is wired. Your breadboard photo indicates at least one 'lonely' connector.

@uxomm I have no idea about what is a "core" :\

6v6gt:
Show a diagram of how everything is wired. Your breadboard photo indicates at least one 'lonely' connector.

Just ignore that "lonely" wire ahaha, it was there but it had no purpose ..
Here it is how I connected things...

Ground and VCC to GRD and VCC pins on attiny85
SDA to PB02 and SCL to PB0.


Thank you all for your answers.

Regards,
Tiago

Where is the 0.1uF ceramic cap between vcc and gnd of the tiny 85 right next to the chip? I often can t even program them without it. It is required for proper operation. I put it across the top on breadboard to minimize lead length

Which core are you using?

Where is your code?

I have just installed the core that uxomm suggested.
I have been using the code and libraries that I was seeing on the tutorials.

Right now I have no code at all.

I will try again with this new core.

Should I use the regular libraries or should I use different ones?

About the capacitors.. I have just read in the instructuons of this new core and in fact they are referring to that.. It is actually the first time I am seeing a reference to capacitors ahaha

Can you please explain where exactly should I put the capacitor?

I am sorry for my newbie questions, but I am not an expert in this kind of things :stuck_out_tongue:

Best regards and once again, thank you very much !

Tiago

So you say I will need capacitors for programming the chip too..
I am using a shield that I made.. it seems to be programming the chip correctly ("Blink" example works fine)

Will I need to add capacitors to this shield as well?

tgalvao:
Here it is how I connected things...

Ground and VCC to GRD and VCC pins on attiny85
SDA to PB02 and SCL to PB0.

As shown in the picture and written:
green wire: ATtiny pin 5 (PB0) to I2C module SCL (most left connector)
yellow wire: ATtiny pin 7 (PB2) to I2C module SDA
you can read the labels of the I2C module if you watch the picture at 100%
This wiring is wrong.

It should be:
PB0 to SDA
PB2 to SCL

Pinout:

  ATtiny 25/45/85
                ------
         Reset |1    8| Vcc
     ADC3, PB3 |2    7| PB2, SCL, ADC1
     ADC2, PB4 |3    6| PB1, MISO, PWM
           GND |4    5| PB0, MOSI, PWM, SDA
                ------

I changed the wiring and it works now !!
So I presume that the problem here was not only the wiring but also the core I was using..

This new core that you suggested is working like a charm.

Despite the fact that now it is working, it seems like my lcd is not getting enough power .. I mean .. even when I increase the i2c built-in potentiometer, the contrast of the letters is very low and you almost can’t read them ... Is it because I am not using the capacitors ??? I would really like to understand this thing about the capacitors ... where should I put the capacitors ??

Thank you guys!!
Tiago

The capacitor was mentioned in #5 by DrAzzy.
It is a decoupling capacitor.
Use a 0.1 µF (100 nF) ceramic cap between Vcc (ATiny85 pin 8 ) and GND (ATtiny85 pin 4) as close as possible to the ATtiny. I often put it "inside" the socket. It is required for proper operation, but many tutorials do not mention it.
Sometimes it works without it pretty well, but in other cases you get "crazy behavior" and it is very hard to find out why. So you should never omit it!

The 100 nF cap is the blue object "inside" the socket:
decoupling_cap.png

Please post your codes so that we can see what deviceAddress (I2C Address) you have entered for your 8574A based IO Extender? The address range is 0x38 - 0x3F.

uxomm:
The capacitor was mentioned in #5 by DrAzzy.
It is a decoupling capacitor.
Use a 0.1 µF (100 nF) ceramic cap between Vcc (ATiny85 pin 8 ) and GND (ATtiny85 pin 4) as close as possible to the ATtiny. I often put it "inside" the socket. It is required for proper operation, but many tutorials do not mention it.
Sometimes it works without it pretty well, but in other cases you get "crazy behavior" and it is very hard to find out why. So you should never omit it!

The 100 nF cap is the blue object "inside" the socket:
decoupling_cap.png

Great! Thank you very much for your help!
Should I put these capacitors both on the shield and in proto board? OR just in the protoboard when there's no connection to arduino?

Can I use .1J63 polyester capacitors? or is it extremely necessary to be ceramic 104 capacitors?

I have put a capacitor in my breadboard and it doesn't make any noticeable difference. In fact, the text keeps showing very very faded... almost like it doesn't have enough power.

here it is the picture of my capacitor in the protoboard..

GolamMostafa:
Please post your codes so that we can see what deviceAddress (I2C Address) you have entered for your 8574A based IO Extender? The address range is 0x38 - 0x3F.

the EXAMPLE code I am using is this one:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7,3, POSITIVE);
 
void setup()
{
 lcd.begin (16,2);
}
 
void loop()
{
  lcd.setBacklight(HIGH);
  lcd.setCursor(0,0);
  lcd.print("Hello World");
  lcd.setCursor(0,1);
  lcd.print("Attiny85 test");
}

I just set up a 16x2 LCD display with an ATiny85.
The I2C board is soldered to the backside of the LCD so you can not see it in the picture.
It works perfectly. :slight_smile:
attiny85_i2c_lcd.png

A few questiones:

  • Does the LCD work with a "normal" Arduino like the UNO?
  • How do you power the setup with ATtiny85 and LCD?
  • What voltage?
  • What library do you use for the LCD?
    There are so many versions of libraries called LiquidCrystal_I2C and not all of them work with ATtiny pretty good.
    I use the one from DFRobot. You can find it here:
    I2C_TWI_LCD1602_Module__SKU__TOY0046_-DFRobot
    Library Download see "Sample code and library".

Or try this one:

The libraries mentioned use a slightly different syntax than yours.

See also this thread: Need help- ATTiny85 + 1602 i2c LCD

tgalvao:
I have tried all the libraries on the internet

At that point, if you're being truthful, it would be safe for you to conclude that it is not possible for you to get it to work.

uxomm:
I just set up a 16x2 LCD display with an ATiny85.
The I2C board is soldered to the backside of the LCD so you can not see it in the picture.
It works perfectly. :slight_smile:
attiny85_i2c_lcd.png

A few questiones:

  • Does the LCD work with a "normal" Arduino like the UNO?
  • How do you power the setup with ATtiny85 and LCD?
  • What voltage?
  • What library do you use for the LCD?
    There are so many versions of libraries called LiquidCrystal_I2C and not all of them work with ATtiny pretty good.
    I use the one from DFRobot. You can find it here:
    I2C_TWI_LCD1602_Module__SKU__TOY0046_-DFRobot
    Library Download see "Sample code and library".

Or try this one:
GitHub - SpenceKonde/LiquidCrystal_I2C_Tiny: Library for the LiquidCrystal LCD display connected to an Arduino board.

The libraries mentioned use a slightly different syntax than yours.

See also this thread: Need help- ATTiny85 + 1602 i2c LCD

Thank you very much for your helpful contribute!
I've managed to solve the problem with the contrast.. It was indeed low voltage... I had one of the sides of my YuRobot power module set to 3.3V instead of 5V ahaha

Now everything is working like a charm!!

Thank you all for you precious help!!!!

You guys rock!

Well done. :slight_smile:
Thanks for the update.