Adafruit eInk Display Breakouts Created by lady ada Last updated on 2019-12-19 05:17:34 PM UTC
Overview Easy e-paper finally comes to microcontrollers, with these breakouts, shields and friends that are designed to make it a breeze to add a tri-color eInk display. Chances are you've seen one of those new-fangled 'e-readers' like the Kindle or Nook. They have gigantic electronic paper 'static' displays - that means the image stays on the display even when power is completely disconnected. The image is also high contrast and very daylight readable.
We have multiple tri-color displays. They have black and red ink pixels and a white-ish background. Using our Arduino library, you can create a 'frame buffer' with what pixels you want to have activated and then write that out to the display. Most simple breakouts leave it at that. But if you do the math, using even the smallest 1.54" display: 152 x 152 pixels x 2 colors = 5.7 KBytes. Which won't fit into many microcontroller memories.
On the EInk Friends and Breakouts, for ultra-low power usages, the onboard 3.3V regulator has the Enable pin brought out so you can shut down the power to the SRAM, MicroSD and display. On the Breakouts and Shields, We even tossed on a MicroSD socket so you can store images, text files, whatever you like to display. Everything is 3 or 5V logic safe so you can use it with any and all microcontrollers. © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
Pinouts This e-Paper display uses SPI to receive image data. Since the display is SPI, it was easy to add two more SPI devices to share the bus - an SPI SRAM chip and SPI-driven SD card holder. There's quite a few pins and a variety of possible combinations for control depending on your needs © Adafruit Industries https://learn.adafruit.
The pin outs are identical for the 1.54", 2.13" and 2.7" E-Ink display! eInk Breakout Friend Connect a bare eInk display to this breakout to use it! Power Pins © Adafruit Industries https://learn.adafruit.
3-5V / Vin - this is the power pin, connect to 3-5VDC - it has reverse polarity protection but try to wire it right! 3.3V out - this is the 3.3V output from the onboard regulator, you can 'borrow' about 100mA if you need to power some other 3.3V logic devices GND - this is the power and signal ground pin ENAble - This pin is all the way on the right. It is connected to the enable pin on the onboard regulator that powers everything.
The FeatherWing eInk Display and eInk Feather Friend are a little more compact but have just about the same pins as the breakout SPI MOSI/MISO/SCK are on the FeatherWing SPI connection pads SD CS, SRAM CS, EINK CS and DC are in order after the two I2C pins. The numbers of the pins these correspond to will differ from board to board. However, on 32u4/328p/M0/M4/nRF52840 and many other boards you will see the following connections SD CS to Pin D5 © Adafruit Industries https://learn.adafruit.
SRAM CS to Pin D6 EINK CS to Pin D9 EINK DC to Pin D10 If you do not plan to use the SD card, you can cut the trace to SD CS. Likewise for SRAM CS. The Reset pin for the E-Ink display is connected to an auto-reset circuit and also to the Feather Reset pin, so it will reset when you press the reset button. The Busy pin is available on a breakout pad, you can solder it to a wire and connect to a pin if you need it - we figure most people will just use a fixed delay. © Adafruit Industries https://learn.
Shield Pinouts The 2.7" EInk Shield is a little special in that the pins are fixed, so we'll document that here. Power Pins 5V - this pin on the Arduino is used to generate the 3V logic level for the EInk chip, level shifter and boost converter. GND - connected for power and logic reference IORef - this pin is connected to the level shifter and pullups.
int8_t readButtons(void) { uint16_t reading = analogRead(A3); //Serial.println(reading); if (reading > 600) { return 0; // no buttons pressed } if (reading > 400) { return 4; // button D pressed } if (reading > 250) { return 3; // button C pressed } if (reading > 125) { return 2; // button B pressed } return 1; // Button A pressed } © Adafruit Industries https://learn.adafruit.
Assembly Assembly Cut the header down to length if necessary. It will be easier to solder if you insert it into a breadboard - long pins down © Adafruit Industries https://learn.adafruit.
Add the E-Ink Display Place the board over the pins so that the short pins poke through the top of the breakout pads © Adafruit Industries https://learn.adafruit.
And Solder! Be sure to solder all pins for reliable electrical contact. (For tips on soldering, be sure to check out the Guide to Excellent Soldering (https://adafru.it/aTk)). OK, you're done! © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
Usage & Expectations One thing to remember with these small e-Ink screens is that its very slow compared to OLEDs, TFTs, or even 'memory displays'. It will take may seconds to fully erase and replace an image There's also a recommended limit on refeshing - you shouldn't refresh or change the display more than every 3 minutes (180 seconds). You don't have to refresh often, but with tri-color displays, the larger red ink dots will slowly rise, turning the display pinkish instead of white background.
Arduino Code Do not update more than once every 180 seconds or you may permanently damage the display Wiring Wiring up the display in SPI mode is pretty easy as there's not that many pins! We'll be using hardware SPI, but you can also use software SPI (any pins) later. The pin outs are identical for the 1.54", 2.13" and 2.7" E-Ink display! Start by connecting the power pins 3-5V Vin connects to the microcontroller board's 5V or 3.
These can be set in the sketch to any pins you like but to follow the exact example code we'll use the following: ECS connects to our e-Ink Chip Select pin. We'll be using Digital 10 but you can later change this to any pin D/C connects to our e-Ink data/command select pin. We'll be using Digital 9 but you can later change this pin too. SRCS connects to our SRAM Chip Select pin. We'll be using Digital 8 but you can later change this to any pin RST connects to our e-Ink reset pin.
If you would like to draw bitmaps, do the same with adafruit ImageReader, click Install Do the same to install the latest adafruit GFX library, click Install Load First Demo Open up File→Examples→Adafruit_EPD→EPDtest If you're using a FeatherWing, try File→Examples→Adafruit_EPD→FeatherWingTest At the top of the sketch find the lines that look like: /* Uncomment the following line if you are using 1.
You will see the display flash a bunch and then a set of black and red lines will appear like shown on the left. If you see the lines, your wiring is good! If not, go back and check your wiring to make sure its correct.
This time you will see the display going through a range of tests, from pixels, lines, text circles etc. This shows all the different shapes and techniques you can use that come with the Adafruit GFX library! Unlike most e-paper displays, where you can only draw an image, the built in SRAM lets you have full control over what shows up on the eInk screen.
Drawing Bitmaps You may need a board with more memory such as the Metro M0 or Metro M4 to handle the memory requirements of drawing a bitmap. Not only can you draw shapes but you can also load images from the SD card, perfect for static images! The 1.54" display can show a max of 152x152 pixels. Lets use this Blinka bitmap as our demo: https://adafru.it/BTa https://adafru.it/BTa For the 2.13" display, use this image instead © Adafruit Industries https://learn.adafruit.
https://adafru.it/EaE https://adafru.it/EaE Rename the file blinka.bmp and place into the base directory of a microSD card and insert it into the microSD socket in the breakout. One extra wire is required, for SDCS which is the SD card Chip Select. We'll connect that to pin #4 but you can use any pin. Plug the MicroSD card into the display.
© Adafruit Industries https://learn.adafruit.
Arduino Library Documentation Arduino Library Documentation (https://adafru.it/BST) © Adafruit Industries https://learn.adafruit.
Adafruit GFX Library Adafruit GFX Library (https://adafru.it/doL) © Adafruit Industries https://learn.adafruit.
CircuitPython Code Do not update more than once every 180 seconds or you may permanently damage the display CircuitPython Microcontroller Wiring Using eInk displays with displayio is really easy. First, wire up your eInk breakout as shown below. All displays have the same pinout, so if your display differs from the one in the Fritzing diagram, you can wire it up the same way.
https://adafru.it/GdI https://adafru.it/GdI To use the eInk displays with displayio, you will need to use the latest version of CircuitPython 5.0. CircuitPython eInk displayio Library Installation To use displayio, you will need to install the appropriate library for your display. First make sure you are running the latest version of Adafruit CircuitPython (https://adafru.it/Amd) for your board. You will need the latest version of CircuitPython 5.0. Even though it is in Alpha, it has been very stable.
Copy the adafruit_il0373.mpy file from the bundle to the lib folder on your CIRCUITPY drive. Adafruit_CircuitPython_SSD1608 1.54” Monochrome eInk Copy the adafruit_ssd1608.mpy file from the bundle to the lib folder on your CIRCUITPY drive. Adafruit_CircuitPython_SSD1675 2.13” Monochrome eInk 2.13 Monochrome eInk FeatherWing Copy the adafruit_ssd1675.mpy file from the bundle to the lib folder on your CIRCUITPY drive. Adafruit_CircuitPython_IL91874 2.7” Tri-Color eInk Copy the adafruit_il91874.
#import adafruit_il0398 # Set based on your display FLEXIBLE = False TRICOLOR = True ROTATION = 90 # Used to ensure the display is free in CircuitPython displayio.release_displays() # Define the pins needed for display use # This pinout is for a Feather M4 and may be different for other boards # For the Metro/Shield, esc is board.D10 and dc is board.D9 spi = board.SPI() # Uses SCK and MOSI ecs = board.D9 dc = board.D10 rst = board.D5 # set to None for FeatherWing/Shield busy = board.
display.refresh() print("refreshed") time.sleep(180) We start by importing the libraries that we need. In this case we need time for adding delays, board the pin definitions, and of course displayio . import time import board import displayio Next you want to uncomment the import statement for the correct driver for your display. This should match the file you copied over earlier. In our case, the 2.9" uses the adafruit_il0373 driver, so we can leave it as is.
color display. You can leave this alone. if TRICOLOR: highlight = 0xff0000 #third color is red (0xff0000) else: highlight = 0x000000 In the next line, we set the display bus to FourWire which makes use of the SPI bus. We pass it the D/C , and CS pins, which are also usually found on TFT displays and if this is a breakout, we also pass in the reset pin. We set the baudrate to 1 MHz instead of the default 24 MHz because the ePaper displays are not about the speed.
pic = displayio.OnDiskBitmap(f) # Create a Tilegrid with the bitmap and put in the displayio group t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter()) g.append(t) In the next line we tell the display to show everything in the group. display.show(g) Finally, we tell the display to refresh so that everything in memory is written out to the display. display.
Python Code Wiring It's easy to use eInk breakouts with Python and the Adafruit CircuitPython EPD (https://adafru.it/BTd) library. This library allows you to easily write Python code to control the display. We'll cover how to wire the display to your Raspberry Pi. First assemble your display. Since there's dozens of Linux computers/boards you can use we will show wiring for Raspberry Pi.
CircuitPython on Python 2.x, it isn't supported! If that complains about pip3 not being installed, then run this first to install it: sudo apt-get install python3-pip Download font5x8.bin This library also requires a font file to run! You can download it below. Before continuing, make sure the folder you are running scripts from contains the font5x8.bin file. https://adafru.it/Gfb https://adafru.
from adafruit_epd.il0373 import Adafruit_IL0373 display = Adafruit_IL0373(152, 152, spi, cs_pin=ecs, dc_pin=dc, sramcs_pin=srcs, rst_pin=rst, busy_pin=busy) If you're using the 2.13" Tri-Color display, run the following code to initialize the display: from adafruit_epd.il0373 import Adafruit_IL0373 display = Adafruit_IL0373(104, 212, spi, cs_pin=ecs, dc_pin=dc, sramcs_pin=srcs, rst_pin=rst, busy_pin=busy) If you're using the 2.
Monochrome Example Now we can clear the screens buffer and draw some shapes. Once we're done drawing, we need to tell the screen to update using the display() method. display.fill(Adafruit_EPD.WHITE) display.fill_rect(0, 0, 50, 60, Adafruit_EPD.BLACK) display.hline(80, 30, 60, Adafruit_EPD.BLACK) display.vline(80, 30, 60, Adafruit_EPD.BLACK) display.display() Your eInk display should look similar to the image above, with a black rectangle instead of a red one. © Adafruit Industries https://learn.
That's all there is to drawing simple shapes with eInk displays and CircuitPython! Tri-Color Bitmap Example Here's a complete example of how to display a bitmap image on your display. Note that any .bmp image you want to display must be exactly the size of your display. We will be using the image below on the 1.54" display. Click the button below to download the image and save it as blinka.bmp on your Raspberry Pi. https://adafru.it/BTa https://adafru.
# create the spi device and pins we will need spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) ecs = digitalio.DigitalInOut(board.D10) dc = digitalio.DigitalInOut(board.D9) srcs = digitalio.DigitalInOut(board.D7) # can be None to use internal memory rst = digitalio.DigitalInOut(board.D11) # can be None to not use this pin busy = digitalio.DigitalInOut(board.
bmpHeight = read_le(f.read(4)) flip = True print("Size: %d\nImage offset: %d\nHeader size: %d" % (bmpFileSize, bmpImageoffset, headerSize)) print("Width: %d\nHeight: %d" % (bmpWidth, bmpHeight)) if read_le(f.read(2)) != 1: raise BMPError("Not singleplane") bmpDepth = read_le(f.read(2)) # bits per pixel print("Bit depth: %d" % (bmpDepth)) if bmpDepth != 24: raise BMPError("Not 24-bit") if read_le(f.read(2)) != 0: raise BMPError("Compressed file") print("Image OK! Drawing...
Change the pins to the following to match the wiring on the Raspberry Pi: ecs = digitalio.DigitalInOut(board.CE0) dc = digitalio.DigitalInOut(board.D22) srcs = None rst = digitalio.DigitalInOut(board.D27) busy = digitalio.DigitalInOut(board.D17) Now go to the command prompt on your Raspberry Pi and run the script with the following command: python3 epd_bitmap.py After a few seconds, your display should show this image: Full Example Code Here is the full example code.
import digitalio import busio import board from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.il0373 import Adafruit_IL0373 from adafruit_epd.il91874 import Adafruit_IL91874 from adafruit_epd.il0398 import Adafruit_IL0398 # from adafruit_epd.ssd1608 import Adafruit_SSD1608 from adafruit_epd.
downloading a PNG of blinka that has been adjusted down to 3 colors so it prints nicely on an ePaper Display. We are using PNG for this because it is a lossless format and won't introduce unexpected colors in. Make sure you save it as blinka.png and place it in the same folder as your script. Here's the code we'll be loading onto the Raspberry Pi. Go ahead and copy it onto your Raspberry Pi and save it as epd_pillow_image.py. We'll go over the interesting parts.
display = Adafruit_IL0373(104, 212, spi, # 2.13" Tri-color display cs_pin=ecs, dc_pin=dc, sramcs_pin=srcs, rst_pin=rst, busy_pin=busy) # IF YOU HAVE A FLEXIBLE DISPLAY (2.13" or 2.9") uncomment these lines! #display.set_black_buffer(1, False) #display.set_color_buffer(1, False) display.rotation = 1 image = Image.open("blinka.png") # Scale the image to the smaller screen dimension image_ratio = image.width / image.height screen_ratio = display.width / display.
display is selected by default. For other displays, go ahead and comment out the line that starts with: display = Adafruit_IL0373(104, 212, spi, and uncomment the line appropriate for your display. #display = Adafruit_SSD1608(200, 200, spi, # 1.54" HD mono display #display = Adafruit_SSD1675(122, 250, spi, # 2.13" HD mono display #display = Adafruit_IL91874(176, 264, spi, # 2.7" Tri-color display #display = Adafruit_IL0373(152, 152, spi, # 1.
image_ratio = image.width / image.height screen_ratio = display.width / display.height if screen_ratio < image_ratio: scaled_width = image.width * display.height // image.height scaled_height = display.height else: scaled_width = display.width scaled_height = image.height * display.width // image.width image = image.resize((scaled_width, scaled_height), Image.BICUBIC) Next we want to figure the starting x and y points of the image where we want to begin cropping it so that it ends up centered.
Here's what it looks like on a monochrome display: Drawing Shapes and Text with Pillow In the next example, we'll take a look at drawing shapes and text. This is very similar to the displayio example, but it uses Pillow instead. Go ahead and copy it onto your Raspberry Pi and save it as epd_pillow_demo.py. Here's the code for that. """ ePaper Display Shapes and Text demo using the Pillow Library.
FOREGROUND_COLOR = WHITE TEXT_COLOR = RED # create the spi device and pins we will need spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) ecs = digitalio.DigitalInOut(board.CE0) dc = digitalio.DigitalInOut(board.D22) srcs = None rst = digitalio.DigitalInOut(board.D27) busy = digitalio.DigitalInOut(board.D17) # give them all to our driver #display = Adafruit_SSD1608(200, 200, spi, # 1.54" HD mono display #display = Adafruit_SSD1675(122, 250, spi, # 2.
import digitalio import busio import board from PIL import Image, ImageDraw, ImageFont from adafruit_epd.il0373 import Adafruit_IL0373 from adafruit_epd.il91874 import Adafruit_IL91874 from adafruit_epd.il0398 import Adafruit_IL0398 from adafruit_epd.ssd1608 import Adafruit_SSD1608 from adafruit_epd.ssd1675 import Adafruit_SSD1675 Next we define some colors that can be used with Pillow.
also make use of the FONTSIZE parameter that we discussed earlier. font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', FONTSIZE) Now we draw the text Hello World onto the center of the display. You may recognize the centering calculation was the same one we used to center crop the image in the previous example. In this example though, we get the font size values using the getsize() function of the font object. text = "Hello World!" (font_width, font_height) = font.
Python Docs Python Docs (https://adafru.it/C4z) © Adafruit Industries https://learn.adafruit.
Downloads Files Fritzing object in Adafruit Fritzing Library (https://adafru.it/aP3) IL0376F E-Ink interface chip datasheet (https://adafru.it/BRW) PCB Files on GitHub (https://adafru.it/BRX) Display shape/outline: Schematic & Fabrication Prints © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
2.9 Inch Display © Adafruit Industries https://learn.adafruit.
eInk Friends © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
© Adafruit Industries Last Updated: 2019-12-19 05:17:34 PM UTC Page 61 of 61