attiny85 lcd display made in china
Simple, 7-segment monochrome LCDs have been on every cheap calculator and digital wrist watch for decades, so you"d think they are the easiest component to find for a low-power electronics project... But they are not! In reality, this has probably been the part of where I spent the most time looking for a solution.
There is no shortage of easy-to-use display modules for microntrollers if you"re looking for an OLED display or even a 7-segment LED display. These are fun, but they are definitely not low-power.
And I don"t need to, either: there are ready-made components to drive an LCD. After a great deal of searching I zoomed in on the HT1621, which seems to be the most widely used one for small displays with up to 32 segments. I could get one of these and hook it up with a bare-bones LCD display, except... The HT1621 has a lot of pins, and it comes in an extremely tiny form factor. Just to get started I would need to get a custom PCB manufactured, and I"m pretty convinced I wouldn"t even be able to solder parts this small. I need a breakout board.
I will start by saying that this project was result of many days of trial and error. In general it is easy to connect an I2C adapter to an LCD and drive it with an Attiny85. But this was not the case for me! My I2C adapter was refusing to cooperate with any common library. The screen was either flickering or it was displaying white squares.
At some point it came to me that I had a library that was working for this specific LCD with Arduino as my controller. So I start searching my computer for this code, and managed to make my LCD work with this one. Keep reading for the solution.
I used an arduino nano as programmer and selected “Arduino as ISP” for that reason. Also make sure that all the board setting are the same as in the image bellow. Board: Attiny85, Processor: Attiny85, Clock: Internal 8MHz (it is very important to select internal clock), Port: whatever port arduino is connected to
#include <LCD.h>
lcd.begin (16,2); // <<----- My LCD was 16x2
Using an LCD on a small chip like an attiny85 is not really that hard and till recent I didnt even think it warranted an instructable, but I have received questions about it, so I may as well expand on the process.
With the attiny only having a max of 6 pins available, it goes without saying that it cannot directly control all the pins of the standard Hitachi based LCD"s
A little bit over a year ago, I described how to add an LCD to an Attiny or other chip, using only 2 pins. That circuit made use of an HC164 shift register, but as I2C modules for LCD"s are extremely cheap and even LCD"s with a module already in place also are dirt cheap, one might as well use I2C on the Attiny85.
I2CThe attiny85 can simulate I2C on PB2 (pin 7) (SCL) and PB0 (pin 5) (SDA). The "Wire" library that is used to read and write bytes from and to the I2C port on the arduino doesnt work on the attiny. It needs the TinyWireM library to act as an I2C master
The "NewLCD" library from Francisco Malpartida is my favorite library, but also that one fails in using I2C for the Attiny because it makes a call to the Wire library. A modification to make it work with Attiny85 can be found here.
The "Bro Hogan" library however does work. It is basically the same library as the standard arduino LCD library, but it is modified to recognize the Attiny85 and the Attiny2313 and then makes a call to "TinyWireM" rather than "Wire".
Adafruit also provides a libray that works with the Attiny85 and that is described in another instructable. I will be using the Bro Hogan library here.
Most problems you may encounter are related to the IDE getting confused regarding the libraries. If you are using the standard Arduino LCD library, best replace it by the Bro Hogan library. If you are using Malpartida"s library and want to keep that (as it is a great library), move it out of the way. Grab the entire folder and move it out of your sketchbook/libraries folder. Make sure you have the TinyWireM library installed and make sure your libraries are up to date.
Now obviously there is no bootloader for the attiny85, but the process of burning the bootloader sets the fuses of the attiny from factory mode, to the mode you want to use it in. So, presuming you use the Arduino as ISP,:
Small I2C OLED displays are common nowadays, and thanks to the work of helpful developers, there are also a variety of graphics libraries for using them. Most of them work by using a RAM buffer, which means that anything one wants to draw gets written to a buffer representing the screen, and the contents of that buffer are copied out to the display whenever it is updated. The drawback is that for some microcontrollers, there simply isn’t enough RAM for this approach to work. For example, a 128×64 monochrome OLED requires a 1024 byte buffer, but that’s bad news if a microcontroller has only 512 bytes of RAM in total like the ATtiny85. [David Johnson-Davies] has two solutions: a Tiny Graphics Library that needs no RAM buffer and an even slimmer Tiny Function Plotter, which we’ll discuss in order.
[David]’s Tiny Graphics Library works by taking advantage of a feature of SH1106 driver-based displays: the ability to read the display over I2C as well as write to it. With the ability to perform read-modify-write on a section at a time, using a large RAM buffer can be avoided. The only catch is that the library only works with OLEDs using the SH1106, but the good news is that these are very common at the usual Chinese resellers. ([David] notes that SH1106 is sometimes misspelled as “SSH1106”, so keep that in mind when searching.)
What about all those other SSD1306-based OLED displays out there? Are they out of luck? Not quite. [David] has one more trick up his sleeve: his Tiny Function Plotter works on the SSD1306 and also requires no RAM buffer. It’s unable to write text, but it can easily handle drawing graphs plotting things like values over time while needing very little overhead.
You can basically develop on Mega, Uno, etc, and simply select ATtiny85 and compile-and-burn with more libraries than in any other Arduino package. SPI, TWI, 1-Wire etc are all support. LCD support is an abstract class that is implemented for HD44780, PCD8544, ST7565. The HD44780 driver also has an adapter layer for 4-bit parallel, Shift Register 3-wire (Pin or SPI), Shift Register 4-wire and a whole range of different I2C adapters. You can see how the configuration works in the CosaLCDsize sketch above.
The basic idea of my home automation system is to create wireless sensor nodes that send data wirelessly to a central server. The sensors’ data will be gathered at central server, processed, stored in database and will be presented to users via LCD display, HDMI display and website.
Sensors (like reed sensor and temperature sensor) will be connected to Attiny85 and Attiny85 will read data from the sensor and send the data to the server via radio transmitter module using radio wave. These components will form a sensor node.
Raspberry Pi (the central server) will connect to another Attiny85 which will then connect to a radio receiver module. Raspberry Pi will receive data from sensor nodes and the data will then be processed and stored in database.
The picture below shows the Raspberry Pi output text to the LCD display and at the same time receive data from Attiny85. It takes the whole day to program the LCD driver in Java (ported from Arduino’s LiquidDisplay driver and interface with Pi4J’s I2C library) as there is no existing driver available on the Internet.
One of the major obstacle in writing the drive is that the China’s version of LCD 1602 wires the data cable in the reverse position and it took some time to discover this! Great that it is now working correctly!
It supports processors with limited RAM by avoiding the need for a display buffer, and works with I2C OLED displays based on the SH1106 driver chip. These are available for a few dollars from a number of Chinese suppliers.
To demonstrate the graphics library I"ve written a simple application to measure the temperature every 15 minutes over a 24-hour period and display it as a live chart.
Note that this project will not work with I2C OLED displays based on the SSD1306 driver chip. For an example of plotting on these displays see my article Tiny Function Plotter.
The monochrome OLED graphics displays are accessed a byte at a time, and each byte represents 8 pixels; to plot a point you need to change just one pixel leaving the others unaffected, so you need to know what the previous contents of the byte were.
The usual way to implement graphics commands on this type of display is to use a RAM buffer, and do all the drawing into the buffer. You then copy the entire buffer to the display when you want to update the display. This is the approach taken by Adafruit in their SSD1306 library ATtiny85 Graphics Display.
The OLED displays available from Chinese suppliers tend to be based on the SH1106 driver chip rather than the SSD1306 used in the displays sold by Adafruit. While browsing the SH1106 datasheet
Displays are also available from AliExpress and eBay, in the sizes 0.96" and 1.3" (screen diagonal), and in white, blue, or yellow/blue. Note that they are sometimes mislabelled "SSH1106".
Note that this library will only work with I2C displays, which have four pins. It will not work with SPI displays, or with displays based on the SSD1306 or SSD1309 driver chips, as none of these support reading back the display memory. If you want to plot data on an SSD1306-based display try my other project Tiny Function Plotter.
I developed and tested this library by first writing it in uLisp, my small Lisp interpreter for the Arduino, which enabled me to test parts of the library interactively simply by typing them into the Serial Monitor; see Graphics display interface in Lisp. At one stage I was a bit stumped because I wasn"t getting the correct data read back from the display. I eventually found a note hidden in the datasheet saying that you have to do a dummy read before reading the actual data, and when I did that it all worked.
The display is divided into eight 8-pixel high bands, referred to as pages, and a byte corresponds to a vertical column of 8 pixels, with the bits ordered as shown in the following diagram:
The PlotPoint() routine plots a point at the specified coordinates. It reads a byte from display memory, sets a bit in the appropriate position, and then writes it back again:
The first three commands set the bottom and top nibbles of the column number, and the page number. The SH1106 supports displays up to 132x64, so for the 128x64 display we"re using you have to add an offset of 2 to the x value.
To allow you to plot a character to an abritrary vertical pixel position the routine plots the bottom half of the character in one page, and the top half in the next page, both shifted by the appropriate amount. The routine uses ReverseByte() to reverse the order of the bits in the CharMap array to correspond to the order on the display.
Here"s a simple program that demonstrates all these commands. It measures the temperature every 15 minutes and plots it on the display to an accuracy of 0.5°C.
I compiled the demo program using Spence Konde"s ATTiny Core ATtiny25/45/85 option under the ATtinyCore heading on the Board menu. Then choose Timer 1 Clock: CPU, B.O.D. Disabled, ATtiny85, 8 MHz (internal) from the subsequent menus. Choose Burn Bootloader to set the fuses appropriately. Then upload the program using ISP (in-system programming); I used Sparkfun"s Tiny AVR Programmer Board; see ATtiny-Based Beginner"s Kit.
These routines could be made a bit more efficient by eliminating unnecessary reads from and writes to the display. For example, when drawing a vertical line the current version of Point() reads and writes each display byte eight times, whereas it could check for this case and only read and write each byte once.
For efficiency these routines don"t do any checking that you are drawing within the display area, and drawing outside this area can cause unpredictable effects. It would be fairly simple to add checking to the routines.
This is a weather station based on an ATtiny85 and a Bosch BME280 sensor breakout. It displays the atmospheric temperature, pressure, and humidity on a 96x64 SD1331 colour OLED display:
To display the readings the Weather Station uses a low-cost 96x64 OLED display with 64K colours, and an SPI interface. It"s available from a number of suppliers including Adafruit
The downside with this sensor is that you have to do quite a bit of calculation to get the final readings; it"s not just a case of reading the values from the device via I2C or SPI, as with some other sensors. Both Adafruit and Sparkfun provide a library to interface to the sensor, but unfortunately these don"t seem to work on ATtiny processors, such as the ATtiny85, so I set about writing my own Tiny BME280 library.
My Tiny BME280 library supports the BME280 sensor on the ATtiny85 and other ATtiny processors. I"ve only supported the I2C interface as it is the most useful one on ATtiny devices with a limited number of pins.
The DC pin is tied low, and doesn"t need to be connected to an ATtiny85 pin, because the graphics library is based entirely on commands rather than data. This leaves two I/O pins free on the ATtiny85 for use by the I2C interface to the Bosch BME280 temperature/pressure/humidity sensor.
The resistor from the display"s CS pin holds the chip select high to prevent the display from being affected by the ISP signals while programming the ATtiny85. The other 33kΩ resistor and the 0.1µF capacitor ensure that the display is reset cleanly on power-up.
The pressure is displayed in hPa (hectopascals), also called mbar (millibars). The average sea-level pressure is 1013 mbar. Higher pressures generally indicate clear skies, whereas lower pressures indicate rainy weather.
The humidity is displayed in percentage relative humidity. Typical relative humidity readings are between 40 and 50% RH; outside this range it will feel uncomfortably dry or humid.
I compiled the program using Spence Konde"s ATTiny Core ATtiny25/45/85 option under the ATtinyCore heading on the Board menu. Then choose Timer 1 Clock: CPU, B.O.D. Disabled, ATtiny85, 8 MHz (internal) from the subsequent menus. Choose Burn Bootloader to set the fuses appropriately. Then upload the program using ISP (in-system programming); I used Sparkfun"s Tiny AVR Programmer Board; see ATtiny-Based Beginner"s Kit.
18th November 2019: I"ve corrected the pin names for the display on the circuit diagram, and added a table to show how these translate to the names used on the Adafruit display.
LiquidCrystal fork for displays based on HD44780. Uses the IOAbstraction library to work with i2c, PCF8574, MCP23017, Shift registers, Arduino pins and ports interchangably.
The most powerful and popular available library for using 7/14/16 segment display, supporting daisy chaining so you can control mass amounts from your Arduino!
Menu library for Arduino with IoT capabilities that supports many input and display devices with a designer UI, code generator, CLI, and strong remote control capability.
A simple library to display numbers, text and animation on 4 and 6 digit 7-segment TM1637 based display modules. Offers non-blocking animations and scrolling!
Monochrome LCD, OLED and eInk Library. Display controller: SSD1305, SSD1306, SSD1309, SSD1312, SSD1316, SSD1318, SSD1320, SSD1322, SSD1325, SSD1327, SSD1329, SSD1606, SSD1607, SH1106, SH1107, SH1108, SH1122, T6963, RA8835, LC7981, PCD8544, PCF8812, HX1230, UC1601, UC1604, UC1608, UC1610, UC1611, UC1617, UC1638, UC1701, ST7511, ST7528, ST7565, ST7567, ST7571, ST7586, ST7588, ST75160, ST75256, ST75320, NT7534, ST7920, IST3020, IST3088, IST7920, LD7032, KS0108, KS0713, HD44102, T7932, SED1520, SBN1661, IL3820, MAX7219, GP1287, GP1247, GU800. Interfaces: I2C, SPI, Parallel.
True color TFT and OLED library, Up to 18 Bit color depth. Supported display controller: ST7735, ILI9163, ILI9325, ILI9341, ILI9486,LD50T6160, PCF8833, SEPS225, SSD1331, SSD1351, HX8352C.
The actual manufacture part number is ATTINY85-20PU. It always tends to look like a lot of part numbers, but often it boils down to tape and reel vs tray, temperature ratings, and packaging. Sometimes you will even get different part numbers based on the default configuration (running at the full 20MHz, running at 1/2 clock speed at 10MHz, or using an external crystal for example), even though the actual chip is the same. For their naming convention usually you can find that in the ordering information at the bottom of the datasheet.
Finally the 85 appears. SparkFun is in the U.S., so I"m guessing PIC fan boys. AVRs not on the brain. - I"d like to see an ATtiny parts kit including ATtiny85, 20MHz crystal, crystal caps, bypass cap, and maybe a six pin ISP header. Even if these parts aren"t kitted the related products list below should include them. Nope, now I gotta go hunting; or maybe that"s the idea :-(
I just confirmed that the ArduinoISP can be used to program the SMD SMT version of the ATTiny85 chip. I used the Arduino 0022 IDE and board definitions and older version of the instructions from MIT High Low Tech. (The updated instructions for Arduino 1.0 fail for me.)
I"m trying to control a strip of a single Neopixel with an Attiny85 @ 16Mhz (internal PLL, 4.3 V BOD) but it just doesn"t work. the example "strandtest" just makes the led stuck in green, any help? i"m just connecting the data cable of the neopixel to the Pin 7 (PB2) in the Attiny, i also try putting a resistor in this, but it doesn"t help.ATTINY85
Yep! The ATtiny85 ships with a fuse that makes them operate at internal 1MHz. That fuse can be changed to operate at 8MHz internal. If you need to go above that (or need better precision than the internal oscillator) you can set the fuses to operate with an external oscillator. 20MHz is the maximum external oscillator allowed.
(see: http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?langId=-1&storeId=10001&catalogId=10001&pa=107166&productId=107166&keyCode=WSF&CID=GOOG&gclid=CI2TocLm6rICFexAMgodOU0ALQ for the
Hi all! I"ve recently bought two of these Attiny85 chips. I followed the MIT hi-low tech-group instructions on using Arduino as an ISP to program the chips.http://hlt.media.mit.edu/?p=1229
Exams are over, so there was some time to make this peculiar interactive name tag. It consists of an I2C LCD screen, an ATtiny85 microcontroller and a microphone. If you are attending a conference, a workshop or something similar and you want to make an impression, keep reading!
On 28th of March, it’s the long awaited Arduino Day. I volunteered for the Arduino day at Malmö and thought it would be rude to show up with empty hands. So, I bought a 500 mAh LiPo battery and made me an interactive name tag, which displays my name, my website and as it is attached to a microphone it also shows the volume of my voice! The various components are connected through terminals, which means that they are easily changeable and the system scalable. For example, an L3G4200D gyroscope or an MPL3115A2 barometric sensor can easily be aside of the LCD screen to the I2C port or the microphone to be swapped with an DS1820 thermometer. Everything, in a small package and as usual with a low price tag. Particularly, the most expensive component was the 500 mAh battery by Adafruit (10€), which I had to purchase locally, since I could not afford waiting one month for it to arrive from China. The rest of the materials used in this project cost approximately 6€.
The ATtiny85 is lately becoming my favorite microcontroller, offering low power consumption, size and price. In this case, despite its internal clock running at 1 MHz to increase battery life, it has no problem controlling the 16x2 I2C LCD screen and sampling the microphone at 20Hz. The schema below illustrates how the system is set up:
Just three ATtiny85 pins were used, two for the I2C connection and an analog for the microphone. The battery, LCD screen and the microphone are attached via terminals, in order to assure modifiability. The challenging part is to fit everything behind the screen, but I was lucky enough for the battery to be just big enough for that. Additionally, an on off switch can be glued on the side to increase the total usability of the name tag.
Additional resources: I2C LCD arduino library (based on the work by Digispark), the ATtiny85 sketch and a quick demo video (sorry for the blurry parts).