An open-source section control system for agricultural sprayers, designed to work with AgOpenGPS. This project provides automated spray section control based on GPS guidance, helping reduce overspray and input costs.
This system uses an ESP32 microcontroller to bridge AgOpenGPS and sprayer relay controls. It provides:
- Automatic section on/off control based on coverage mapping
- Manual override switches for each section
- Master enable/disable switch
- GNSS data passthrough for dual-antenna GPS systems
- Real-time section status feedback to AgOpenGPS
Current Version: v2.5.1 (July 4, 2025)
- 4-Section Control: Independent control of up to 4 spray boom sections
- Relay Interface: NC (Normally Closed) relay control for fail-safe operation
- Manual Overrides: Physical toggle switches for manual section control
- Master Switch: Emergency master disable for all sections
- Wi-Fi Communication: Access Point mode for wireless AgOpenGPS connection
- GNSS Passthrough: UART forwarding of GPS data (NMEA/UBX) at 115,200 baud
- Dual-Antenna Support: Automatic conversion of UNIHEADING to $GNHDT format
- Watchdog Timer: 2-second relay timeout for safety
- AgOpenGPS Protocol: Full PGN message support for section commands and feedback
- Adafruit ESP32 Feather V2 - Main microcontroller
- 4-Channel Relay Module - NC (Normally Closed) configuration
- 5x Toggle Switches - 4 section switches + 1 master switch
- Dual-Antenna GNSS Receiver - ArduSimple simpleRTK3B Compass (or compatible)
Hardware datasheets are included in the datasheets/ folder:
- Adafruit ESP32 Feather V2
- DST-1R4P-N Relay Module
- ArduSimple simpleRTK3B Compass
| Relay | GPIO Pin | Function |
|---|---|---|
| 1 | 25 | Section 1 |
| 2 | 26 | Section 2 |
| 3 | 27 | Section 3 |
| 4 | 33 | Section 4 |
| Switch | GPIO Pin | Function |
|---|---|---|
| Section 1 | 12 | Manual override for section 1 |
| Section 2 | 14 | Manual override for section 2 |
| Section 3 | 15 | Manual override for section 3 |
| Section 4 | 32 | Manual override for section 4 |
| Master | 13 | Master enable/disable |
| Signal | GPIO Pin |
|---|---|
| RX | 7 |
| TX | 8 |
| Baud | 115200 |
- Arduino IDE (1.8.x or 2.x)
- ESP32 board support package
-
Install ESP32 Board Support
- Open Arduino IDE
- Go to File → Preferences
- Add to "Additional Board Manager URLs":
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json - Go to Tools → Board → Boards Manager
- Search for "ESP32" and install "esp32 by Espressif Systems"
-
Open the Sketch
- Open
bateman-section-control-final/bateman-section-control-final.ino
- Open
-
Select Board
- Tools → Board → ESP32 Arduino → Adafruit Feather ESP32 V2
-
Upload
- Connect ESP32 via USB
- Select the correct COM port
- Click Upload
The ESP32 creates a Wi-Fi Access Point with these credentials:
- SSID:
ESP32-GPS - Password:
gps12345
To change these, modify the sketch and re-upload.
- Port 9999: NMEA data output / AOG messages
- Port 8888: AgOpenGPS section commands
- Connect your tablet/laptop to the
ESP32-GPSWi-Fi network - In AgOpenGPS, configure:
- UDP port for GPS: 9999
- UDP port for section control: 8888
- Enable section control module
- Configure 4 sections
- Power on the ESP32
- Connect to
ESP32-GPSWi-Fi network - Start AgOpenGPS
- Toggle switches:
- Switch LOW (ON) = AUTO mode (AgOpenGPS controls section)
- Switch HIGH (OFF) = Manual OFF (section forced off)
- Master switch overrides all sections when disabled
Relays will energize (LED on) when sections should spray based on:
- AgOpenGPS section commands
- Manual switch positions
- Master switch state
- Relay watchdog: If no command received for 2 seconds, all relays turn off
- NC relay configuration: Power loss = sprayer off
- Master switch: Immediately disables all sections
The system communicates with AgOpenGPS using a custom UDP-based PGN (Parameter Group Number) protocol.
- PGN 123: Keep-alive (sent every 500ms)
- PGN 203: Scan reply
- PGN 229: Section control commands (received)
- PGN 234: Section status feedback (sent every 100ms)
For detailed protocol specification, including message formats, byte layouts, and examples, see docs/pgn-protocol.md.
- Check SSID/password match
- Ensure ESP32 is powered and running (check serial monitor for startup messages)
- Verify relay wiring
- Check switch positions (LOW = AUTO allowed)
- Confirm AgOpenGPS is sending section commands (check serial monitor)
- Verify UART connections (RX/TX not swapped)
- Confirm baud rate: 115200
- Check GNSS receiver power
This project is open source and available under the MIT License.
Contributions are welcome! Please feel free to submit issues, fork the repository, and create pull requests.
- AgOpenGPS - Open-source precision agriculture platform
- Adafruit - ESP32 Feather V2 hardware
- ArduSimple - GNSS receivers
For questions or issues:
- Open an issue on GitHub
- Check AgOpenGPS Discord community for general guidance automation questions
Version History
- v2.5.1 (July 4, 2025) - Wi-Fi credentials aligned with working build
- v2.4.0 (June 4, 2025) - Master switch support added