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: Optical dissolved oxygen solutions?

Home Forums Environmental Sensors Optical dissolved oxygen solutions? Reply To: Optical dissolved oxygen solutions?

Sara Damiano

    You’re not “overwriting” the serial connection.  The USB connection on the SAMD21 is a bit touchy and will fail if anything in the program fails.  In you’re program in lines 117 and 119 you’re calling Serial.println(...) and asking it to print the results of a function that returns void.  That’s most likely causing the crash.  It probably would be OK on an AVR board, but the SAMD21 is less forgiving.

    Why don’t you start with the current version of the GetValues example from the YosemitechModbus library:  https://github.com/EnviroDIY/YosemitechModbus/blob/master/examples/GetValues/GetValues.ino.  It’s very different from what you had.  From there:

    • delete line 16 (#include <AltSoftSerial.h>) and
    • replace line 44 with HardwareSerial& modbusSerial = Serial1;
    • in lines 33, use your real pin number controlling the Y4000 power, or -1 if you have it straight to a battery (and make sure the sonde really is powered!)
    • in line 34, set the adapterPwrPin to -1; the shield you have is always powered
    • in line 35, set the DEREPin to A4 or A5 (and make sure they’re tied together)

    See if that compiles and runs.  Make sure your serial monitor is set to 115200.

    After your getting some output, if you’re not getting values or the values are garbled or unreasonable, try adding the line sensor.setDebugStream(&Serial) right below the sensor.begin(..) in line 67.  Then post that output.