top of page

Smart Greenhouse Monitor Using STM32 Nucleo

Introduction


A Smart Greenhouse Monitor is a system designed to continuously monitor important environmental conditions inside a greenhouse. The main objective of this project is to develop a simple monitoring system using the STM32 Nucleo-L031K6 that can measure temperature, humidity, and light intensity.


The system uses a DHT22 sensor to measure temperature and humidity, an LDR (photoresistor) to monitor the surrounding light level, and an OLED display to provide real-time information to the user. The STM32 Nucleo board acts as the central controller and continuously reads the sensor values.


Complete Wokwi circuit of the Smart Greenhouse Monitoring System
Complete Wokwi circuit of the Smart Greenhouse Monitoring System

The measured temperature, humidity, and LDR values are displayed on the OLED and also transmitted through the serial monitor for observation. The system can therefore provide a basic overview of greenhouse environmental conditions and can serve as a foundation for future automatic greenhouse control systems.


The complete system was developed and tested using the Wokwi simulation environment before implementation on physical hardware.


Components Required

Component

Quantity

Purpose

STM32 Nucleo-L031K6

1

Main microcontroller for processing sensor data

DHT22 Temperature & Humidity Sensor

1

Measures temperature and humidity

LDR (Photoresistor)

1

Measures light intensity

SSD1306 OLED Display

1

Displays the measured environmental parameters

Jumper Wires

As required

Connects the components to the STM32 board


System Overview


The Smart Greenhouse Monitor consists of an STM32 Nucleo-L031K6, a DHT22 sensor, an LDR, and an SSD1306 OLED display. The STM32 acts as the main controller and processes the environmental data received from the sensors.


Working Principle


  1. The DHT22 sensor measures the temperature and humidity of the greenhouse environment.

  2. The LDR measures the intensity of surrounding light.

  3. The STM32 reads the sensor values at regular intervals and processes them.

  4. The measured values are displayed on the SSD1306 OLED for real-time monitoring.

  5. The same readings are also sent to the Serial Monitor for debugging and observation.

  6. The LDR reading is interpreted to determine whether the environment is BRIGHT or DARK.


Circuit Connections

Component

Pin

STM32 Nucleo Pin

Purpose

DHT22

DATA

A0

Temperature & humidity data

DHT22

VCC

3.3V

Power supply

DHT22

GND

GND

Ground

LDR

AO

A1

Analog light-level input

LDR

VCC

3.3V

Power supply

LDR

GND

GND

Ground

SSD1306 OLED

SDA

D4

I²C data

SSD1306 OLED

SCL

D5

I²C clock

SSD1306 OLED

VCC

3.3V

Power supply

SSD1306 OLED

GND

GND

Ground


Programming and Implementation


The Smart Greenhouse Monitor is programmed using the Arduino framework for the STM32 Nucleo-L031K6. The program initializes the DHT22 sensor and continuously reads the temperature, humidity, and LDR values at regular intervals. The processed readings are then displayed on the OLED and sent to the Serial Monitor.


5.1 Pin Configuration



  • A0 is used for the DHT22 data signal.

  • A1 is used to read the analog output of the LDR.

  • D4 and D5 are used for the OLED's I²C communication.

  • 0x3C is the I²C address of the OLED display.


5.2 Sensor Data Acquisition


The DHT22 is initialized using the DHT library and its temperature and humidity values are read periodically. The LDR value is obtained using the STM32's analog input.


The LDR value is inverted in software so that a higher displayed value corresponds to higher illumination.


5.3 OLED Display


A lightweight custom OLED interface is used instead of the larger Adafruit SSD1306/GFX libraries. This keeps the program within the limited FLASH memory of the STM32L031K6.



The OLED displays:

  • Temperature

  • Humidity

  • LDR value

  • BRIGHT/DARK status


Source Code


The complete source code used to program the STM32 Nucleo-L031K6 and implement the Smart Greenhouse Monitor is provided below for reference and download.



Simulation and Output


The Smart Greenhouse Monitor was implemented and tested using the Wokwi simulation environment. The simulation integrates the STM32 Nucleo-L031K6 with the DHT22 sensor, LDR, and SSD1306 OLED display.


Wokwi simulation output of the Smart Greenhouse Monitor.
Wokwi simulation output of the Smart Greenhouse Monitor.

The system was tested by changing the temperature, humidity, and illumination values using the Wokwi sensor controls. The OLED and Serial Monitor successfully displayed the corresponding sensor readings and light condition (BRIGHT/DARK) in real time.


Future Scope


The Smart Greenhouse Monitor can be further enhanced by:

  • Automatic irrigation control based on soil moisture levels.

  • Additional sensors for parameters such as CO₂, soil moisture, and air pressure.

  • IoT connectivity for remote monitoring and data logging.

  • Mobile application integration for viewing greenhouse conditions remotely.

  • Automatic fan and lighting control based on the monitored environmental conditions.

  • Physical hardware implementation for real-world greenhouse deployment.


Conclusion


The Smart Greenhouse Monitor successfully demonstrates the use of the STM32 Nucleo-L031K6 for monitoring important greenhouse environmental parameters. The system measures temperature and humidity using the DHT22 and light intensity using the LDR, with the measured values displayed on the SSD1306 OLED and Serial Monitor.


The Wokwi simulation successfully verified the operation of the complete monitoring system under different temperature, humidity, and lighting conditions. The project provides a simple foundation that can be further developed into a fully automated greenhouse management system.


 
 
 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page