Skip to content

petros/spm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Αισθητήρας Ποτίσματος (SPM)

A soil moisture monitor that runs on a Raspberry Pi Zero 2 W. It reads moisture from an LM393-based sensor and sends a push notification to your phone when your plant needs watering. Includes a web dashboard accessible from any device on the same network.

How It Works

  1. The Pi reads a soil moisture sensor every 2 seconds.
  2. After 3 consecutive dry readings (~6 seconds), it changes state and sends a notification via ntfy.sh.
  3. A Phoenix LiveView dashboard at http://spm.local:4000 shows the current status and history — updated in real time.

Hardware

  • Raspberry Pi Zero 2 W (H variant, with pre-soldered GPIO headers)
  • MH-Sensor-Series soil moisture module (LM393-based)
  • Female-to-female Dupont cables
  • MicroSD card + card reader
  • Micro USB cable + USB power adapter

Wiring

Sensor Pin Pi Pin Notes
VCC Pin 1 (3.3V) Not 5V — this is important
GND Pin 6 (GND)
DO Pin 11 (GPIO17) Digital output (wet/dry)

Project Structure

Two projects in a poncho layout:

spm/
├── docs/        ← implementation plan
├── ui/          ← Phoenix LiveView dashboard
└── firmware/    ← Nerves firmware (sensor, notifications)

firmware/ depends on ui/ via a path dependency. mix firmware bundles both into a single image that runs on the Pi.

Prerequisites

  • macOS
  • Erlang 28.4.1 and Elixir 1.19.5-otp-28 (via asdf)
  • Nerves toolchain: mix archive.install hex nerves_bootstrap
  • System deps: brew install fwup squashfs coreutils xz pkg-config

Getting Started

1. Configure Wi-Fi

cp firmware/config/secrets.exs.example firmware/config/secrets.exs

Edit firmware/config/secrets.exs with your 2.4 GHz Wi-Fi SSID and password.

2. Build and Flash

cd ui && mix assets.deploy
cd ../firmware
export MIX_TARGET=rpi0_2
mix deps.get
mix firmware
mix burn

3. Boot

  1. Insert the MicroSD card into the Pi.
  2. Wire the sensor (see table above).
  3. Plug the micro USB cable into the PWR port.
  4. Wait ~30 seconds, then open http://spm.local:4000.

4. Get Notifications

  1. Install the ntfy app on your phone.
  2. Subscribe to the topic you configured in firmware/config/secrets.exs.
  3. When the soil dries out, you get a push notification.

Development

Work on the dashboard without the Pi:

cd ui
mix phx.server
# Open http://localhost:4000

The UI uses fake sensor data in dev mode. Push to the Pi when ready:

cd ui && mix assets.deploy
cd ../firmware
export MIX_TARGET=rpi0_2
mix firmware
mix upload spm.local    # over-the-air, no SD card needed

Calibration

The sensor module has a small blue potentiometer. Turn it with a screwdriver to adjust the wet/dry threshold for your specific plant.

More

See docs/plan.md for wiring diagrams, safety checklist, iPhone hotspot instructions for demos, and the optional MCP3008 analog upgrade.

Screenshots

Fully moist:

IMG_7039

Dashboard reports that:

moist

Suddenly, it gets dry:

IMG_7038

Dashboard reports that:

dry

And you get a notification on your phone:

Screenshot 2026-03-22 at 23 36 45