Raspberry Pi Solenoid Trigger Script -- 2

Job ID: 40287348

Budget: $25 – $50 AUD

I need a concise Python 3 script that will run on a Raspberry Pi 5 and do the following:

• Watch a single GPIO input line for the HIGH digital signal coming from my Sony camera’s built-in AI output.
. The Sony camera will be pre-loaded with images of the target - in this case a plant which is detected in the target bounding box in the camera field of view.
. When the target plant is encountered in bounding box of the camera field of view, the corresponding relay will activate a spray nozzle for the time the target remains in the bounding box.
•The point above is achieved as soon as that digital signal is detected, drive a separate GPIO output that energises a small 5 V solenoid for as long as the target plant remains in the bounding box of the camera, then automatically switch it off when the spray rig moves forward and the target plant is no longer in the bounding box - camera field of view.
• Debounce or otherwise ignore any further triggers until the target image has left the bounding box and the camera seeks another target.

The camera only provides a digital signal, so no protocol parsing is required—plain HIGH/LOW logic on the GPIO pin is all I need. The trigger itself must use the Pi’s native GPIO header rather than USB or networking.
The Pi AI camera is self powered via the ribbon cable.

I haven’t fixed the exact GPIO numbers yet; feel free to suggest sensible defaults that won’t conflict with I²C or UART on a Pi 5, and declare them clearly at the top of the script so I can change them quickly. Comments in the code should be straightforward and explain any required libraries (I’m expecting RPi.GPIO or gpiozero, whichever you think is cleaner for this job).
The program will record GPS location every 30 seconds and number of times the relays are activated within the corresponding 30 second period. The programmer will specify the GPS module to be used.

Added detail via the documents provided below to assist your proposal.

# A separate top level design brief for the appliance is available to provide a overview of the functionality that the software will be supporting. See attached pr 808 Overview.
# See also clarification questions and answers, attached at DOC 4
# See hardware details at DOC 2 - attached.

Deliverable: a single, well-commented .py file I can drop on the Pi, along with any terminal commands needed to install dependencies and enable the GPIO library. Include a short README section in the file header that covers wiring the input/output pins and powering the solenoid through a transistor or relay to protect the Pi’s 3 V logic.