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

Can't read/store values from Yosemitech using WingShield

Home Forums Mayfly Data Logger Can't read/store values from Yosemitech using WingShield

Viewing 5 reply threads
  • Author
    Posts
    • #13149
      rachel.murray
      Participant

        Hello and greetings from New Zealand,

        My work group is developing some mayfly loggers and we have run into a problem using Modbus with a Yosemitech Y4000 sensor, measuring pH, conductivity, temperature, turbidity, and dissolved oxygen. We are attempting to communicate to this device using the WingShield and Modbus (as described on the EnviroDIY github) on the Mayfly. We have were able to successfully read data off of this unit for a while, but then, seemingly with no changes made to the code, we started getting a reading of -9999.00 for all of the sensors.

        With additional fiddling, the problem got worse, and now it seems that when the mayfly tries to read and log the sample, the program just restarts from the beginning.

        We are able to connect and read values off of the sensors using the GetValues.ino script in the YosemitechModbus library. However when we try to run a logging script based on the ModularSensors library, everything falls apart. I think it has to be a library issue, where my code just isn’t playing nice with one of the libraries in the EnviroDIY universe. I am using platformio with the libraries included in the ‘libraries’ enviroDIY repository.

        I will test it again soon and collect additional debugging info, but I thought I would just post about it now in case anyone has been having similar issues lately. Attached is a screen shot of what happens when the logger tries to save the data, and here is a recent iteration of the code I am trying to use:

        Attachments:
      • #13151
        Anthony Aufdenkampe
        Participant

          @rachel.murray, that’s great to hear that you were able to get the YosemiTech Y4000 sonde working with our Modbus Mayfly Wing Shield and associated documentation. I developed all of that for a team at Winona State University in Minnesota, but I hadn’t been aware of anyone else trying to integrate the Y4000 with our EnviroDIY stack. So that’s satisfying to hear that you got it working, for a while.

          BTW, are you working with my friend Troy Baisden?

          I will say that the Y4000 sonde is the one sensor from YosemiTech that has given me headaches to get working and also to keep working. Unfortunately I haven’t kept up with documenting everything.

          The first challenge with the Y4000 is that it needs a stable and consistent 12V of power with the capacity for high amperage draw during startup and when the brush is spinning. I was able to barely get it to work on the Mayfly with the Modbus Wing + two 680 uF capacitors, but only when no other sensors were attached. The system was browning out when I attached other sensors, and I’m guessing that if the radio were drawing power while the Y4000 is on that would also brown out the system.

          The solution was to wire up an independent 2 Amp 12V power supply that is switched on & off by the Mayfly. While the power for the Y4000 system comes from this separate power supply, the Modbus communication still passes through the Wing Shield. None of this is publicly documented yet, but here are my notes:

          Redo Y4000 line, with built-in power regulation and switching

          Overview of connections
          – Battery to Pololu Power Switch HP to control by Mayfly
          Pololu 12V Voltage Regulator to Sonde

          Details
          Pololu Big Pushbutton Power Switch with Reverse Voltage Protection, HP,
          Battery Side:
          – Vin to battery +, This powers the system
          – GND to Battery
          Sonde side (via regulator)
          – Vout to 12V regulator Vin
          – GND to 12V regulator GND
          Mayfly Control side
          – CTRL to Mayfly switched power (Setting D10)
          – GND to system/Mayfly ground

          Pololu 12V Step-Up/Step-Down Voltage Regulator S18V20F12
          Battery Side (via switch)
          – Vin to switch Vout
          – GND to switch GND
          Sonde side
          – Vout to Sonde red
          – GND to Sonde black

        • #13158
          rachel.murray
          Participant

            Thanks for the reply,

            Yes, I am working with Troy :). We have had some success with the decagon CTD, including using a wifibee and portable wifi hotspot to log data to monitormywatershed.org. It would be nice to have turbidity measurements as well, which is one reason we are interested in the Y4000 device.

            In our y4000-mayfly setup, I have tried removing the wifibee modem, along with the associated code. I have also tried running with and without other sensors. We are currently testing using an external 12V power supply to power the y4000 (left on constantly for testing purposes). Regardless of the setup, the result is the same – the mayfly can’t seem to communicate with the sensor.

            The mayfly reboots right after attempting to activate the brush. This makes a brownout seem like a likely problem, however connecting to an external 12V supply doesn’t seem to help. I’m wondering if there might be some sort of problem with the serial connection using Altsoftserial.

            I’m going to try a few more tests and report back – are there any particularly useful debugging flags that could shed some light on the problem?

            Thanks for your help,

            Rachel

          • #13163
            Shannon Hicks
            Moderator

              It’s hard to tell exactly what’s going on with your wires from the photo, but you should make sure your separate power supplies are sharing a common ground. If you’ve got 12v going to the sensor and 5v going to the board, you need to have the ground of both of those supplies (or batteries) connected to the same ground as the Mayfly.

            • #13239
              rachel.murray
              Participant

                We have made sure that the power supplies are sharing the same ground. There seems to be some issue with the serial connection to the modbus, maybe related to a conflict in the libraries that handle the physical and software serial connections.

                We are able to read values using SoftwareSerial as the Modbus serial connection and the ‘GetValues.ino’ script on the EnviroDIY Github (YosemitechModbus/Examples/GetValues), and we can also read values using a similar script with NeoSWSerial as the Modbus serial. However, we are unable to retrieve values using AltSoftSerial at all.

                The software serial connections only work when I am running a simple test script that references the YosemitechModbus library. As soon as I try to run a logging script and reference the ModularSensors library, I can’t read any values off the Y4000, using either the modified SoftwareSerial library or NeoSWSerial. The brush is activated and then the serial output has some odd characters (sometimes it says ‘connection failed’) and then the script re-starts.

                I have attached the output from the logging script, as well as the outputs from the ‘GetValues.ino’ script.

              • #13247
                Sara Damiano
                Moderator

                  Where is the extra red (5V?) wire in your pictures from September connected? It looks like you have the Yosemetich connected to one 12V power supply (red line at the bottom), the Mayfly powered by second 5V power supply (the black/red twisted pair?) and then the Mayfly also connected to the computer’s USB. But then I can’t figure out the extra wire. You’re sure everyone’s sharing a ground? (I know you already checked, but it’s worth checking again.)

                  Do you have an RS485 adapter that isn’t attached to a “WingShield” that you could test with? I don’t expect that the wing is the problem, but using the raw adapter would completely eliminate it from suspicion.

                  If you can use an RS485 adapter that hasn’t been built into a wing, connect it to Serial1. The hardware serial port is *always* better than any software version and using it eliminates any questions the serial libraries. We’ve had some sensors that absolutely refused to talk over anything but hardware serial.

                  AltSoftSerial should not (generally) conflict with much else. It uses timer capture interrupts rather than pin change interrupts that other software serial libraries use. But using too many libraries that define interrupts of any type can cause some headaches with serial communication because the timing is really important and even well written interrupt routines can throw the timing off enough to cause it to be garbled. In my experience AltSoftSerial *is* the very best alternative to hardware serial. I don’t think I ever succeed in communicating with the Yosemitech’s over the version of SoftwareSerial that’s been modified to play with the rest of ModularSensors – it’s just not accurate enough. I’m really surprised your experience has been the opposite.

                  Once you can get the GetValues example to run smoothly, try running modular sensors with the build flags for the variable array turned on. (MS_VARIABLEARRAY_DEBUG and MS_VARIABLEARRAY_DEBUG_DEEP) that might give me a better idea of where ModularSensors is crashing.

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