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

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

Display simple string on E-Ink with increasing counter


Before starting

Dependancies

waveshare

Details

Waveshare E-Ink version

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

WaveShare 1.54 inch module

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 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.h"
#include "epdpaint.h"

#define COLORED 0
#define UNCOLORED 1

unsigned char image[1024];
Paint paint(image, 0, 0);
Epd epd;
int count = 0;
char count_string[] = {'0', '0', '0', '\0'};

void setup() {
  SerialUSB.begin(9600);

  SerialUSB.print("e-Paper init ");
  if (epd.Init(lut_full_update) != 0) {
    SerialUSB.print("e-Paper init failed");
    return;
  }
}

void loop() {
  sprintf(count_string, "%d", ++count);
  SerialUSB.println(count_string);

  epd.ClearFrameMemory(0xFF);  // bit set = white, bit reset = black
  epd.DisplayFrame();
  epd.ClearFrameMemory(0xFF);  // bit set = white, bit reset = black
  epd.DisplayFrame();

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

  paint.Clear(COLORED);
  paint.DrawStringAt(10, 4, "hello", &Font24, UNCOLORED);
  paint.DrawStringAt(10, 30, count_string, &Font24, UNCOLORED);
  epd.SetFrameMemory(paint.GetImage(),
    80, 72, paint.GetWidth(), paint.GetHeight());
  epd.DisplayFrame();

  delay(1000);
  epd.Sleep();
}

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