Tele Ink for ESP32
An ESP32 display project involving E-paper display.
Parts and sourceBefore you start
Check the exact E-paper display configuration against the upstream wiring or parts list.
Upstream README
Tele-Ink
A FreeRTOS based 4GLTE/WiFi/GNSS IoT device that utilizes a E-Ink display for low power
Features
- Utilizes E-Ink display for low power/holding images while off
- USB-C 500Ma Charging and 2500Mah internal battery
- Full Qwerty keyboard with arrow keys and fn/sym keys
- Hologram SIM for automatic network switching +46 Country code and 13 digit number
- Full Global Roaming 4g/3g/2g/LTE/GNSS/PPP/etc (no voice)
- Service quality is parsed and interpreted to show signal type and quality
- WiFi is available for connection/hosting/scanning but commented out for now to save upload time.
- Can send/recive/respond/delete SMS messages directly from SIM.
- GNSS mode allows location data such as time, date, location, etc.
- Local time offset is calculated automatically using longitude from UTC not accounting for DST
- Can send raw AT commands and see full responses using command page.
- Command screen is encapsulated and dynamic so text will wrap and push elements up until there is room
- Idle animation similar to old VCR tape machines.
- Full control over hardware from command page.
FreeRTOS Task Overview
Task: Core: Priorety: Use:
* keyTask 0 3 Polls I2C and if special key, performs large operations else reads into cmd_buffer if in sequential
* displayTask 0 2 Consumes from dispQueue and operates the I2C EPD (E-Paper) API using epd_mutex
* modemTask 1 4 Reads UART RX resp/URC and consumes from modem_cmd_queue and sends -> TX using modem_mutex
* modemBackgroundTask 1 1 Uses UART to get modem ready then polls status/GNSS/signal strength using modem_cmd_queue
Usage
- You must wait ~20 seconds for modem coldstart + system recognition for AT
- Sym+key can be used for major screen updates and or page changes
- You can change screen page using sym+key (home h, idle i, command c)
- Sleep/Wake button clears screen on sleep (sym+esc)
- GNSS info updates every 15s in background if gnss_on just repaint to see new data on homepage
- Idle page has a VCR style box bouncing around on the edges of the screen that will trigger if low activity
- Command page causes keyboard to enter sequential mode for typing
- Command modes include (Base $, at mode AT, sms write >, sms read :, gnss GNSS:)
- In SMS read mode you can use /s to send a message to the number of the last message read
- GNSS mode requires "on" plus time for a fix, then repaint the homescreen or "info"
- Command modes can be exited using /exit or esc key
- It will save state, history and text buffer unless you /clear
- Queuing display events will cause a fullscreen refresh unless they are modem status changes not on the homescreen.
- WARNING the epd api from waveshare requires 4Gray to be initlizied before fullscreen changes. (It currently only initilizes once at start) STABLE
Commands
$ TEXT - Echo mode
$ /help - Sends you here
$ /clear - Clear history
$ /sim on/off - Toggle pwk on modem
$ /sim net - Send AT+CREG? and handle URC auto
$ /esp rst - Restart ESP32
$ /at CMD - Send raw single line AT command
$ /at - Enter AT mode
AT_ - Type AT command ex: +CREG?, +CNUM (AT is prepented)
AT/exit - Exit AT mode
$ /sms s NUMBER - Start SMS send mode to NUMBER
$ /sms s - Start SMS send mode to saved NUMBER
> MESSAGE - Send SMS MESSAGE to NUMBER
> /exit - Exit SMS send mode
$ /sms ra - Read all messages stored on sim
$ /sms ru - Read unread messages stored on sim
: ID - Read message number ID and store number into buffer
: /s - Uses previously read messages's number and enter SMS send mode
: /d ID - Delete message from sim
: /da - Deletes all messages from sim
: /exit - Exit SMS read mode
$ /gnss - Enter GNSS mode
GNSS: on - Turn on GNSS and wait for fix
GNSS: off - Turn off GNSS
GNSS: info - Query time and location data UTC
GNSS: /exit - Exit GNSS mode
High level Code functionality
- Starting at Tele-Ink.ino
- Screen is initilized via Waveshare original code modified
- DisplayInit() Starts a new task that can read from a queue of display events
- DisplayTask performs updates on the screen while holding the EPD mutex and initilizes 1Gray mode before updates
- ModemInit() Starts a new task and queue then attempts to connect to the module via "AT" -> TX after cold start
- ModemTask waits for commands in the queue from SendAT and or reads incoming data on RX
- ModemStatusTask checks physical status of modem by sending AT/CREG in background every ~10s
- ModemStatusTask takes modem_mutex when sending and reading UART to not interfere with SendAT()
- ModemGNSSTask pings AT+CGPSINFO and updates global information held in display.h
- ModemGNSSTask automatically calculates rough timezone offset using longitute (does not account for DST yet)
- ModemSendAT takes modem_mutex and the original task gives back after response or givin timeout
- KeyboardInit() Starts a new task that polls for incoming data on I2C 0x5F (keypress when not 0x00)
- Keyboardtask will enter sequential mode and start the cmd_buffer if the selected page is command page
- KeyboardTask doesnt need debounce (release = 1 stroke), and when a special key is encountered, posts events for other tasks
- KeyboardTask reads keys until enter and then the global input is set and Command.cpp starts processesing
- Command takes a global c-string as input and returns a response into the global resp buffer as well as posting events
- Command history and command buffer is stored globally in hisplay.h struct until /clear
- Command buffer is accessed atomically by display to show user text(producer/viewer)
- Command buffer is accessed atomically for modem commands and updating responses (producer/consumer)
- Command history is saved and can be accessed by using arrow keys
- WiFi is underdeveloped at the moment but can poll for nearby networks or connect to one.
- All of the heavy tasks have a timeout feature that will increase time between loops to save resources
- Every 60 partial updates send fullscreen refresh event to prevent ghosting in daylight or use Sym+P to repaint
- Display_1Gray_Part rotation coordinates not working so ~500ms refreshrate is best so far
- Start at the homescreen and shift to idlescreen when no acitivity is detected
Tech Stack
Hardware/Communication
- Waveshare ESP32-WROOM-32E E-Ink driver module
- Waveshare E-Ink display black/white 3.7 inch
- Waveshare SIM7600G-H Modem module
- LTE antenna I-P.EX Unobstructed
- GNSS Cirocomm I-P.EX Unobstructed
- Hologram SIM card (not using API)
- M5Stack CardKB v1.1
- AmpRipper 4000 v1.0 PSU/BMS
- AdaFruit 1sLiPo 2500mAh battery
- UART (ESP32 <-> Modem)
- SPI (ESP32 <-> E-Ink)
- I2C (ESP32 <-> Keyboard)
Software/Development Env
- C/C++
- Arduino
- FreeRTOS
Hardware Modifications
- Replaced 471 SMD resistors on M5Stack keyboard with 472 (3.3v logic) (clk/dat)
- Replaced SMD resistor on AmpRipper for 1A max batt charge rate (AdaFruit Batt Max)
- Switch on ESP32 Driver board 1 = A 2 = ON
Goals
- Fix partial update buffer rotation coordinates (Waveshare API broken)
- Add connections between BMS and ESP for battery info
- Add RAW data mode AT+CMGF=0 but need encoding
- Add GNSS automatic DST calculation based on month/day/location?
- Add PPP dial up support for remote WiFi hosting (unlikely and SLOW)
Diagram
┌──────────────────────────────────┐
│ │
│ ◄─────────────┐
│ ◄───────────┐ │
│ 2500mAh LiPo 1s │ │ │ DATA
│ │ │ │ ──────────────
│ │ │ │ POWER
│ │ │ │ ─────────────►
└──────────────────────────────────┘ │ │
│ │
│ │ USB IN
│ │ │
│ │ │
┌────▼─▼───────▼─────┐
│ ┼────────────────────────────┐
┌──────────────────────────────────────────┐ │ ┼──────────────────────────┐ │
│ 3.7" E-INK │ │ AMP Ripper │ │ │
│ ┌────────────────────────────────────┐ │ │ PSU/BMS │ │ │
│ │ │ │ │ xx │ │ │
│ │ │ │ └─┬─┬────────────────┘ │ │
│ │ │ │ ┌──────┼ │ │ │
│ │ │ │ │ ┌┼┐│ │ │
│ │ │ │ │ ┌───┘│└┼ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ Cleared History! │ │ │ │ │ │ │ │
│ │ $ _ │ │ ┌┘┌┘┌───▼─▼─────────┐ │ │
│ └────────────────────────────────────┘ ├────────┼─┼─┤ │ GND ┌──────────────────▼─▼──┐
│ │ SPI 4 │ │ │ ┼──────────────┼ │
└──────────────────────────────────────────┴────────┼─┼─┼ │ 17-TXD │ │
└┐└┐│ ESP32W ┼──────────────┤ │
┌─────────────────────────────────────────────┐ │ ││ │ 16-RXD │ │
│ M5Stack QWERTY Keyboard ◄────────┘ ││ ┼──────────────┤ │
│ ◄──────────┘│ │ 4-PWK │ │
│ │ │ ┼──────────────┤ SIM7600G-H │
│ │ └──┬──┬─────────┘ │ │
│ │ DATA-21 │ │ │ │
│ 472 ┼──────────────┘ │ │ │
│ │ CLK-22 │ │ │
│ 472 ┼─────────────────┘ LTE───────┤ │
│ │ GNSS───────┤ │
│ │ └───────────────────────┘
│ │
│ │
└─────────────────────────────────────────────┘
Sources
- https://www.waveshare.com/wiki/SIM7600G-H_4G_Module?srsltid=AfmBOoow9ujjO1206nzUsXVMr9o72mcQgfmwjMp-vEK3QVuOIhEVSpLd
- https://www.waveshare.com/wiki/E-Paper_ESP32_Driver_Board
- https://www.waveshare.com/wiki/E-Paper_API_Analysis?srsltid=AfmBOoqeSFM_rVWAgtaWrzRiQB7OrI90iRIy5Up24zcl5dhIv23WO0H_
- https://www.digikey.com/en/resources/conversion-calculators/conversion-calculator-ohms
- https://www.waveshare.com/w/upload/3/39/SIM7080_Series_AT_Command_Manual_V1.02.pdf?srsltid=AfmBOopDPUJbcJVsTY_KqjYtSbKTreGlTCFfHh68Vml8m4Wp6ItrzICq
- https://docs.m5stack.com/en/unit/cardkb_1.1
- https://www.tindie.com/products/kickstart_design/ampripper-4000-5v-4a-lipo-li-ion-battery-charger/
- https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/freertos.html
- https://content.u-blox.com/sites/default/files/products/documents/GNSS-Antennas_AppNote_(UBX-15030289).pdf
- https://www.w3schools.com/c/c_ref_string.php