Skip to content

leckerstone-labs/sprayer-section-control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP32 Sprayer Section Control

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.

Overview

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)

Features

  • 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

Hardware Requirements

Core Components

  • 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)

Datasheets

Hardware datasheets are included in the datasheets/ folder:

  • Adafruit ESP32 Feather V2
  • DST-1R4P-N Relay Module
  • ArduSimple simpleRTK3B Compass

Pin Configuration

Relay Outputs

Relay GPIO Pin Function
1 25 Section 1
2 26 Section 2
3 27 Section 3
4 33 Section 4

Switch Inputs (Pull-up, Active LOW)

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

GNSS UART

Signal GPIO Pin
RX 7
TX 8
Baud 115200

Software Setup

Prerequisites

  • Arduino IDE (1.8.x or 2.x)
  • ESP32 board support package

Installation

  1. 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"
  2. Open the Sketch

    • Open bateman-section-control-final/bateman-section-control-final.ino
  3. Select Board

    • Tools → Board → ESP32 Arduino → Adafruit Feather ESP32 V2
  4. Upload

    • Connect ESP32 via USB
    • Select the correct COM port
    • Click Upload

Configuration

Wi-Fi Settings

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.

Network Ports

  • Port 9999: NMEA data output / AOG messages
  • Port 8888: AgOpenGPS section commands

AgOpenGPS Setup

  1. Connect your tablet/laptop to the ESP32-GPS Wi-Fi network
  2. In AgOpenGPS, configure:
    • UDP port for GPS: 9999
    • UDP port for section control: 8888
    • Enable section control module
    • Configure 4 sections

Usage

Normal Operation

  1. Power on the ESP32
  2. Connect to ESP32-GPS Wi-Fi network
  3. Start AgOpenGPS
  4. Toggle switches:
    • Switch LOW (ON) = AUTO mode (AgOpenGPS controls section)
    • Switch HIGH (OFF) = Manual OFF (section forced off)
  5. Master switch overrides all sections when disabled

LED Indicators

Relays will energize (LED on) when sections should spray based on:

  • AgOpenGPS section commands
  • Manual switch positions
  • Master switch state

Safety Features

  • 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

Protocol Details

The system communicates with AgOpenGPS using a custom UDP-based PGN (Parameter Group Number) protocol.

PGN Messages

  • 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.

Troubleshooting

No Wi-Fi Connection

  • Check SSID/password match
  • Ensure ESP32 is powered and running (check serial monitor for startup messages)

Sections Not Responding

  • Verify relay wiring
  • Check switch positions (LOW = AUTO allowed)
  • Confirm AgOpenGPS is sending section commands (check serial monitor)

GNSS Not Working

  • Verify UART connections (RX/TX not swapped)
  • Confirm baud rate: 115200
  • Check GNSS receiver power

License

This project is open source and available under the MIT License.

Contributing

Contributions are welcome! Please feel free to submit issues, fork the repository, and create pull requests.

Acknowledgments

Support

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

About

Development of a section control system for an agricultural sprayer using AgOpenGPS.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages