The first Python code that we run deals soley with monitoring the switch state of the float switches and activating the water solenoid valve at the right times (when the Tanks are Full the mains water solenoid valve closes .... when the Tanks are Empty the mains water solenoid valve opens)
As I mentioned in the Introduction to this project I dont proffess to being a Python programmer by any means, but I can promise that any code that appears in this project will work. If there are any programmers out there that feel the need to have a tidy up - or make changes for the better of the project, you are more than welcome to do so.
The video at the end of this section will summarise how to get the code running, but for now try out the following steps;
1 - The first thing you need to do is copy the code below and save it somewhere on your Raspbery Pi, alternatively download it from GitHub via the link provided. As this is going to be modified during the project save the file as Garden_Irrigation1.py
2 - On your Raspberry Pi's desktop you will see an IDLE icon, double click IDLE and the Python Shell window will open
3 - In Python Shell click on File -> Open ... and locate the code that you have just saved
4 - Once you have opened Garden_Irrigation1.py - on the menubar click Run -> Run Module
You should now be up and running, and providing that all of your floats (switches) are in a closed state you should see a 'Solenoid Valve Closed' message that self updates itself. Toggle through each of the switches, turning them off one at a time and you will see the status messages change. Once you have switched off the last switch (Tank 1 - L/L) you will see that the PiFace LED associated with Output 1 lights up, and the changeover relay operates.
The above details all you need to know to be able to run your code in IDLE, but as we progress you will see that there are times when it is much easier to run code using Python's Interactive Mode. The next few steps show how this is achieved;
5 - In Linux Terminal change directory to the location where you saved Garden_Irrigation1.py
at the command promp type $ cd path/to/Garden_Irrigation1.py
Once you have changed directory to the location of the file, at the command prompt
type $ python
Python will now execute and you will be taken to the Python primary prompt
type >>> execfile('Garden_Irrigation1.py')
You should now see the code running in your Terminal window exactly as we saw in Step 4 above.
To exit Python - press Ctrl - D
In the next few sections I will be putting the Raspberry Pi and PiFace to one side and focusing on one of the key elements of this project, Twitter Alerts.