4. Jetson Nano Development Tutorial

4.1 Getting Started

4.1.1 Wiring Instruction

This section uses DuPont wires to connect OLED display module. For wiring instructions, refer to the figure below:

Note

Before powering on, ensure that no metal objects are touching the controller. Otherwise, the exposed pins at the bottom of the board may cause a short circuit and damage the controller.

4.1.2 Environment Configuration

Install NoMachine on your computer. The software package is located under “2 Software Tools & Programs -> 01 Software Installation Package -> Remote Desktop Connection Tool -> 1 Remote Desktop Connection Tool. For detailed usage of NoMachine, refer to the materials in the same directory.

Drag the program into the Jetson Nano system image, taking placing it on the desktop as an example.

Open the terminal and enter the command to navigate to the program directory, enter:

cd Desktop/

4.2 Test Case

This example uses terminal to display the OLED sensor values and show how to control the module based on set thresholds.

4.2.1 Program Execution

  1. Open the terminal and enter the command to navigate to the program directory, enter:

cd Desktop/
  1. Run the program by entering:

python3 OledSensorDemo.py

4.2.2 Project Outcome

The text “1234” is displayed on the OLED display.

4.2.3 Program Brief Analysis

  • Import Libraries

from luma.core.interface.serial import i2c, spi
from luma.core.render import canvas
from luma.oled.device import ssd1306, ssd1325, ssd1331, sh1106

Import the library files required by the program.

  • Initialization Operation

serial = i2c(port=1, address=0x3C)
device = ssd1306(serial, width=128,height=32)

Initialize the communication object serial, set serial to IIC communication, and the address is 0x3C. Configure the display object device using the ssd1306 class, setting the length to 128 pixels and the width to 32 pixels. (Be sure to set the length and width, otherwise the display will be incomplete.)

  • Main Program

while(1):
    with canvas(device) as draw:
        draw.text((1, 1), "1234", fill="white") # Display "Hello World" at column 30, row 10 in white (将Hello World显示在屏幕第30列、第10行,显示的内容颜色为white(白色))
# Note: This screen cannot show white; it will display the current LED color instead (但该屏幕无法呈现白色,只能显示当前LED灯的颜色)

Within the while loop, set the configured device object as the canvas, and start drawing at position (1,1) to display the number “1234” with white font color.

Finally, run the program to see “1234” displayed on the OLED screen.