Monitoring the presence of viruses and bacteria in environmental reservoirs such as wastewater, lake water etc. is a very useful tool for early detection and controlling the spread of diseases, while also helping estimate the severity of infections at a community level. While several DNA sensors have been demonstrated for nucleic acid sensing for a variety of applications, most such demonstrations require sophisticated instrumentation or assays that need to be controllably performed in a well-equipped laboratory. In this work, we demonstrate a low-cost, portable device to detect DNA in wastewater and lake water, based on the color change in samples due to the intercalation of DNA with methylene blue (MB) dye. The optical sensor consists of a phase-sensitive detection circuit constructed with low-cost semiconductor ICs, red LED, and a silicon PIN photodiode. The phase-sensitive detection circuit has a resolution of 68μV, and the sensor has a limit of detection of 25.68 nM for DNA sensing. The utility of this sensor is demonstrated through the detection of bacteria (E. coli) and viruses (bacteriophage phi6) from wastewater and lake-water samples, respectively.