CantlinMath.com Home

Mr. C.'s
Raspberry Pi Page!
Desmos ~  Symbolab ~  WolframAlpha
RaspberryPi.org - Home  ~  Mr. C.'s Python Page

General Raspberry Pi Sites:
Headless RPi Related:
  • Adafruit RPi B+ Headless via Ethernet Product Wishlist
  • General Tutorials:
  • Headless RPi Blink LED via Python and VNC Server-Viewer/XFCE Desktop/IDLE Python IDE Step-By-Step Setup aka RPi Blinky Program:
    1. Watch Mr. C.'s Video:Headless RPi Setup
    2. Do this: Headless RPi Setup Connect via SSH file using Putty - HackerNoon.com
      • Supporting Information: How to Create a File With No Extension Using Notepad *you will need this*
      • I configured my router to always give the RPi the same local IP number aka a "static IP address" so I just enter once in Putty. I saved this static IP (mine is 192.168.1.129) in a Putty "session" file and just "Load" it when I want to use Putty to login to the RPi. Later- I will login using VNC Viewer and a desktop GUI (XFCE).
    3. Initial Configuration Using "sudo raspi-config" at CLI via Putty:
      • Read "raspi-config" at raspberrypi.org
      • "sudo raspi-config" tool options:
        1. Change User Password Do this. WRITE it down!
        2. Network Options I chaged my HOSTNAME.
        3. Boot Options I started with CLI login, changed to GUI login after XFCE install.
        4. Localisation Options Added en_US.UTF-8 UTF-8 not sure what conflicts having GB (default, Great Britain) also selected will arise, changed timezone, etc.
        5. Interfacing Options Enabled SSH, VNC (uses 168 mb) I2C, and GPIO remote access.
        6. Overclock Configure overclocking for your Pi
        7. Advanced Options I expanded filesystem. Set resolution to highest for VNC.
        8. Update Update this tool to the latest version
        9. About raspi-config Information about this configuration tool
    4. Updating everything and install desktop XFCE via CLI and Putty:
      1. Read the guide here then follow the below listed super user commands using Putty at the CLI (command line interface):
      2. sudo apt update
      3. sudo apt upgrade
      4. sudo apt dist-upgrade
      5. sudo reboot (restart Putty)
      6. sudo apt install xserver-xorg
      7. sudo apt install xfce4 xfce4-terminal
      8. sudo apt install lightdm
      9. sudo reboot (restart Putty)
    5. Install VNC Viewer on desktop
    6. Connect to RPi via VNC Viewer - see screenshot
    7. Initial Python Setup:
      1. Read "How to Install Python 3" at RaspberryPi.org
      2. Read "Installing Python Packages" at RaspberryPi.org then follow the below listed super user commands using Putty at the CLI (command line interface). If any of these are already installed it is OK. On completion, reboot into the XCFE desktop via the VNC client and the Python 3 IDE (called IDLE) should now be in your Application Menu (under Developer Tools):
      3. sudo apt update
      4. sudo apt install python3
      5. sudo apt install idle3
      6. sudo apt install python3-pip
      7. sudo reboot
    8. Python Hello World and Blinky:
      • Read RaspberryPiHQ - Blink RPi LED With Python
      • Read Sparkfun Tutorial: Python and the RPi
      • Read about the differences between using apt to install packages and using pip3 to install packages at raspberrypi.org. I don't really know what is best but I am going to try the following policy for now, if it is a unique or special Python package I will use pip3, if it is a general Linux package or a commonly used Python package, I will use apt. We may make exceptions to this policy for necessity or convenience.
      • Read Headless RPi and Blinky Using Python at FreeCodeCamp and GPIO Zero Python Library then follow the below listed steps to get the Python "Hello World and Blinky" program running:
        1. Login to the CLI with Putty and enter the following to verify Python 3 is being used by the OS: python --version
        2. If it is not version 3 (mine was not) enter the following to open the "bashrc" user configuration file with Nano: nano ~/.bashrc
        3. Then scroll/arrow to the bottom of the "bashrc" file (don't change anything else) and add the line: alias python='/usr/bin/python3'
        4. Use Ctrl-X to exit and Y to save. Logout of Putty, reboot the RPi (I use the USB power switch) and login via Putty and check the Python verion the OS is using. Mine was now 3.7.3.
        5. You can also verify the pip3 version you installed earlier is OK using: pip3 --version. PIP is the built-in package manager for Python libraries. It is, IMHO, very complicated (Pip Home). But for our purposes, we will simplfy things by only using Python 3, so use pip3 whenever pip is used in an example.
        6. Install the T-Cobbler (RPi OFF) and plug into your lomgest breadboard. Turn RPi on Verify the 3.3 v, 5 v, and Gnd pins with your multimeter. (see pic of Mr. C.s T-Cobbler while reading a 3.3 vdc pin)
        7. As shown in the FreeCodeCamp tutorial above, connect the longer lead (+) of an LED to GPIO Pin 25 (conveniently labeled 25 on T-Cobbler) and the shorter side of the LED (-) to the GND rail on your breadboard. Connect a GND pin on your T-Cobbler to the the same GND rail on your breadboard.
        8. To access the GPIO pins, of the several gpio packages available the FreeCodeCamp tutorial uses gpiozero, and uses apt to install, so install that via Putty and PIP3 using: sudo apt-get install python3-gpiozero. Note: the corresponding pip3 install would use: sudo pip3 install gpiozero.
        9. Finally we are ready to leave the CLI and use the VNC Viewer and do the rest of the steps to create a pi user folder for Python programs that will automatically have the right file permissions to write it and torun it. Then we will write and run the blinky program using IDLE. The essential steps are to launch VNC Viewer, log into the pi and get to the XFCE desktop. Use the XFCE File Manager to create a subfolder under the pi/home folder called bin. Open IDLE, copy/paste our blinky program test file in a "New File" (see Python text file code here), then Run it! It worked first time. See my video below!
        10. Watch Mr. C.'s Video: Writing/Running a Blink LED program via VNC Viewer (on Windows 10) connected to a Raqspberry Pi B Plus using the XCFE Desktop and IDLE.
  • Tools:
Python-GPIO Related:
Electronics Supersites and Suppliers:
Linux Apps/Commands:
Public Key Authentication: