Configuration File - Progradius/PhytoController GitHub Wiki
The param.json configuration file
For now, this project use a JSON file to handle his configuration.
This is for several reasons:
- Centralizing settings and share them through the code
- Not writing sensitive information directly in the code
- Provide a comprehensive way to configure the system for the user
I know this is not optimal in term of user experience, and that's why I'll later implement at least a python script to do that job in an user-friendly way.
A note on JSON Syntax:
Before jumping into the jungle, a quick reminder of how the JSON format works. JSON stands for JavaScript Object Notation and is a data format. It's written in the form of key/value pair with this syntax:
{"key1": "value1", "key2": "value2"}
In this project we'll use only strings and numerical values, strings are enclosed by double quotes, and numbers are written without nothing around.
I recommend you to read this tutorial if all of this seems obscure:
Breakdown of the config file:
REMEMBER ABOUT THE KEY/VALUE PAIRS CONCEPT
STRING AND INTEGER ONLY
FOR CONFIGURATION PURPOSE, NEVER MODIFY A KEY
Full view of the default file:
Sections are represented by a line with key "==Text_Here=="
These lines are only here to help the user, and can be removed if necessary.
Detail about the sections can be found below.
{ "==LifeCycle_Configuration==": "",
"growth_stage": "veg",
"==DailyTimer_Configuration==": "",
"dailytimer1_start_hour": 17,"dailytimer1_start_minute": 0,
"dailytimer1_stop_hour": 11, "dailytimer1_stop_minute": 0,
"dailytimer2_start_hour": 17,"dailytimer2_start_minute": 0,
"dailytimer2_stop_hour": 11, "dailytimer2_stop_minute": 0,
"==CyclicTimer_Configuration==": "",
"cyclic1_period_minutes": 2, "cyclic1_action_duration_seconds": 30,
"cyclic2_period_minutes": 60, "cyclic2_action_duration_seconds": 30,
"==Wifi_and_Influx_Configuration==": "",
"wifi_ssid": "", "wifi_password": "",
"influx_db_name": "", "influx_db_user": "",
"influx_db_password": "", "influx_db_host": "",
"==Sensor_Related_Pin_Configuration==": "",
"i2c_sda":21, "i2c_scl":22, "ds18_pin": 23, "hcsr_trigger_pin": 26, "hcsr_echo_pin": 27,
"==Timer_Driven_Components_Configuration==": "",
"light1_pin": 17, "light2_pin": 18,
"cyclic1_pin": 5, "cyclic2_pin": 16,
"==Motor_and_Temperature_Configuration==": "",
"motor_pin1": 32, "motor_pin2": 33, "motor_pin3": 14, "motor_pin4": 25,
"motor_mode": "auto", "motor_user_speed": 2,
"target_temp": 24, "hysteresis": 2, "min_speed": 1, "max_speed": 4,
"==Sensor_States_Configuration==": "",
"bme_state": "disabled", "ds18_state": "enabled", "veml_state": "disabled", "vl53_state": "disabled",
"mlx_state": "disabled", "tsl_state": "disabled", "hcsr_state": "disabled"
}
Down the rabbit hole:
-
==LifeCycle_Configuration==
The "growth_stage" key hold the current lifecycle of the monitored environment (not implemented yet)
-
==DailyTimer_Configuration==
In this section you can configure two daily timers, dailytimer1 and dailytimer2.
Each one has four parameters, start_hour start_minute stop_hour and stop_hour
Set the time, in 24 format according to your needs.
A valid time is required
"dailytimer1_start_hour": 19,"dailytimer1_start_minute": 30, "dailytimer1_stop_hour": 13, "dailytimer1_stop_minute": 30, "dailytimer2_start_hour": 17,"dailytimer2_start_minute": 45, "dailytimer2_stop_hour": 11, "dailytimer2_stop_minute": 45,
-
==CyclicTimer_Configuration==
In this section you can configure two cyclic timer, cyclic1 et cyclic2
Each one has two properties "action_duration" and "period"
period represent the cycle/period you want an event to happen
action_duration represent the amount of time you want an an event to be
e.g. I want cyclic1 to happen every 10 minutes and his action to be 45 seconds long
"cyclic1_period_minutes": 10, "cyclic1_action_duration_seconds": 45,
-
==Wifi_and_Influx_Configuration==
In this section, you can configure your wifi credentials and configure influx
Enter your wifi SSID and password in the corresponding fields
Enter the influx's database name created while the installation, as long as the user and password. The influx's host is your host machine address on port 8086
"wifi_ssid": "YOUR_WIFI_SSID", "wifi_password": "hunter2", "influx_db_name": "DATABASENAMEHERE", "influx_db_user": "DBUSERHERE", "influx_db_password": "Mr_Goodbytes", "influx_db_host": "http://192.168.1.10:8086",
-
==Sensor_Related_Pin_Configuration==
In this section you can configure the GPIO to your liking/hardware.
Check your hardware's pin-out and choose the GPIO used for the following:
- I2C bus: two GPIO (scl and sda)
- 1-Wire bus: one GPIO (for DS18B20 sensors)
- HCSR04 sensor pins: two GPIO (echo and trigger)
Example taken from default state:
"i2c_sda":21, "i2c_scl":22, "ds18_pin": 23, "hcsr_trigger_pin": 26, "hcsr_echo_pin": 27,
-
==Timer_Driven_Components_Configuration==
In this section you can configure the four outlets, driven by the daily and cyclic timers. These outlet are represented by one GPIO each, who's handling it's own relay/outlet pair on the relay board.
Choose you own GPIO according to your hardware.
Example taken from default state:
"light1_pin": 17, "light2_pin": 18, "cyclic1_pin": 5, "cyclic2_pin": 16,
-
==Motor_and_Temperature_Configuration==
In this section you can configure motor's speed pin and settings related to temperature control
- To drive motor's speed we need four GPIO, choose them according to your hardware
"motor_pin1": 32, "motor_pin2": 33, "motor_pin3": 14, "motor_pin4": 25,
- Temperature control has two modes, "auto" where the hardware is handling speed based on temperature sensor data, and a "manual" mode where the user define a constant speed.
The user's speed is only used in manual mode. Choose a speed (integer between 1 and 4)
"motor_mode": "auto", "motor_user_speed": 2,
- Auto mode configuration For the auto mode, choose a target speed and the hysteresis (the value added or subtracted to the temperature before an action is taken), then choose a mini and maxi speed in case you want to restrain the range (integer between 1 and 4)
"target_temp": 24, "hysteresis": 2, "min_speed": 1, "max_speed": 4,
-
==Sensor_States_Configuration==
In this section you can configure the wired sensors you have available on your hardware.
Just set the corresponding field to "enabled" or "disabled" (by default only the DS18B20 is enabled)
"bme_state": "disabled", "ds18_state": "enabled", "veml_state": "disabled", "vl53_state": "disabled", "mlx_state": "disabled", "tsl_state": "disabled", "hcsr_state": "disabled"