Skip to content

Save Nurture: An automatic plant watering system using soil moisture sensor and relay control, fully implemented in C for ATmega328P.

License

Notifications You must be signed in to change notification settings

omidkarami1337/save-nurture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

save-nurture

سیستم آبیاری خودکار گلدان برای ATmega328P (Arduino Uno compatible)

این پروژه یک پیاده‌سازی ساده به زبان C (قابل کامپایل با avr-gcc) برای خواندن سنسور رطوبت خاک، کنترل رله پمپ، ذخیره‌سازی تنظیمات در EEPROM و ارسال وضعیت از طریق UART است.

ویژگی‌ها

  • خواندن ADC از A0 با میانگین‌گیری
  • تبدیل ADC به درصد با کالیبراسیون قابل تنظیم
  • هیستریزیز برای جلوگیری از نوسان زیاد (THR_DRY < THR_WET)
  • فعال‌سازی رله (D8 / PB0) برای زمان قابل تنظیم
  • دکمه دستی روی D2 (INT0): فشار کوتاه => آبیاری یک دور، فشار طولانی => حالت تنظیم
  • گزارش وضعیت هر 60 ثانیه از طریق UART 9600bps
  • ذخیره و بازیابی پیکربندی در EEPROM
  • ساختار ماژولار در C

سخت‌افزار

  • MCU: ATmega328P (Arduino Uno)
  • سنسور رطوبت: Analog sensor به A0 (ADC0)
  • رله 5V: D8 (PORTB0), فعال با HIGH
  • دکمه: D2 (INT0) با pull-up داخلی
  • LED وضعیت: D13 (PB5)

شماتیک پین و نقشه سیم‌کشی در hardware/wiring.md (و یک فایل placeholder hardware/schematic.txt به‌عنوان راهنما).

قطعات پیشنهادی

  • ATmega328P (یا Arduino Uno)
  • ماژول رله 5V
  • سنسور رطوبت خاک آنالوگ
  • دکمه فشاری و مقاومت یا استفاده از pull-up داخلی
  • کابل‌ها و منبع تغذیه 5V

پارامترهای پیش‌فرض

  • THRESHOLD_DRY = 30 (%)
  • THRESHOLD_WET = 40 (%)

save-nurture

Automated plant pot watering controller for ATmega328P (Arduino Uno compatible).

This project is a minimal C implementation (for avr-gcc) that reads an analog soil moisture sensor, controls a water pump via a relay, stores configuration in EEPROM, and reports status over UART.

Maintainer: @omidkarami1337

Features

  • ADC readings from A0 with configurable averaging
  • Linear calibration (dry/wet) to convert ADC raw to percent
  • Hysteresis to avoid pump chatter (THR_DRY < THR_WET)
  • Relay control (D8 / PB0) for configurable pump duration
  • Manual button on D2 (INT0): short press = one watering cycle, long press = setting mode (placeholder)
  • Periodic status messages over UART (9600 bps)
  • Configuration stored in internal EEPROM
  • Modular C layout (see src/ and include/)

Hardware

  • MCU: ATmega328P (Arduino Uno)
  • Soil moisture sensor (analog) connected to A0 (ADC0)
  • Relay module input to D8 (PORTB0), active HIGH
  • Push button to D2 (PD2 / INT0) with internal pull-up
  • Status LED on D13 (PB5)

See hardware/wiring.md for wiring details and hardware/schematic.txt as a placeholder for an image.

Default parameters

  • THRESHOLD_DRY = 30 (%)
  • THRESHOLD_WET = 40 (%)
  • PUMP_DURATION_SEC = 5
  • MEASURE_INTERVAL_SEC = 60

Repository layout

  • src/ — source files
  • include/ — public headers
  • hardware/ — wiring notes and schematic placeholder
  • Makefile — build and flash targets

Build and flash Requires: avr-gcc, avr-libc, avrdude.

Examples (POSIX shell / WSL):

make
# Flash to Arduino bootloader; set COMPORT to your port, e.g. COM3
make flash COMPORT=COM3

Notes for Windows users: the Makefile uses POSIX shell commands; use WSL, MSYS, or adapt the commands for PowerShell.

Sample UART output

save-nurture boot
MOIST: 27% ADC: 276 PUMP: OFF THR_DRY:30 THR_WET:40
MOIST: 29% ADC: 300 PUMP: ON THR_DRY:30 THR_WET:40

Testing and calibration

  • Calibrate cal_dry_raw and cal_wet_raw in EEPROM (or in code) by measuring ADC values on dry and fully wet soil/contacts.
  • Use a potentiometer on A0 to simulate ADC values for threshold tests.
  • Verify EEPROM persistence by changing thresholds and resetting the MCU.

If you want a UART interactive menu to change settings or a low-power mode using the watchdog timer, tell me which to add next.

About

Save Nurture: An automatic plant watering system using soil moisture sensor and relay control, fully implemented in C for ATmega328P.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published