A .NET 8.0 ASP.NET Core MVC web application for monitoring soil sensor data and controlling automated plant watering systems.
- Real-time Soil Monitoring: View live soil moisture and voltage readings
- Remote GPIO Control: Control water valves via GPIO pins on connected devices
- Automated Watering: One-click watering with automatic 1-second valve operation
- Web Interface: Clean, responsive web UI for monitoring and control
- Docker Support: Containerized deployment ready
- Railway Deployment: Pre-configured for Railway platform
The application communicates with a remote soil sensor device (typically a Raspberry Pi) via HTTP APIs to retrieve sensor data and control watering systems.
- Web Application: ASP.NET Core MVC frontend
- Service Layer: HTTP client for remote sensor communication
- Data Models: Soil sensor data representation
- Remote Device: Raspberry Pi with soil sensors and GPIO control
- .NET 8.0 SDK
- Remote soil sensor device with API endpoints
# Clone the repository
git clone <repository-url>
cd SoilSeneorSystem
# Build the application
dotnet build
# Run in development mode
dotnet runThe application will be available at http://localhost:5000
# Build Docker image
docker build -t soil-sensor-app .
# Run container
docker run -p 5000:5000 soil-sensor-appConfigure the soil sensor device endpoint in appsettings.json:
{
"SoilSensor": {
"BaseUrl": "http://soil-sensor-pi.local:8080"
}
}Or set via environment variable:
export SoilSensor__BaseUrl="http://your-sensor-device:8080"GET /Home/GetData- Retrieve current soil sensor dataPOST /Home/WaterPlant- Trigger automated watering sequence
The application expects a remote device providing these HTTP endpoints:
GET /api/soil-data- Returns soil sensor readingsPOST /api/soil-data/gpio/control- Controls GPIO pins for water valve
{
"voltage": 3.3,
"moisture": 65.5,
"timestamp": 1642608000000
}The application is pre-configured for Railway deployment with:
Dockerfilefor containerizationrailway.jsonfor deployment settings- Automatic PORT environment variable handling
PORT- Server port (default: 5000)SoilSensor__BaseUrl- Remote sensor device URL
SoilSeneorSystem/
├── Controllers/ # MVC controllers
├── Models/ # Data models
├── Services/ # Service layer
├── Views/ # Razor views
├── wwwroot/ # Static files
├── appsettings.json # Configuration
└── Dockerfile # Container configuration
Program.cs- Application entry point and configurationServices/SoilSensorService.cs- HTTP client for remote device communicationModels/SoilData.cs- Data model for sensor readingsControllers/HomeController.cs- Main controller with API endpoints
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
dotnet test - Submit a pull request
This project is licensed under the MIT License.