Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Latest commit

 

History

History

Microsoft.PowerShell.IoT.Plant

Example module Microsoft.PowerShell.IoT.Plant

This PowerShell module is for automating taking care of potted indoor plants.

This module allows a PowerShell script to control lights and water a plant when needed based on soil moisture level.

This showcases GPIO functionality of the Microsoft.PowerShell.IoT module.

Hardware setup

Hardware pieces:

Default pin configuration of Microsoft.PowerShell.IoT.Plant module:

  • Water pump relay connected to GPIO pin 0.
  • Light relay connected to GPIO pin 2.
  • Soil moisture sensor sends data to GPIO pin 5.

Wiring diagram will be published shortly.

Software setup

Install PowerShell Core on Raspberry Pi

Installation instructions can be found here.

Start Powershell and install modules

sudo pwsh
Install-Module -Name Microsoft.PowerShell.IoT
git clone https://github.com/PowerShell/PowerShell-IoT.git
Import-Module ./PowerShell-IoT/Examples/Microsoft.PowerShell.IoT.Plant

Manual operation

PS /home/pi> # working with light
PS /home/pi> Set-Light On
PS /home/pi> Set-Light Off
PS /home/pi>
PS /home/pi> # working with water
PS /home/pi> Start-Water
PS /home/pi> Stop-Water
PS /home/pi>
PS /home/pi> # reading soil moisture level
PS /home/pi> Read-SoilIsDry

Automated operation

See full-plant-demo.ps1.

This script runs 2 PS jobs - one controls light, the other - water.

For demo purposes script runs for 2 minutes. Adjust timeouts in the script for your scenario.