Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, a web toolkit designed to help citizens, conservation practitioners, municipal decision-makers, researchers, educators, and students advance knowledge and stewardship of fresh water. New to EnviroDIY? Start here

Reply To: Water level monitor with a Mayfly.

Home Forums Mayfly Data Logger Water level monitor with a Mayfly. Reply To: Water level monitor with a Mayfly.

#1677
Danny Waz
Participant

Pardon the somewhat off-topic response, but regarding reading serial data I have found this post extremely helpful. Both of the examples above hold the loop() hostage until the whole string comes in. That’s okay in a small, single-sensor sketch, but it is susceptible to (a) truncating the string if the arduino gets ahead of the incoming data and (b) getting hung in the serial.read() “while” loop. It’s more robust (although, admittedly, more complicated) to add a single byte per loop() iteration.