Given the requirement of monitoring the temperature and humidity inside the greenhouse and the great variation in area between various types of greenhouses, the environment sensing system must be distributed across various nodes, the number of which will depend on the specific greenhouse dimensions. On the other hand, for monitoring the water quality and controlling the pump, one central node is sufficient. The iPONICS system concept is shown in
Figure 1.
The system is composed of three types of nodes: the sensing and control unit (SCU), the environment sensing unit (ESN) and the greenhouse security unit (GSN). The greenhouse unit (GHU) is a greenhouse containing one SCU, which is the master node and several ESN and GSN “slave nodes”, the number of which depends on the dimensions of the greenhouse.
3.1. Sense and Control Unit (SCU)
The SCU is the main (master) node, as well as the central node in the star topology of the WSN. It is responsible for measuring the circulating water quality through four sensors, namely, temperature, pH, water electrical conductivity (EC) and dissolved oxygen (DO). Furthermore, it is responsible for controlling the pump in an efficient manner by conserving energy while maintaining the required water flow for crops growth and requesting and receiving data from the slave nodes.
The sensors used were from Atlas Scientific [
22,
23,
24,
25]. The reasons for selecting these particular sensors were the following: First, they require infrequent recalibration, which is convenient while being deployed in a greenhouse during plant growth, which requires weeks to months. Second, they are easily integrated into an Arduino-based microcontroller system, reducing the development time and time-to-market. Third, they are long lasting at a reasonable cost, which are essential attributes in order to keep the overall cost of the system an attractive investment for farmers.
The SCU processing unit used was an Arduino Mega 2560, providing the required processing power, program memory and number of pins to support the following connections: the Xbee shield, the RTC shield, the Atlas Scientific EZO circuits, the GSM shield, the voltage sensor and, finally, the relay module to control the ON/OFF switching of the water pumps. All the shields and modules were supplied by the power drawn out of the Arduino by the 5v and GND pins.
Figure 3 depicts the schematic of the SCU, while
Figure 4 illustrates its operation using a flowchart.
As shown in
Figure 4, the SCU starts by initializing the serial and I2C communications and verifying that all modules are connected. In order to preserve energy, the microcontroller is put to sleep, along with the GSM shield since it is the highest power-consuming module. The microcontroller awakes in the following cases:
An “Alarm_Interrupt” that signals abnormal and possibly hazardous temperature/humidity readings in which the SCU activates the GSM to send an alarm SMS/email and upload these readings to the server. In this case, the system demands operator intervention and does not return to sleep or activate the pump.
A “Security_Interrupt” that signals unauthorized access to the site in which the SCU activates the GSM to send a security SMS/email and upload the captured images to the server before returning to sleep.
The SCU reaches the sampling time of water quality sensors in which it collects those readings temporally in the EEPROM. Afterwards, it activates the GSM shield and proceeds uploading the water quality readings, and then wakes up one ESN at a time and uploads its readings to the server. It returns to sleep afterward.
The SCU wakes up at fixed intervals for the pump control in which the state of the battery, along with the latest water quality readings, dictate the powering decision before returning to sleep.
Since the entire system is meant to be off-grid, it is crucial to minimize the power consumption of the units connected to the solar-charged battery whenever possible to guarantee uptime. The use of the sleep mode and intelligent control of the water pumps ensures moderate usage of the power resources. We measured the current drawn by the SCU under the operating conditions listed in
Table 3 using both a multimeter and a current clamp. As it can be seen in
Table 3, the SCU consumed around 1.25 W while sleeping, where the GSM was off and the microcontroller was in deep sleep mode. Other connected modules were still powered including the Xbee shield, as interrupts are asynchronous. In the idle state, the Arduino was awake to regularly do the water quality readings or control the water pump, where it consumed about 1.35 W. The power consumption almost doubled when the GSM shield was activated for transmission, where it consumed about 2.75 W. This could rise to 11.5 W given that the transmission is occurring under extreme weather conditions or a weak network connection, which caused the GSM to draw higher currents. On the positive side, without interruption, the GSM stayed off until the upload time, which happened a few times a day.
Figure 5 shows an SCU prototype.
The maximum power (last entry in
Table 3) was only consumed when the GSM module is first registered to the network. During normal operation, the SCU slept and consumed 1.25 W while consuming 2.75 W when transmitting data. Therefore, the SCU energy consumption per cycle was
where
T is the sleep period and
t is the execution time of the main loop (
Appendix A). Essentially the sleep mode power was multiplied by the duration of the sleep period and the transmission power was multiplied by the time it took to transmit the data.
The execution time was measured in milliseconds by counting the processor cycles. The execution of the main loop with no ESNs present was 19,170 ms. With one ESN, the main loop execution time was 145,090 ms. Since all ESNs transmitted the same amount of data, the execution time was given by the formula:
Equation (2) also indirectly defines an upper bound in the sampling rate of the system, depending on the number of ESNs available. However, such a high sampling rate is not required since it takes at least hours for the water quality parameters to significantly change (when plants absorb nutrients) and, at most, days when most nutrients have been absorbed.
3.2. Environment Sensing Node (ESN)
Environment sensing nodes are slave nodes that are responsible for monitoring greenhouse environmental conditions, such as the ambient temperature and humidity. The necessity behind the ESNs is that abnormal temperature and humidity could imply a hazard, such as a fire. Therefore, the temperature is monitored every few minutes, but temperature and humidity readings are permanently stored on an hourly basis in an SD card. The ESN is interrupted by the SCU and then transmits the data to the SCU using Zigbee unless there is an alarm (high temperature), in which case, the ESN does not wait for an interrupt. This allows for effective monitoring of the greenhouse environment while minimizing data transmission and, therefore, power consumption. The number of ESNs present in each greenhouse is dependent on the greenhouse dimensions. Each ESN has its own ID number and Zigbee address.
Figure 6 depicts the schematic diagram of the ESN circuit.
The ESN initialization procedure includes initializing the serial and SPI communication (
Figure 7) and verifying the connection to all modules. After initialization, the ESN awakes on fixed intervals to collect the ambient temperature and humidity readings and record them on the SD card. If no abnormal readings are present, the ESN remains asleep until interrupted by the SCU when it is time for data collection. On the occurrence of the abnormal readings, the ESN interrupts the SCU with a Zigbee packet payload “Alarm_Interrupt_XX”. The “XX” is a code representing either “FIRE” or “Connection” to distinguish whether the alarm is due to high temperature due to a possible fire in the greenhouse or just a connection problem.
The ESN power consumption in sleep mode was approximately 0.4 W compared with approximately 0.55 W during data transmission. However, as mentioned earlier in the SCU subsection (
Section 3.1), the transmission only occurs a few times a day, unless there is an alarm. In both modes, the Xbee module stays active as it is an end device to be interrupted by the SCU.
3.3. Greenhouse Security Node (GSN)
As discussed in
Section 2, the GSN was developed as a rudimentary security node and is not essential for the operation of the iPONICS system. It comprises a microcontroller with a motion sensor, camera, SD card and Zigbee transmitter/receiver. The reason such a node may be used is that a greenhouse could be in an isolated area, and we wish to prevent unauthorized entry. It is not meant to be a robust security solution, merely a low-cost warning system. The node spends the majority of time sleeping to conserve energy under normal circumstances. It is woken up by an external interrupt from the motion sensor, in which case, it activates the camera to take pictures and sends an alarm to the SCU through Zigbee. In the case of an authorized user accessing the system, the RFID is used to cancel the alarm. GSNs can also be deactivated and reactivated when receiving a command from the SCU. The microcontroller used for the implementation of the GSN was Arduino UNO, similar to the ESN.
Figure 8 depicts the schematic diagram of the node’s circuitry.
Figure 9 shows a flowchart of the GSN operation. As shown in
Figure 9, the node starts by initializing the I2C and SPI communications and ensures proper wiring of the modules. Then, the node falls into sleep mode and remains in that state until motion is detected. After such an event, the node expects an authorized ID tag swap. If no such verification of the identity of the user occurs in the next few seconds, the GSN interrupts the SCU and signals a “Security_Interrupt” inside the first payload, followed by the images that are data captured by the node. The GSN draws power of about 0.53 W in sleep mode and about 0.68 W during transmission depending on the distance from the SCU.
3.4. SCU Fuzzy Inference Engine
An important novelty of the iPONICS method is the SCU FIE [
26]. We describe here the design of the control algorithm separately from the rest of the SCU for clarity. There are several reasons for using FLC in iPONICS. First, we have to manage imprecision from sensor errors. Second, the ideal values for pH and electrical conductivity vary slightly between plants (
Table 1), and we can accommodate several crops with the same controller by fuzzifying the inputs.
The architecture of the FIE is shown in
Figure 10. It accepts three inputs: pH, EC and power supply voltage level. Since the power supply is from the battery being charged by a solar cell, the voltage level reflects the battery level according to the voltage/charge curve. The DO and water temperature are not used for two reasons: first, they are not documented in the literature to have a significant effect on efficient hydroponic culture, and second, using five or six outputs would require a large number of rules, most of which would be redundant. The FIE determines the irrigation duration based on the critical hydroponic parameters and the available energy. The general premise behind the knowledge base of the proposed scheme is to provide the available nutrients to the plants while being conservative with watering when energy and nutrients are low.
According to hydroponics guidelines, the irrigation duration is given as follows [
21]:
where
: irrigation duration in seconds,
Q: irrigation dose (lt/bucket),
m: number of drip lines per bucket and
q: drip emission (lt/h) (
Appendix A). We applied this formula as our baseline duration to determine our fuzzy set membership functions.
The rationale behind using FLC for controlling the pump stems from the use of an expert system based on linguistic if–then rules for the pump on/off duration, coupled with inherent uncertainty and errors in sensor readings and different parameters for different crops. The above constitute fuzzy modeling as an ideal fit for the proposed system. By abstracting the inputs and outputs using fuzzy sets, more robust control can be achieved.
Figure 11 shows the fuzzy membership functions. In order to maintain computational simplicity, we selected trapezoidal and triangular membership functions in the proposed control scheme to describe the linguistic values of the fuzzy input and output variables. The amount of overlap between the membership functions areas was chosen to have at most two membership functions overlapping; thus, we will never have more than six rules activated at a given time. This offers computational simplicity in the implementation of the proposed scheme, which was a design objective. Furthermore, it does not make intuitive sense to have a parameter such as pH being considered as both high and low according to hydroponics guidelines. The EC and pH membership functions were determined based on hydroponics guidelines, while the voltage was based on extending battery life. The irrigation duration membership functions were based on multiples of the baseline irrigation duration from Equation (3). In the case of clearly erroneous sensor values (
Section 4.2), the values are not fed to the FIE; instead, the last valid values are used. If the pH and EC values seem correct they are fed to the FIE and the last valid values are updated for the next sensor reading.
The fuzzy rule base was determined based on hydroponics guidelines. As mentioned, three inputs are used, with three membership functions per input. Therefore, there are a total of 3
3 = 27 rules. The rules were determined empirically according to the principle that when conditions are ideal, the irrigation period is the one determined by Equation (3). When conditions are suboptimal, especially when the input voltage is low, indicating the battery is discharged, the irrigation duration is shortened in order to conserve energy. When EC and pH indicate that there are few nutrients to be absorbed, then the irrigation period is also shortened. The forms of the rules with some indicative cases are shown in
Table 4.
The execution time of the FIE was measured to be 3326 ms, which is included in the SCU main loop execution time reported in
Section 3.1.