-
Notifications
You must be signed in to change notification settings - Fork 21
operation
The pigrow is a series of small scripts which run on the raspberry pi, these are mostly run by cron at set times, triggered when sensor values change, buttons are pushed or they can be run remotely via the gui, phoneapp, or similar.
pigrow_config.txt is the main config file used by the pigrow software, this includes the locations and configuration of all the sensors and devices the pigrow is controlling as well as information required by the pigrow system itself.
The name of the pigrow used for identification when connecting with the gui
box_name=<pigrow name>
when connecting with the gui it will set the local folder used to store files downloaded from the pigrow to /frompigrow/<box_name>/
To use a sensor it must first be configured using the GUI, the dependencies must be installed then simply select it from the list in the sensors tab and press add, each sensor has it's own guide that can be viewed in the add sensor dialogue box of the gui or found in the resources/guides section of the repository.
This information is saved to the pigrow config file, a typical sensor will look like this;
sensor_bmetemp_type=bme280new
sensor_bmetemp_log=/home/pi/Pigrow/logs/bme280new_log.txt
sensor_bmetemp_loc=0x76
The sensor is named 'bmetemp' which is how it will show up in the GUI, it's type is a bme280new which means will use sensor_bme280new.py found in the sensor modules folder, on running it will append a line to the log 'bme280_new.txt' in the pigrow logs folder and it's location on the i2c bridge is at 0x76.
- Other sensors may also require extra information, this will be covered in the associated sensor module documentation
Once the sensor is set up and it's details saved to the config it can be called to write a log entry using the command
/home/<USERNAME>/Pigrow/scripts/sensors/log_sensor_module.py name=bmetemp
The add sensor dialogue box will create a repeating cron job which calls this sensor at the set interval to create a log of all the recorded values. This can be used to create graphs and to control triggers to send alerts or activate devices.
There are various ways of control devices with the pigrow, the most common is simple relay control where the raspberry pi triggers a relay to turn on or off a device like a lamp, heater, or humidifier.
It's also possible to control motors using H-bridge control, hardware and software PWM, or through external module which can be useful when controlling switches, pumps, window opening, or etc.
Relay modules are simple devices that act as switches for powered devices, the easiest way to use them is to wire them to the live wire of a plug so the flow can be connected or disconnected thus turning the plug on or off as required. Relays are controlled with a single GPIO pin set to output mode and set as HIGH (3.3V) or LOW (GND), there are several ways of controlling a relay with the pigrow.
- setting up relay
(section not yet written, it's super simple tho just use the gui)
Used for devices like lamps which are turned on and off at a set times
- timing
(also not written)
- resetting relays when the system reboots.
When using simple cron timing to control a relay it's important to have the script startup_set_relays.py run when the raspberry pi turns on, this script is run automatically when trigger_watcher.py starts, if you are not using trigger_watcher.py this can done via a cron @reboot job, which can be added via the gui, in the cron file it will read;
@reboot /home/_<username>_/Pigrow/scripts/autorun/startup_set_relays.py
This script looks for daily timed relay control jobs in cron, these are jobs that appear in cron as;
30 7 * * * /home/_<username>_/Pigrow/scripts/switches/lamp_on.py
30 19 * * * /home/_<username>_/Pigrow/scripts/switches/lamp_off.py
This looks for devices that are turned _on and _off daily, it checks to see if the current time falls within the on or off window and triggers the relay as appropriate.
These read the log and look for changes that take things above a set value, for example the temperature rising above 25 C might be used to trigger the fans switching to high-power mode, falling below 15 might turn on the heater.
Devices can be controlled using log triggers, these use trigger_watcher.py to monitor logs in the Pigrow/logs folder and call a script when the selected value crosses the selected threshold.
trigger_watcher.py should be started at boot by cron.