-
-
Notifications
You must be signed in to change notification settings - Fork 156
Installation
- A suitable SD memory card that has been flashed with an up to date rev of the Raspbian operating system. See the Raspberry Pi Quick Start Guide for instructions. Be sure the system is properly set up with the correct time zone for your location.
- An internet connection
Note: If you are running a resent full version of the Raspbian operating system, git should already be installed. You can test this by typing 'git' (without quotes) in a terminal window. If git is installed you will see a help screen showing git commands. If you are running Raspbian Lite or if git does not appear to be installed follow these instructions.
With the Raspberry Pi connected to the internet, open a terminal window (command line). enter the following command:
sudo apt-get install git
After a couple of seconds, you may be asked if you want to proceed, answer yes by typing y and the installation should finish within a minute or two.
Be sure you are in the Pi user's home directory (pi@raspberrypi ~ $). Clone the SIP directory from GitHub by issuing the following command:
git clone https://github.com/Dan-in-CA/SIP
The program is now installed and ready to run. To start the program execute:
cd SIP sudo python3 sip.py
-
Open a terminal window or connect to the pi via ssh.
-
Type the command:
git clone https://github.com/Dan-in-CA/SIP
followed by the enter key.
The program file should start downloading from the GitHub server.
If you get an error message, carefully retype the command and double check that it is exactly as shown above. Also be sure the pi is connected to the internet.
-
Check that the SIP directory was created in the proper location by typing ls (that's lower case LS). You should see the directory (SIP) listed as a sub-directory.
-
Log into the SIP sub-directory by typing:
cd SIP
followed by the enter key.
-
start the program by typing the following command:
sudo python3 sip.py
followed by the enter key.
You should see a message from the program “Starting timing loop” and a URL.
On a device connected to your local network, enter the URL of your Raspberry Pi. For example, on my test system, the URL would be http://192.168.1.22. The URL of your Raspberry Pi will be different.
You should now see SIP's home page in your browser. Congratulations! The program is now installed and running.
Note: If you start the program while logged in via SSH and then log out of SSH, the program will be stopped. If you then try to access the program from your browser you will get an error message.
Once the program is installed, you will probably want it to start automatically when the Raspberry Pi boots up. This will ensure that the program will be running even after recovering from a power outage.
There are a couple of ways to accomplish this. The simplest is to add some start-up commands to a file named “rc.local” which is in a directory named “/etc”. However, the recommended method for recent versions of Raspbian (jessie) is to use a script in /etc/systemd.
Here's the best way to automatically start SIP on boot instead of using /etc/rc.local. This is the preferred method and two files (sip.service and sip3.service) are included with the program distribution to make setup easy.
The advantage of using a systemd script is that you can easily stop, start, and check the status of SIP. Since /etc/rc.local is only executed on boot up, it's a little awkward to stop sip.py and start it again without rebooting or a typing bunch of commands.
-
Copy one of the script files to /etc/systemd/system.
To Run SIP under Python 2
Run the command:sudo cp SIP/sip.service /etc/systemd/system/
To run SIP under Python 3
Run the command:sudo cp SIP/sip3.service /etc/systemd/system/
For Python 3 you will also need to install the Python 3 version of RPi.GPIO:
sudo apt install python3-rpi.gpio
If this is not installed SIP will run but no stations will be activated under Python 3.
-
Enable sip service:
For Python 2:sudo systemctl enable sip.service
For Python 3:
sudo systemctl enable sip3.service
-
Reboot the Pi:
sudo reboot
After the Pi has rebooted you should be able to go to the URL of your Pi from a device connected to your local network and access SIP's web interface.
If you open a terminal window on the Pi, or access the Pi via ssh you will not see any indication that the program is running. It started as “root” and is not visible to the standard Pi user. You can use the Pi as if the program wasn't running but be aware that a lot of additional activity may cause timing problems with SIP.
If you want to disable the auto-start, use:
For Python 2
sudo systemctl disable sip.service
For Python 3
sudo systemctl disable sip3.service
If you are developing new features in the code you will find the restart command (see below) a quick way to check your changes.
Note: if you are running SIP under Python 3 use sip3 in the following commands.
You can check if sip is running by executing the command:
systemctl status sip
To start sip, execute:
sudo systemctl start sip
To stop sip, execute:
sudo systemctl stop sip
To quickly restart the program after making changes, execute:
sudo systemctl restart sip
-
Edit the file /etc/rc.local and add the following before the “exit 0” line:
### Start the SIP interval program cd /home/pi/SIP/ python sip.py &
-
Reboot the Pi.
sudo reboot
Nano is the name of a light weight text editor that is included with the Raspbian operating system. It is used to edit various configuration files including the rc.local file that can be used to start sip when the Pi boots up.
-
In a terminal window type the following command:
sudo nano /etc/rc.local
followed by the enter key.
This will open the file in the editor.
You can use the keyboard arrow keys to move around and the Enter key to add new lines in the editor.
Use the down arrow key on your keyboard to move the cursor (which appears as a highlighted box) down past most of the text to a blank line just before the line “exit 0”.
-
Carefully type in the following:
### Start the SIP interval program cd /home/pi/SIP/ python sip.py &
Be sure to include all spaces and punctuation just as shown above.
The first line is a comment that is there as a reminder of what the code does but doesn't actually perform any action.
The third line is what actually starts the interval program. If you ever need to disable the automatic start, you can “comment out” this line by editing the file and placing a # character at the start of the line. You can then re-enable automatic start by removing the # character.
-
After you have entered the lines as shown above, save the file by typing Ctrl + o. (that's the control key and the letter o together) followed by the Enter key.
-
Exit the editor by typing Ctrl + x.
-
Once you have exited the editor, reboot the Pi by typing:
sudo reboot
followed by the Enter key.
The logging feature included with SIP is disabled by default. This is to prevent the uncontrolled accumulation of log data.
Click the “Options” button at the top of the page. On the Options page click the triangle next to "Log" on the menu. You will be presented with a dialog containing a check box for enabling the feature.
It is set to 100 records by default but you can change the value to whatever you like. When the maximum number of records has been reached, new records will continue to be added to the top of the list and the oldest records deleted from the bottom.
Setting the maximum to zero (no maximum) will allow records to accumulate until all available storage space is filled. This may effect system performance if the number of records becomes very large but it has been tested with over 1100 records without a noticeable problem. A practical setting might be the number of records you would get in a period of time such as a week or a month.
The Log page contains a link that allows you to download log data as a spread sheet friendly, comma separated values, (csv) text file to another device, e. g. a laptop. This provides a means of keeping a permanent archive of irrigation data in manageable size chunks. Once the file has been downloaded it can be imported in to your favorite spread sheet program for viewing, sorting, etc.