A client from an agricultural holding complained that up to 15% of commands were lost due to network delays in cloud-based irrigation management. Crop yield suffered and water overuse reached 20%. We proposed a hybrid architecture—a local MQTT controller with cloud backup. Now command reliability is 99.9%, and water savings up to 40%.
An irrigation controller in the field is a device with relays that open and close solenoid valves on zones. Rain Bird, Hunter, Orbit are the most well-known names. Most communicate with “smart” hubs over proprietary protocols. For custom integration into a mobile app we use either the manufacturer’s API (if available) or replace the controller with an IoT-compatible one (ESP32 with MQTT, Raspberry Pi with GPIO) or an intermediate gateway. For remote irrigation control, command execution accuracy and state monitoring are critical. A missed watering due to a network error can destroy a crop, and a leak can cause water overuse. Therefore, the app architecture must guarantee command delivery and fault handling. An MQTT controller is 5 times more reliable over a local network than a cloud API, and provides full control over the equipment.
How to manage an irrigation system through a mobile app?
Integration via Rachio API
Rachio is one of the few manufacturers with a public REST API. OAuth 2.0 authorization, scope full_control. According to the Rachio documentation, “API provides full control over zones, schedules, and device settings.”
// iOS, async/await class RachioClient { let baseURL = "https://api.rach.io/1/public" var accessToken: String func getPersonInfo() async throws -> PersonInfo { return try await get("/person/info") } func startZone(zoneId: String, duration: Int) async throws { // duration in seconds try await put("/zone/start", body: [ "id": zoneId, "duration": duration ]) } func stopDevice(deviceId: String) async throws { try await put("/device/stop_water", body: ["id": deviceId]) } func createScheduleRule(deviceId: String, zones: [ZoneSchedule]) async throws -> ScheduleRule { return try await post("/schedulerule", body: [ "device": ["id": deviceId], "name": zones.first?.name ?? "Schedule", "zones": zones.map { ["id": $0.id, "duration": $0.durationSeconds] }, "startTime": 21600, // seconds from midnight = 6:00 "type": "FIXED_SCHEDULE" ]) } } Rachio Webhook allows real-time event reception: watering start/end, valve errors, rain detection. Webhook registration via API, events arrive as POST requests to the developer’s server, which forwards them to the mobile app via WebSocket or FCM.
| Characteristic | Rachio API | MQTT Controller |
|---|---|---|
| Protocol | REST + Webhook | MQTT + WebSocket |
| Zone control | Through the cloud | Locally, no latency |
| Internet dependency | Always required | Local operation possible |
| Cost | Cloud call fees | Low (only component cost) |
| Flexibility | Limited by API capabilities | Full control over logic |
Why choose a custom MQTT controller?
Implementation on ESP32
For custom installations—a controller based on ESP32 with MQTT. Topics:
irrigation/zone/1/command → {"action": "open", "duration": 300} irrigation/zone/1/state → {"isOpen": true, "openedAt": "2024-07-15T06:00:00Z"} irrigation/system/status → {"activeZones": [1,3], "waterFlow": 12.5, "pressure": 2.8} The mobile app subscribes to irrigation/+/state and irrigation/system/status. Control—publish to irrigation/zone/+/command.
For Flutter:
class IrrigationRepository { late MqttServerClient _client; final StreamController<ZoneState> _zoneStateController = StreamController.broadcast(); Stream<ZoneState> get zoneStates => _zoneStateController.stream; Future<void> connect(MqttConfig config) async { _client = MqttServerClient(config.host, config.clientId) ..port = config.port ..secure = true ..securityContext = config.sslContext ..keepAlivePeriod = 30 ..onDisconnected = _onDisconnected; await _client.connect(config.username, config.password); _client.subscribe('irrigation/+/state', MqttQos.atLeastOnce); _client.updates!.listen((messages) { for (final message in messages) { final payload = MqttPublishPayload.bytesToStringAsString( (message.payload as MqttPublishMessage).payload.message, ); final zoneId = _extractZoneId(message.topic); _zoneStateController.add(ZoneState.fromJson(zoneId, jsonDecode(payload))); } }); } Future<void> startZone(int zoneId, Duration duration) async { final builder = MqttClientPayloadBuilder(); builder.addString(jsonEncode({ 'action': 'open', 'duration': duration.inSeconds, })); _client.publishMessage( 'irrigation/zone/$zoneId/command', MqttQos.atLeastOnce, builder.payload!, ); } } What does weather-based irrigation automation provide?
The irrigation schedule is a separate screen where zones, duration, and repetition can be set. Complexity: the schedule must consider weather forecasts (skip watering if rain is expected) and soil sensor data. By integrating with Open-Meteo we avoid unnecessary watering on rainy days, saving up to 40% water. Precise control yields up to 30% savings on pump electricity and extends valve lifespan.
Integration with weather forecast via Open-Meteo API (free, no key required):
Future<bool> shouldSkipIrrigation(double lat, double lon) async { final url = Uri.parse( 'https://api.open-meteo.com/v1/forecast' '?latitude=$lat&longitude=$lon' '&daily=precipitation_sum' '&forecast_days=2' '&timezone=auto' ); final response = await http.get(url); final data = jsonDecode(response.body); final todayRain = data['daily']['precipitation_sum'][0] as double; final tomorrowRain = data['daily']['precipitation_sum'][1] as double; // Skip if today or tomorrow has more than 5mm precipitation return todayRain > 5.0 || tomorrowRain > 5.0; } Process overview
We complete a project in 3-5 weeks. Steps:
| Stage | Duration | Result |
|---|---|---|
| Analysis and design | 1-2 days | Technical specification, equipment selection |
| Mobile app and backend development | 2-3 weeks | Source code, configured MQTT broker |
| Integration and testing | 3-5 days | Command debugging, verification on real controller |
| Deployment and training | 1-2 days | App Store/Google Play upload, operator manual |
What is included in the work
- Source code of the mobile app for iOS and Android
- Backend (API, MQTT broker, weather integration)
- Controller and sensor configuration
- Operational documentation
- Staff training (2 hours online)
- 30-day technical support after launch
Server technical requirements
- VPS with 2 vCPU, 4 GB RAM, 50 GB SSD
- OS: Ubuntu 22.04 LTS
- Installed Docker and docker-compose
- Public IP access for MQTT (port 8883) and HTTPS
Why choose our solution?
Over 10 years of experience in mobile development, 45 implemented IoT projects for the agricultural sector. Certified specialists in Swift and Kotlin ensure stable app performance in the field. Compare: Rachio API is simpler to implement, but an MQTT controller gives full control over equipment and saves up to 30% on cloud service license costs.
Contact us for a consultation on architecture selection. Order a turnkey development and get a free engineer consultation.
Step-by-step guide: connecting an MQTT controller to a Flutter app
- Set up ESP32: flash a sketch with MQTT client, specify broker address and topics.
- Deploy an MQTT broker (e.g., Mosquitto) on a server with an SSL certificate.
- In the Flutter app, use the
mqtt_clientpackage, connect with login/password. - Subscribe to zone state topics (
irrigation/+/state). - Implement sending commands via publishing to
irrigation/zone/{id}/command. - Test the cycle: valve opening → state reception → display on screen.







