0% found this document useful (0 votes)
2 views9 pages

Project Report

The project report details the development of a compact STM32-based Smart Soil System that monitors soil moisture and ambient temperature. It utilizes various sensors, including a soil moisture sensor and a DHT11 temperature sensor, to provide real-time readings displayed on a 0.96″ I²C OLED, with an alert mechanism via a buzzer for watering needs. The system demonstrates effective automation from sensing to action, ensuring reliable monitoring and user alerts for soil conditions.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views9 pages

Project Report

The project report details the development of a compact STM32-based Smart Soil System that monitors soil moisture and ambient temperature. It utilizes various sensors, including a soil moisture sensor and a DHT11 temperature sensor, to provide real-time readings displayed on a 0.96″ I²C OLED, with an alert mechanism via a buzzer for watering needs. The system demonstrates effective automation from sensing to action, ensuring reliable monitoring and user alerts for soil conditions.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Project Report

Group-1
Course : CSE 331L
Section : 13
SUBMITTED BY :
Name: Ananto Shariar 2211431042
Name: [Link] Reyan 2211769042
Name: Minhajul Hoque 2232460042
Name: Md. Sajidul Islam 2212663042
Smart Soil System & Temperature Measurement

1. Abstract
We developed a compact STM32-based multi-sensor system to monitor soil moisture, and
ambient temperature. Soil moisture status is shown using two level (level-1(no), level-2(yes)),
while level-1 means no need water and level-2 means yes need water. A small 0.96″ I²C OLED
continuously displays live sensor readings. The firmware is built using STM32 HAL, using I²C
for the OLED, ADC for the soil sensor, a microsecond timer for precise timing (DHT11).
Reliability is improved with error counting we use buzzer which work like alarm when water
need it will make sound. Overall, the system provides a clear, demo-ready example of sensing-
to-action automation using core STM32 peripherals.

2. Objectives
The main objective of this project is to design and implement a compact STM32-based system
that can monitor soil moisture and ambient temperature in real time. The system classifies soil
moisture into two levels—Level-1 indicating no need for watering and Level-2 indicating
watering is needed—and displays the current readings clearly on a 0.96″ I²C OLED screen. To
achieve this, the firmware uses STM32 HAL drivers with ADC for the soil moisture sensor, I²C
communication for the OLED, and precise microsecond timing to read data from the DHT11
temperature sensor. Additionally, the project aims to improve reliability by using error counting
for sensor read issues and to provide an alert mechanism using a buzzer that sounds whenever
the soil condition reaches Level-2 (water needed), making the system demo-ready and practical
for basic sensing-to-action automation.

3. Components Used
Sl.
Component Quantity Purpose/Use
No.
STM32 Microcontroller Board (e.g., Main controller; reads sensors, runs
1. 1
STM32F103 “Blue Pill”) logic, controls display and buzzer
Measures soil moisture level using
2. Soil Moisture Sensor (Analog) 1
ADC input
Measures ambient temperature using
3. DHT11 Temperature Sensor 1
precise timing protocol
Displays real-time moisture status
4. 0.96″ I²C OLED Display (SSD1306) 1
and temperature
Alarm sound when soil moisture
5. Buzzer 1
indicates water is needed (Level-2)
Programs the STM32 and provides
6. ST-LINK V2 Programmer/Debugger 1
power during testing
Used to assemble and connect
7. Breadboard / Connection Setup 1
modules
As Wiring connections between STM32
8. Jumper Wires
needed and sensors/modules

4. Block Diagram
5. Circuit Connections
Module Pin STM32 Pin Notes

OLED (0.96″ I²C SSD1306) VCC 3.3V Use 3.3V for safe I²C level

GND GND Common ground

SCL PB6 (I2C1_SCL) I²C clock

SDA PB7 (I2C1_SDA) I²C data

VCC 3.3V Sensor power


Soil Moisture Sensor (Analog)

GND GND Common ground

AO (Analog Out) PA0 (ADC1_IN0) ADC input pin

VCC 3.3V Can work on 3.3V


DHT11

GND GND Common ground

DATA PA1 (GPIO Input/Output) Use one GPIO pin for DHT11 data

+ (Signal) PB0 (GPIO Output) ON when Level-2 (need water)

Buzzer

– GND Common ground

3.3V 3.3V Power from ST-LINK (during test)


ST-LINK V2

GND GND Must be common

SWDIO PA13 SWD programming/debug

SWCLK PA14 SWD clock

NRST (optional) RST Optional reset connection


6. Working Principle
1. Power & Initialization: The STM32 is powered through the ST-LINK and the firmware
starts running. It initializes the required peripherals using HAL, including GPIO, ADC
(soil moisture sensor), I²C (OLED Display) and the timer functions needed for DHT11
timing.

2. Soil Moisture Reading (ADC): The soil moisture sensor outputs an analog voltage that
changes with soil water content. The STM32 reads this voltage using the ADC and
converts it into a digital value.

3. Moisture Level Decision (Level-1 / Level-2): The ADC moisture value is compared with
a preset threshold. If the value indicates sufficient moisture, the system sets Level-1 (No
need water). If it indicates low moisture, the system sets Level-2 (Need water).

4. Temperature Reading (DHT11): The STM32 communicates with the DHT11 using a
single data pin and precise microsecond timing. It reads and extracts the ambient
temperature value from the sensor response.

5. Alarm/Buzzer Action: If the soil is in Level-2 (Need water), the STM32 turns the buzzer
ON to alert the user. If the soil returns to Level-1, the buzzer stays OFF.

6. OLED Display Update: The STM32 continuously updates the 0.96″ I²C OLED to show
live information such as the soil moisture level (Level-1/Level-2) and the current
temperature.

