ATtiny85 I2C LCD problem

Hi,
I want to use an I2C 16x2 LCD with ATtiny85 MCU. I have already downloaded ATtiny Core, flashed firmware for 8MHz and everything seems to be working. I am using Arduino Nano (ATmega 328) as an ISP programmer.

Problem is the I2C. I have installed TinyWireM.h library and tried some libraries, which should work with it but nothing worked. Display is just dead. I2C is connected same as with any other MCU I have used (SDA->SDA, SCL->SCL, Vcc->Vcc, GND->GND, no resistors used)

I have also accidentally swapped Vcc and GND on the MCU which started to overheat but after connecting it right it worked again but something might have got burned... I dont really know if this is possible.

Any ideas? Thanks.

Which one?

I'm my opinion the best one is

Definitely try some 4K7 pull-up resistors on SDA & SCL pins.

1 Like

Yes, could be burned. But if you can still upload code at all, that's a hopeful sign.

Yes, exactly this one. I think that here is a problem with I2C and LCD libraries which seems to be pretty hard to find and also most of them are with a bad documentation.

You may parctice te following ATtiny85-I2CLCD Experiment. In this experiment, it is observed that the MCU gets resetted when the voltage at RESET/-pin goes below 2.8V which can be established theoretically by simple circuit analysis.


Figure-1:

Sketch:

#include<Wire.h>
#include<LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define LED 1    //PB1 = MISO pin onboard LED

void setup()
{
  Wire.begin();
  pinMode(LED, OUTPUT);
  analogReference(DEFAULT); //5.0V Vref

  //-------system reset indication-----
  for (int i = 0; i < 3; i++)
  {
    digitalWrite(LED, HIGH);
    delay(200);
    digitalWrite(LED, LOW);
    delay(200);
  }
  lcd.begin();//or lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);  //DPos (0-15), LPos (0-1)
  //----------------------
  Wire.beginTransmission(0x27);
  byte busStatus = Wire.endTransmission();
  if (busStatus != 0)
  {
     	While(true)   //error indication
	{
	   	digitalWrite(LED, HIGH);
    		delay(100);
    		digitalWrite(LED, LOW);
    		delay(100);
	}
  }
  lcd.print("I2CLCD is found!");
  delay(2000);
  lcd.clear();
}

void loop()
{
  lcd.setCursor(0, 0);
  digitalWrite(LED, HIGH);   //debug message to see MCU reset
  delay(1000);
  digitalWrite(LED, LOW);
  delay(1000);
  //------------------
  unsigned int y = analogRead(A0);
  float testVolt = (5.0 / 1023) * y;
  lcd.print(testVolt, 1);
  lcd.print(" V");
}

Seems that adding pull up 4k7 resistors on SDA ans SCL solved the problem! Thank you everybody for help!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.