Home › Forums › Mayfly Data Logger › Hydros 21 and Serial Comms
- This topic has 3 replies, 3 voices, and was last updated 2024-05-10 at 5:01 PM by rhouck.
-
AuthorPosts
-
-
2024-05-10 at 10:12 AM #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
hydros21.powerUp();// Wake up the sensor
hydros21.wake();// Update the sensor value
hydros21.update();// 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
hydros21.sleep();// Cut the sensor power
hydros21.powerDown();// 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?
-
2024-05-10 at 11:08 AM #18468
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.
-
2024-05-10 at 4:57 PM #18470
@rhouck, @damiano moved this post to a new thread here. I noticed that you reposted to a different thread. Please reply to this thread.
-
2024-05-10 at 5:01 PM #18471
Thank you, Scott. I am not used to this forum and got a bit mixed up.
-
-
-
AuthorPosts
- You must be logged in to reply to this topic.