Skip to content

1.7 Basic Commands for Using the Smart Pi One Board

Introduction

The Smart Pi One board runs on Debian with Armbian, a distribution optimized for Single Board Computers (SBCs). This guide provides essential commands to manage the board, focusing on GPIO control, network configuration, and basic system management.

1. System Update

Before configuring the board, it’s crucial to update the system for the latest security patches and package updates:

sudo apt update && sudo apt upgrade -y           

2. System Information

To check hardware specifications and active services on the Smart Pi One board, here are some useful commands:

  • Check the Armbian version:

    armbianmonitor -u
    

  • Get information about the board and CPU:

    cat /proc/cpuinfo
    

  • Check available memory:

    free -h
    

  • Monitor disk usage:

    df -h
    

3. GPIO Management with SmartPi-GPIO

The Smart Pi One board allows control of GPIO pins for connecting sensors, LEDs, etc. SmartPi-GPIO provides a Python-based interface to manage GPIO, PWM, and interrupts efficiently.

  • Install SmartPi-GPIO (if not already installed):

    pip3 install smartpi-gpio
    

  • To view the available GPIO pins and their states:

    gpio readall
    

  • Configuring a GPIO pin as an output (e.g., GPIO 18):

    gpio setmode 18 out
    

  • Writing a high or low state to a GPIO pin:

    gpio write 18 1  # Set pin 18 to HIGH
    gpio write 18 0  # Set pin 18 to LOW
    

  • Using PWM on a pin (e.g., GPIO 19):

    gpio pwm 19 1000 50  # Set PWM frequency to 1 kHz and duty cycle to 50%
    

4. Enabling and Configuring I2C

I2C is used for connecting sensors and peripherals. To enable and configure I2C:

  • Enable I2C:

    sudo armbian-config
    # Navigate to System > Hardware > Enable I2C
    

  • Install I2C tools:

    sudo apt install i2c-tools
    

  • Scan connected I2C devices:

    i2cdetect -y 1
    

5. Enabling and Configuring SPI

SPI is another interface used for fast communication with external devices.

  • Enable SPI via Armbian Config:

    sudo armbian-config
    # Navigate to System > Hardware > Enable SPI
    

  • Check SPI interface:

    ls /dev/spidev*
    

6. Managing Services and Autostart

Armbian uses systemd to manage services. You can start, stop, and enable services at boot with the following commands:

  • Check the status of a service (e.g., SSH):

    sudo systemctl status ssh
    

  • Start a service:

    sudo systemctl start ssh
    

  • Enable a service at boot:

    sudo systemctl enable ssh
    

  • Disable a service:

    sudo systemctl disable ssh
    

7. Basic Network Configuration

For configuring Internet access or handling network settings, here are some basic commands:

  • View network interfaces:

    ip a
    

  • Set a static IP address (edit configuration as needed):

    sudo nano /etc/network/interfaces
    

  • Restart the network after changes:

    sudo systemctl restart networking
    

8. Obtain the IP Address

To find the IP address of your Smart Pi One board, you can use the following commands:

  • Display the IP address of network interfaces:

    ip a
    

  • Display only the IP address of the main interface (e.g., eth0 or wlan0):

    hostname -I
    

9. Display and Modify the Hostname

To view and change the name of your Smart Pi One board:

  • Display the current hostname:

    hostname
    

  • Edit the hostname file:

    sudo nano /etc/hostname
    
    Replace the content with the desired new name, then save and exit the editor.

  • Edit the hosts file:

    sudo nano /etc/hosts
    
    Update the line containing the old hostname with the new name.

  • Restart the system to apply the changes:

    sudo reboot
    

10. Managing Real-Time Clock (RTC)

To enable and configure an external RTC module:

  • Load the RTC module:

    sudo modprobe rtc-ds1307
    

  • Synchronize the hardware clock with the system clock:

    sudo hwclock -s
    

11. Modify a File

To edit a configuration file (e.g., using nano):

sudo nano /path/to/file
Replace /path/to/file with the actual path of the file you want to edit.

12. Shutdown and Reboot

To safely power off the Smart Pi One:

sudo shutdown now

To restart the Smart Pi One:

sudo reboot