Skip to content

3.2 Setup Your Pi and Serial Port

jgyates edited this page Jan 7, 2022 · 14 revisions

The quickest way to setup your pi and the software is to use the genmonmaint.sh script. This page has information on how to download the software and run the script.

The following is an example setup. Please note that there are often several ways to setup things in Linux (gui vs command line, different distributions, etc).

If you are new to using a Raspberry Pi and Linux please refer to other sources for coming up to speed with the environment. Having a base knowledge will go a long way. This site is a great place to start if you are new to these topic.

If you are not familiar with remote login commands for Linux/Unix, two useful commands if you are not using a GUI on your raspberry pi are "ssh" and "scp". These commands allow you to run your Pi without a monitor or user interface. These program allow you to remotely login to your Pi and remotely transfer files to your Pi. This page describes both programs. You can also do a web search on these programs to find other resources on their use. In short you need to have at minimum a basic understanding of using a command line, preferably some experience with Linux and the ability to transfer files to a Raspberry Pi and execute them.

The Raspberry Pi organization has documentation on installing an operating system on your Raspberry Pi. It is located here.

Assemble the Raspberry Pi and all the physical connections as per the schematic

Download SFD Formatter onto your PC or laptop and install this utility for setting up the mini SD Card. Raspberry Pi Operating System installation instructions are located here.

Insert the SD card into your PC and format the mini SD Card

Once complete, leave the SD card in your PC and go to https://www.raspberrypi.org/downloads/ and select a distribution (NOOBs or Raspbian) to download and extract the files from the zip. Copy all the files from the extracted folder to the SD Card

Eject the SD card from your PC or Laptop and insert into the PI ensuring that you have and HDMI monitor, usb keyboard and mouse connected to your unit. Power up the PI and let the installer setup the Raspberry Pi software. FYI – this takes a while and wait for the system to load. If you are using NOOBs then a GUI will be displayed. If you are using Raspbian Lite then a text based login will be displayed.

Connect network patch cable to the PI unit and setup your timezone, time and date. Click on terminal window >_ and then type the following:

 sudo raspi-config.
 Select Localisation Options.
 Select L2 Timezone.
 Select your Geographic area.
 Select your nearest City.
 Select Finish
 Type Reboot at the terminal window.

The remaining steps deal with setting up the raspberry pi serial port hardware. The program /OtherApps/serialconfig.py can perform the steps described below. It is documented on this page. You can setup your serial port manually in the steps below, or you can skip to downloading and installing the generator monitor software and then use the serialconfig.py program to setup the serial port.

You need to setup the serial port on the PI 3. Open the terminal window again and type

 sudo nano /boot/config.txt

and add the following line at the bottom:

 enable_uart=1

In some cases you may need to disable Bluetooth also, depending on your firmware revision in your Pi. To disable Bluetooth add the following to the bottom of /boot/config.txt:

dtoverlay=pi3-disable-bt

and then press ctrl-o to save the /boot/config.txt file, ctrl-x to exit nano.

Leave the terminal window open and confirm the name of the serial port of ttyAMA0 has the alias serial0. Type:

 ls –l /dev/serial*

and confirm that /dev/ttyAMA0 has an alias of /dev/serial0. The output should look like this:

 lrwxrwxrwx 1 root root 7 Apr 12 01:06 /dev/serial0 -> ttyAMA0
 lrwxrwxrwx 1 root root 5 Apr 12 01:06 /dev/serial1 -> ttyS0

If serial0 -> ttyS0 instead of serial0 -> ttyAMA0 then you may have attempted to enable the UART via raspi-config. This may cause interference with the console. The onboard serial port is ttyAMA0 and for compatibility reasons you should typically use the alias. In short, to user the onboard serial port with genmon you must user the alias mapped to ttyAMA0, not ttyS0.

Disable the console function of the serial port by typing :

 sudo systemctl stop [email protected]
 sudo systemctl disable [email protected]

Disable the BlueTooth service that access the serial port (if you have BT on your Pi)

 sudo systemctl disable hciuart

Now remove the console from the command line boot file. Type

 sudo nano /boot/cmdline.txt

and remove the text “console=serial0,115200. Press ctrl o and write the file

At the terminal window now type

 sudo reboot