This project is a remote soil monitoring system powered by an STM32 microcontroller and SIM800L module, designed to measure and report multiple environmental parameters via GSM/GPRS to ThingSpeak. It’s suitable for agricultural IoT applications with solar-powered operation and future scalability.
- STM32F103C8T6 (Bluepill) – Main microcontroller
- SIM800L – GSM/GPRS communication module
- Soil Moisture Sensor – Analog soil humidity sensor
- DHT22 – Air temperature and humidity sensor
- DS18B20 – Waterproof soil temperature sensor (1-Wire)
- Relay Module – Controls water pump
- Solar Cell (5V output) – Renewable power source
- 3x 18650 Li-ion Batteries (Parallel) – Rechargeable power backup
- Auto Charging Module (1S) – Solar charge controller
- 🌡️ Measure air temperature & humidity (DHT22)
- 🌱 Monitor soil moisture & temperature (Soil Sensor + DS18B20)
- 🔋 Monitor battery voltage via ADC (PA0)
- 📡 Upload data to ThingSpeak via SIM800L (HTTP POST)
- 🌞 Operates on solar energy, energy-efficient with sleep routines
- 💧 Water pump control via relay (future development)
- 🤖 Future upgrade: Telegram bot notifications
| File | Description |
|---|---|
full_code.ino |
Complete integrated code for the entire monitoring and communication system |
read_sensor.ino |
Standalone code for testing and reading each sensor module |
sleep_thingspeak.ino |
SIM800 HTTP routine with sleep control using STM32’s internal RTC |
💡 Note: Sleep functionality will not activate when USB is connected. Use battery/serial power during deployment.
Data is sent to ThingSpeak in a single HTTP POST request, updating:
- Air Temperature (DHT22)
- Air Humidity (DHT22)
- Soil Temperature (DS18B20)
- Soil Moisture
- Battery Voltage
- Pump Status (Future)
| Sensor / Module | Pin (STM32) |
|---|---|
| DHT22 (Air Temp/Hum) | PB14 |
| DS18B20 (Soil Temp) | PB12 |
| Soil Moisture Sensor | PA1 |
| Battery Voltage (ADC) | PA0 |
| SIM800L (GSM UART) | Serial1 |
| Relay (Pump Control) | Customizable |
git clone https://github.com/2black0/Soil-Monitoring-System.gitUse Arduino IDE with STM32duino core or PlatformIO to flash full_code.ino to your Bluepill.
- Ensure your solar cell outputs a stable 5V
- Use proper protection circuitry for Li-ion cells
- Send data to ThingSpeak via SIM800L
- Use deep sleep for power saving
- Activate pump under low soil moisture or high temp
- Add Telegram bot for real-time alerts
This project is licensed under the MIT License.