According to a plea deal announced Wednesday, Thomas Sheppard, of Speonk, is expected to get five years of probation, give up his teacher's license and register as a sex offender.
Sheppard had been charged with unlawful surveillance, a felony, and seven counts of endangering the welfare of a child, a misdemeanor.
Sheppard's lawyer told Newsday that his client was remorseful and wanted to spare the community further trauma.
The Westhampton Beach school board has accepted his resignation. He had been suspended without pay since the incident came to light in February.
Sheppard is to be sentenced on Dec. 18.