Greenhouse Arduino Code
Greenhouse Arduino Code
The use of both DHT11 and LM35 provides redundancy and enhances accuracy in temperature measurement. The DHT11 is used primarily for measuring humidity but also gives a separate temperature reading, which can cross-verify the LM35 sensor's readings. This setup offers the system an additional layer of reliability and allows cross-referencing to ensure temperature accuracy, crucial for automating climate control systems and providing consistent environmental conditions for plant growth .
The greenhouse automation system uses several components including the LM35 temperature sensor, DHT11 for humidity and temperature, LDR for measuring light levels, a soil moisture sensor, a 16x2 LCD for display, a fan, and a pump. Each component serves a specific role: the LM35 and DHT11 measure temperature (ambiance and air, respectively), the LDR measures ambient light, the soil moisture sensor checks soil dryness, the LCD displays system status and readings, the fan manages temperature control by activating above 30°C, and the pump supplies water when soil moisture is below a set threshold .
The automation system uses two main thresholds: a temperature threshold set at 30°C and a soil moisture threshold set at an analog value of 500. If the temperature exceeds 30°C, the fan is triggered to turn on to cool down the environment. When the soil moisture level falls below 500, the pump is activated to water the plants. These thresholds ensure that the environment remains within optimal conditions for plant growth .
The delay function in the loop() causes the system to halt for 1.5 seconds, during which no inputs are read or outputs updated. While this simplifies timing management, it can impair system responsiveness, especially if environmental conditions change rapidly and require immediate intervention. In a dynamic system, using delay may not be ideal; alternatives like non-blocking delays using millis() can improve responsiveness and allow concurrent processing tasks, leading to more efficient and effective environmental management .
Currently, the LDR measures light levels but does not control any components. Future improvements could use light data to adjust parameters such as the opening/closing of blinds or to control supplementary lighting. By incorporating the LDR into a feedback loop, the system could maintain optimal lighting conditions automatically, facilitating better plant growth and adaptability based on time of day or weather conditions. This would enhance the system's efficiency and automate another aspect of environmental control .
The LCD is crucial for displaying real-time data about the greenhouse's environmental conditions, such as temperature, humidity, and status indicators for the fan and pump. It allows the user to have a visual interface with the ongoing processes without needing another device. Integrated via digital pins 12, 11, 5, 4, 3, and 2, it provides clear text output. The LCD is initialized in the setup(), and its display is updated in the loop() to show current sensor data and state information of the actuators every 1.5 seconds .
The Arduino reads input from several sensors: the DHT11 for humidity and temperature data, the LM35 for temperature, the LDR for light levels, and a soil moisture sensor for soil wetness. It processes these inputs and uses conditional logic to control outputs like the fan and the pump. If temperature exceeds 30°C, the Arduino sets the fan on, and if the soil moisture level is below 500, it activates the pump. Outputs are communicated via GPIO pins assigned to each component, with the fan and pump statuses being displayed on the LCD screen .
The Arduino program activates the fan when the temperature read by the LM35 exceeds 30°C. This decision is made using a simple conditional statement. Similarly, the pump is activated when the soil moisture level drops below a threshold value of 500. For each device, the system checks the current sensor readings against these thresholds; if the conditions are met, respective outputs are set high, turning on the fan or pump, otherwise, they remain low. This logical control ensures the system automates greenhouse climate stabilization and moisture maintenance .
In the greenhouse system, the DHT11 sensor is connected to digital pin 7 as it requires a precise digital signal input/output. The LM35, an analog sensor, uses pin A2, while the LDR and soil moisture sensors use pins A0 and A1, respectively, which are also analog inputs. The fan and pump control signals are output through pins 8 and 9, connected via transistors to power these components. LCD uses pins 12, 11, 5, 4, 3, and 2 for RS, E, D4, D5, D6, and D7 respectively, as these pins provide necessary controls for character data. Pin assignments are crucial as they ensure the correct communication paths and functionality of the connected components, maintaining organized and efficient data processing .
During the initialization phase, the program uses the LCD to communicate statuses. It first displays 'GREENHOUSE SYS' and then 'Initializing...' with delays to indicate the system startup phase. This sequential display makes it clear to the user that the system is booting up and ensures that they understand the process is starting correctly. Clear initialization messages on the LCD help users confidently monitor the system status as it sets up .