Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, an initiative of Stroud Water Research Center designed to help people advance knowledge and stewardship of fresh water.
New to EnviroDIY? Start here

Reply To: Hydros 21 and Serial Comms

Home Forums Mayfly Data Logger Hydros 21 and Serial Comms Reply To: Hydros 21 and Serial Comms

Sara Damiano

    I know nothing about rosserial. Are you using Hardware Serial with it? Serial or Serial1? Are you using some type of software serial (SoftwareSerial, AltSoftSerial, NeoSWSerial)? Very quickly skimming the rosserial docs and code, it looks like it has some specific boards that are supported and the 1284p in the Mayfly may not be 100% compatible.

    The power cycling done by modular sensors is based on the power pin you used to set up the Hydros21.  If you have your other serial peripheral on the same pin, it’s possible that the power cycling could be throwing it off.  Try putting them on different power pins, or re-running the Serial.begin() after the power cycle.

    The Hydros21 is an SDI-12 sensor using the SDI-12 library under the hood. That library does make use of and changes the settings for Timer2. Any other library that would use Timer2 (Tone, NeoSWSerial, etc) will conflict with it without showing compiler errors.  See this: SDI-12 ReadMe.  ModularSensors runs a begin() and end() on the SDI-12 objects whenever it talks to them, which *should* set and unset the timers and prevent conflicts, but it’s possible there’s still a problem with them.

    As a side note, instead of using getValueString() and then toFloat() and then converting back to a String, you should just use the string value in your hydros_data String. If you need the float for some reason, use getValue().  The getValueString() is designed to not only give the value as a string, but to also give it in with the appropriate number of significant figures based on the specifications of each sensor. Converting to a float and back to a String completely negates that.