LILYGO LoRa32

The LILYGO LoRa32 board [1] is an ESP32 board designed for LoRa wireless applications:

LilygoLoRa2.jpg

It is based on the ESP32 processor with 4 MB flash, Wi-Fi and Bluetooth 4.2 with the addition of the following peripherals:

  • A 128x64 monochrome OLED display supported by the uLisp GFX functions.
  • A micro SD card socket supported by the uLisp SD card functions.
  • A LoRa module supported by the uLisp LoRa extension..
  • A battery socket, with charging via the USB port.

Installing uLisp from the Arduino IDE

Install the ESP32 Arduino core

  • Add the following URL to the Additional Boards Manager URLs list in the Arduino IDE Preferences dialog box:
https://espressif.github.io/arduino-esp32/package_esp32_index.json
  • In the Arduino IDE search for the ESP32 Arduino core in Boards Manager and install it.

I tested this with core version 2.0.10.

  • Select ESP32 Arduino from the Board menu, and TTGO LoRa32-OLED from the submenu.
  • Set Board Revision to TTGO LoRa32 V2.1 (1.6.1).

You can leave all the other options at their defaults.

Installing the LoRa extension

If you want to add the uLisp LoRa Extension which provides functions to use the LoRa radio:

  • Install Sandeep Mistry's Arduino-LoRa Library via the Arduino IDE Library Manager.
  • Download the LoRa extension file and save it with the name LoRaExtension.ino.
  • Put it in the same folder as your uLisp source file.
  • In the main uLisp source file uncomment the lines:
#define extensions
#define streamextensions

Upload uLisp

  • Download Release 4.8b or later of the ARM version of uLisp from the Download uLisp page.
  • Enable the uLisp graphics and SD card support, if required, by uncommenting the lines:
#define sdcardsupport
#define gfxsupport
  • Select the board's USB port from the Port menu
  • Upload uLisp to the board.

Using uLisp

  • You may need to select the board's USB port from the Port menu again.
  • Select Serial Monitor from the Tools menu.
  • Enter Lisp commands.

Pins

LORA32Pins.jpg

LED

The LILYGO LoRa32 has an green LED connected on pin 25. You can flash it with the following program:

(defun blink (&optional x)
  (pinmode :led-builtin :output)
  (digitalwrite :led-builtin x)
(delay 1000) (blink (not x)))

Run it by typing:

(blink)

All pins can also be used for analogue (PWM) output, so you can pulsate the LED slowly on and off with the program:

(defun pulse ()
  (let (down)
    (loop
     (dotimes (x 256) 
       (delay 5) 
       (analogwrite :led-builtin (if down (- 255 x) x)))
(setq down (not down)))))

Run it by typing:

(pulse)

Exit from either program by entering ~.

Analogue inputs

The LILYGO LoRa32 has analogue inputs on pins 0, 2, 4, 12 to 15, 25 to 26, 34 to 36, and 39.

Analogue outputs

You can generate an analogue output using PWM on any of the digital pins. The precision is 8 bits.

Serial

The LILYGO LoRa32 has one serial port on pin numbers 3 (RX) and 1 (TX). By default the baud rate is 9600.

SPI

The LILYGO LoRa32 SPI ports are used for the SD card and LoRa.

I2C

The LILYGO LoRa32 has one I2C port on pin numbers 21 (SDA) and 22 (SCL).

OLED display

The monochrome OLED display has a resolution of 128x64 and supports the Graphics extensions. Drawing is done in a memory buffer, and to update the display after a series of drawing commands you need to call:

(display)

The following example draws a welcome screen:

LilygoLoRa1.jpg

(defun welcome ()
  (fill-screen)
  (do ((x 0 (+ 6 x)) (y 0 (+ 3 y))) ((> x 127))
    (draw-line 0 y x 63)
    (draw-line x 0 127 y))
  (set-text-color 1) (set-cursor 28 30)
  (with-gfx (str) (princ "HelLoRa World" str))
  (display))

  1. ^ Lora32 on LILYGO.