Oak

🌳 An outdoor LoRa-GPS tracker with an E-Ink display 🔑

power 18650
wireless LoRa,
sensor GPS, E-Ink
mcu SAMD21G18
bom items 82
bom cost USD $78.93
vendors 6
completed July 2022

E-Ink hello world with V2.1

e-ink e-paper waveshare display e-paper version 2.1 medium

Display demo sample code with V2.1 E-Ink hardware version


Before starting

Dependancies

waveshare

Details

Waveshare E-Ink version

Check the E-Ink display module for the version number. Here, version 2.1 is used and the number is marked on the module.

WaveShare 1.54 inch module Version 2.1

SPI

The 4 non-SPI pins are defined in epdif.h file:

#define RST_PIN 8
#define DC_PIN 9
#define CS_PIN 10
#define BUSY_PIN 7

The SPI pins for Arduino Zero / SAMD21G are defined as following:

SAMD21G Pin I/O Pin SERCOM-ALT Name
19 PB10 SERCOM4/PAD[2] COPI
20 PB11 SERCOM4/PAD[3] SCK

Pins in schematic

Schematic label Arduino Zero pin name SAMD21G pin name
EINK_BUSY D7 PA21
EINK_RST D8 PA06
EINK_DC D9 PA07
EINK_CS D10 PA18
COPI ICSP_COPI PB10
CLK ICSP_SCK PB11
CIPO ICSP_CIPO PA12

Steps

  1. Plug in the Oak PCB with the E-Ink to the computer
  2. (Option A) Ensure the PCB can be detected with ls -al /dev/cu.usbmodem and arduino-cli board list. Run make to compile and upload the code to the board. (Option A) Ensure the PCB can be detected with <code>ls -al /dev/cu.usbmodem</code> and <code>arduino-cli board list</code>. Run <code>make</code> to compile and upload the code to the board.
  3. (Option B) Ensure the board can be detected with Arduino IDE. Compile and upload the code to the board. (Option B) Ensure the board can be detected with Arduino IDE. Compile and upload the code to the board.
  4. Start the serial monitor to view the console logs

Serial console

Serial output from the firmware.

Code

Download code
#include <SPI.h>
#include "epd1in54_V2.h"
#include "epdpaint.h"

Epd epd;
unsigned char image[1024];
Paint paint(image, 0, 0);

#define COLORED     0
#define UNCOLORED   1

int count = 0;
char count_string[] = {'0', '0', '0', '\0'};

void setup() {
  SerialUSB.begin(9600);
  SerialUSB.println("e-Paper init");
  initEink();
  delay(1000);
}

void loop() {
  displayOnEink();
  delay(2000);
}

bool initEink() {
  epd.LDirInit();
  epd.Clear();

  return true;
}

void displayOnEink() {
  sprintf(count_string, "%d", ++count);

  paint.SetWidth(200);
  paint.SetHeight(24);
  paint.SetRotate(ROTATE_0);

  paint.Clear(COLORED);
  paint.DrawStringAt(10, 4, "Lat Long!", &Font16, UNCOLORED);
  epd.SetFrameMemory(
      paint.GetImage(), 0, 10, paint.GetWidth(), paint.GetHeight());

  paint.Clear(UNCOLORED);
  paint.DrawStringAt(10, 4, "at ", &Font16, COLORED);
  paint.DrawStringAt(40, 4, "00:00", &Font16, COLORED);
  epd.SetFrameMemory(
      paint.GetImage(), 0, 30, paint.GetWidth(), paint.GetHeight());

  paint.SetWidth(50);
  paint.SetHeight(120);
  paint.SetRotate(ROTATE_270);

  paint.Clear(COLORED);
  paint.DrawStringAt(12, 10, count_string, &Font16, UNCOLORED);
  paint.DrawStringAt(12, 32, count_string, &Font16, UNCOLORED);
  epd.SetFrameMemory(
      paint.GetImage(), 80, 72, paint.GetWidth(), paint.GetHeight());

  epd.DisplayFrame();
  SerialUSB.println("e-Paper print " + String(count_string));
}

Makefile

BOARD?=hutscape:samd:oak
PORT := $(shell ls /dev/cu.usbmodem*)
BUILD=build

.PHONY: default lint all flash clean

default: all flash clean

all:
	arduino-cli compile --fqbn $(BOARD) --output-dir $(BUILD) ./

flash:
	arduino-cli upload -p $(PORT) --fqbn $(BOARD) --input-dir $(BUILD) --verbose

clean:
	rm -r build

References