Introduction: Serial I2C HD44780-compatible LCD for ATTINY85

This instructable will show you how to use an LCD and I2C module to display data from an ATTINY85. The intent of the schematic above it to show the connection needed to display data. Note that pull-up resistors are needed for the I2C module.

Step 1: Modify Liquid Crystal Display Library

The following two libraries will need to be installed in your Arduino environment.

1. NewliquidCrystal_1.3.4 written by F Malpartida which can be found at the following link New Liquid Crystal Display Driver
2. TinyWireM

The NewLiquidCrystal library has to be modified to make it work with the ATTINY chips. Modify the following file accordingly.

Find the following file I2CIO.cpp and make the modification below:

Line 33 replace with:

#if (ARDUINO > 100)

Line 34 “#include <../Wire/Wire.h>” replace with

#if defined(__AVR_ATtiny84__) || (__AVR_ATtiny2313__) || defined (__AVR_ATtiny85__)

#include "TinyWireM.h" // include this if ATtiny84 or ATtiny85 or ATtiny2313

#define Wire TinyWireM

#else

#include "Wire.h" // original lib include

#endif

Step 2: Source Code

#include <LiquidCrystal.I2C.h>

#include <usi_twi_master.h>

#include <tinywirem.h>

//

//To wire your Lcd I2C Display to your ATtiny85, connect the following pins :

//

//ATtiny85 Pin1 –> NC

//ATtiny85 Pin2 –> NC

//ATtiny85 Pin3 –> NC

//ATtiny85 Pin4 –> Ground

//ATtiny85 Pin5 –> LCD Sda

//ATtiny85 Pin6 –> NC

//ATtiny85 Pin7 –> LCD Scl

//ATtiny85 Pin8 –> +5V

//

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

void setup()

{

lcd.begin(16, 2);

//3 flash introduction

for (int i = 0; i< 3; i++)

{

lcd.backlight();

delay(150);

lcd.noBacklight();

delay(150);

}

lcd.backlight();

lcd.setCursor(2, 0);

lcd.print("Instructables");

lcd.setCursor(6, 1);

lcd.print("...");

}

void loop()

{

}

Step 3: Notes

I am using the latest (at the time of this writing) arduino core (IDE version 1.6.2).

Please note that I have referenced and modified according the following information:

Use a LCD i2c with attiny84

How to control LCD Display with ATtiny85

I hope this instruction helps as I spent many hours trying to figure out how to get these libraries to work with the ATTINY.

Note update Feb 07, 2016. After upgrading to the newer version of Arduino (1.6.7) if you are using Visual Studio with Visual Micro this code will not work. There appears to be an issue with the #define statements not being passed in. If you get an error do to Wire.h then this was the reason. Hopefully they will fix this issue.

Upate: Feb 09, 2016. The fix for the Visual Micro is to install the latest as of this date.