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

Hydros 21 and Serial Comms

Home Forums Mayfly Data Logger Hydros 21 and Serial Comms

Viewing 2 reply threads
  • Author
    • #18466

        Hello, my senior project team at Lake Superior State University is using the Mayfly board with the Hydros 21 CTD sensor.

        We are using the ModularSensors library and we’re wondering if there is a power cycle taking place that could affect any serial communication. There are no issues with communication or connection when sending data from the Mayfly via rosserial, but when sending data to the board, we lose connection with the rest of our system.

        Below is a snippet of our loop:

        /** —————–Start of Hydros CTD Sensor Read——————**/

        // Send power to the sensor

        // Wake up the sensor

        // Update the sensor value

        // Get the sensor readings as strings
        String hydrosCondStr = hydros21Cond->getValueString();
        String hydrosTempStr = hydros21Temp->getValueString();
        String hydrosDepthStr = hydros21Depth->getValueString();

        // Convert the strings to floats
        hydrosCond = hydrosCondStr.toFloat();
        hydrosTemp = hydrosTempStr.toFloat();
        hydrosDepth = hydrosDepthStr.toFloat();

        String hydros_data = date_time + “,” + String(hydrosTemp) + “,” + String(hydrosCond) + “,” + String(hydrosDepth/1000);

        // Put the sensor back to sleep

        // Cut the sensor power

        // Turn off the LED to show we’re done with the reading
        digitalWrite(greenLED, LOW);
        /** —————–End of Hydros CTD Sensor Read——————–**/

        For the hydros21.powerUp(), hydros21.wake(), hydros21.update(), hydros21.sleep(), and hydros21.powerdown(), would any of these functions cause a communication problem with serial communication?

      • #18468
        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.

        • #18470
          Scott Ensign

            @rhouck, @damiano moved this post to a new thread here. I noticed that you reposted to a different thread. Please reply to this thread.

            • #18471

                Thank you, Scott. I am not used to this forum and got a bit mixed up.

          Viewing 2 reply threads
          • You must be logged in to reply to this topic.