7. Error Handling & Reliability: During operation, if a sensor read fails (especially DHT11),
the system increases an error counter and continues trying, which helps keep the system
stable and prevents sudden incorrect outputs.

8. Continuous Monitoring Loop: The above steps repeat continuously in a loop, so the
system always provides real-time monitoring and immediate alert when watering is
required.
7. Algorithm
1. Start program.

2. Initialize STM32 peripherals using HAL:

o GPIO, ADC1, I2C1, TIM1

o Start TIM1 for microsecond delay

o Initialize SSD1306 OLED

3. Enter infinite loop

4. Blink status LED (PC13)

o LED ON (PC13 reset), delay 500ms

o LED OFF (PC13 set)

5. Read DHT11 sensor (PB9)

o Send start signal and wait for response

o Read 5 bytes: RH int, RH dec, Temp int, Temp dec, checksum

o If checksum is valid → update Temperature C and Humidity

6. Read soil moisture using ADC1

o Start ADC, get raw (0–4095), stop ADC

o Convert to percent:
𝑟𝑎𝑤
𝑆𝑜𝑖𝑙% = 100 − ቀ ൈ 100ቁ
4095

o Clamp result to 0–100%

7. Decide Water Level (only from soil%)


o If soil% < 30 → water_level = 2 (Need water)

o Else → water_level = 1 (No need water)

8. Update OLED display (I²C)

o Clear screen

o Print: Temperature, Humidity, Soil%, Level text

o Update screen

9. Buzzer control (PA5)

• If water_level == 2 → beep (ON 200ms, OFF 1800ms)

• Else → keep OFF and delay 500ms

11. Repeat loop forever.

8. Implementation
The project was implemented on an STM32 microcontroller using the STM32 HAL library in
STM32CubeIDE. Hardware interfacing includes an analog soil moisture sensor, a DHT11
temperature and humidity sensor, a 0.96″ SSD1306 OLED display (I²C), and a buzzer for alert.
The OLED is driven through I2C1 at 400 kHz, and the display is updated in every loop to show
temperature, humidity, soil moisture percentage, and water level status. Soil moisture is read
using ADC1 as a 12-bit value (0–4095), then converted into percentage using the formula: Soil%
= 100 − (raw/4095 × 100) and clamped between 0 and 100 to avoid invalid values. The DHT11
sensor is read using a bit-banged protocol on PB9, where a start signal is generated by switching
PB9 to output mode and then back to input mode; TIM1 is used to create microsecond delays for
precise timing during data reception and bit detection. After reading the 5 DHT11 bytes, the
checksum is verified before updating the temperature and humidity values to ensure correct
readings. The watering decision logic is based only on soil moisture: if soil moisture is below
30%, the system sets Level-2 (Need water); otherwise, it remains Level-1 (No need water).
When Level-2 is detected, the buzzer on PA5 generates an alarm beep pattern (200ms ON,
1800ms OFF). Additionally, three GPIO pins (PA2, PA3, PA4) are used as indicator outputs
(traffic-light style) to represent dry/medium/wet ranges, and the onboard PC13 LED blinks as a
heartbeat to confirm the system is running continuously.
9. Results & Output
The Smart Soil System operated correctly as a real-time monitoring and alert platform. The
STM32 continuously read soil moisture using ADC and converted the raw ADC value (0–4095)
into a percentage (0–100%), then classified the result into two levels based on the threshold:
Level-1 (No need water) when soil moisture was ≥ 30%, and Level-2 (Need water) when soil
moisture was < 30%. The buzzer alarm reliably activated only in Level-2 and remained OFF in
Level-1, providing a clear indication of when watering is required. At the same time, the system
successfully read temperature and humidity from the DHT11 using microsecond timing and
displayed all live values—temperature (°C), humidity (%), soil moisture (%), and water level
text—on the 0.96″ I²C OLED screen. Overall, the project demonstrated stable sensing-to-
decision automation: sensor readings were updated repeatedly, the moisture threshold logic
responded immediately to soil condition changes, and the alert output (buzzer) worked as
expected for dry-soil conditions.

10. Discussion
In this project, we successfully designed and implemented a compact STM32-based Smart Soil
System that monitors soil moisture and ambient temperature (and humidity) and provides a clear
watering decision using a simple two-level logic. The system reads soil moisture through the
STM32 ADC, converts it into a percentage, and determines Level-1 (no need water) or Level-2
(need water) using a fixed threshold. Live sensor readings and status are continuously shown on
a 0.96″ I²C OLED, making the output easy to understand during demonstration. When the soil
becomes dry (Level-2), the buzzer alarm activates to alert the user, proving that the system can
perform practical sensing-to-action automation. Overall, the project demonstrates effective use of
core STM32 peripherals (ADC, I²C, GPIO, timer-based timing) and produces a stable, demo-
ready solution for basic soil monitoring and watering indication.
11. Reference
1. STMicroelectronics, STM32F103x8/STM32F103xB Datasheet, STM32F103C8T6, Rev.
DS5319 (or latest), STMicroelectronics, 2025.

2. STMicroelectronics, RM0008 Reference Manual: STM32F10x Reference Manual,


STMicroelectronics, 2025.

3. Solomon Systech Ltd., SSD1306: 128×64 Dot Matrix OLED/PLED Segment/Common Driver
with Controller, Datasheet, 2025.

4. Aosong Electronics Co., Ltd. (ASAIR), DHT11 Temperature & Humidity Sensor Datasheet,
2025.

5. STMicroelectronics, AN2820: Getting Started with STM32F10xxx Hardware Development,


Application Note, STMicroelectronics, 2025.

6. STMicroelectronics, UM1850: Getting Started with STM32CubeF1 (HAL) Firmware


Package, User Manual, STMicroelectronics, 2025.

You might also like