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

Logging Mayfly with Decagon SDI-12 Sensor

Home Forums Mayfly Data Logger Logging Mayfly with Decagon SDI-12 Sensor

Tagged: , ,

Viewing 12 reply threads
  • Author
    Posts
    • #2129
      Sara Damiano
      Moderator

        Several people have asked about how to get a Decagon CTD or other SDI-12 sensor logging with the Mayfly, so I’m trying to put together a list of steps to help everyone out. Our convention at here at the Stroud Center is to plug all SDI-12 sensors into the D6-7 jack (J6) with pin 7 as our SDI-12 data pin. These instructions are written to follow that.

        The first step is to decide how you’re going to connect the sensor to your Mayfly. The easiest way is to make use of the white Grove jacks on the bottom of the Mayfly board. Here are some ways to adapt your sensor to the Grove jacks without using a soldering iron.

        For a bare wire sensor: (ie, Decagon 5TM)
        — Buy a $2.90 Grove 4-port screw terminal adapter: https://www.seeedstudio.com/Grove-Screw-Terminal-p-996.html and some Grove cables: https://www.seeedstudio.com/Grove-Universal-4-Pin-Buckled-20cm-Cable-%285-PCs-pack%29-p-936.html
        — Connect your sensor’s ground wire to ground on the screw terminal adapter. If you are holding the screw terminal adapter with the green screw terminal on the top and the white grove jack on the bottom, the ground pin is all the way on the right.
        — Connect your sensor’s power wire to Vcc. This is next to the ground.
        — Connect your sensor’s data wire to D2, which is next to Vcc. [This is Stroud convention, D1 can also be used.]
        — If your sensor has a braided shield wire, either cut it or connect it with ground.
        — Use the Grove cable to connect the screw terminal adapter to the D6-7 Jack (J6).

        For a sensor with a stereo cable: (ie, Decagon CTD or Decagon ES2)
        — Buy a 3.5mm stereo female TRS jack to terminal adapter, such as this one: https://smile.amazon.com/Cerrxian-Terminal-Headphone-Converter-Adapter/dp/B06W2KB8ZV and a 4 pin male jumper to Grove cable: https://www.seeedstudio.com/Grove-4-pin-Male-Jumper-to-Grove-4-pin-Conversion-Cable-%285-PCs-per-Pack%29-p-1565.html
        — Put the black wire from the Grove conversion cable into the ground on the jack-to-terminal adapter. The jumpers can be inserted and tightened into the screw terminal just like wires.
        — Put the red wire into the “R” (ring/right) slot on the terminal.
        — Put the white wire into the “T” (tip) or “L” (left) slot on the terminal. (Which letter appears on the terminal might depend on the brand.)
        — Fold and secure the white yellow wire out of the way.
        — Plug the Grove cable into the D6-7 Jack (J6).

      • #2130
        Sara Damiano
        Moderator

          Up to 61 SDI-12 sensors can be connected to the same pin of the Mayfly. It is more stable to use the same pin for all the SDI-12 sensors you wish to connect rather than using different pins for each because this allows you to create only one instance of the SDI-12 object in your code. To connect multiple sensors to that pin, you can use a Grove branch cable (https://www.seeedstudio.com/Grove-Branch-Cable-%285PCs-pack%29-p-847.html) or a Grove hub (https://www.seeedstudio.com/Grove-I2C-Hub-p-851.html).

        • #2133
          Shannon Hicks
          Moderator

            Another option for connecting a sensor’s 3.5mm stereo headphone plug is to use these stereo jacks:
            https://www.amazon.com/uxcell-Stereo-Female-Adapter-Connector/dp/B013D1U90S
            Just strip the black, red, and white wires of a Grove cable and solder them to the corresponding terminals of the jack.

            And the easiest way to do it is to use our custom Grove-to-3.5mmStereoJack adapter board:
            http://envirodiy.org/wp-content/uploads/grove_stereo.jpg
            We hope to have these in our Amazon store later in April.

            • #2138
              Sara Damiano
              Moderator

                Yup, doing the soldering will make your 3.5mm jack connection much prettier and more secure than using the screw terminals. If you’re skilled with a soldering iron, it’s the way to go.

                If you’re skill-less and solder-less like I am, the jacks with screw terminals are a solution.

            • #2134
              Sara Damiano
              Moderator

                Once you have physically connected your sensor to your Mayfly board, the next step is to download the library to communicate with the it from GitHub. If you are only interested in the SDI-12 library, download it here: https://github.com/EnviroDIY/Arduino-SDI-12/archive/master.zip. If you would like to download a collection of libraries that might be useful in communicating with and logging data from sensors, including the SDI-12 library, download this: https://github.com/EnviroDIY/Libraries/raw/master/libraries.zip.

                To install the libraries into the Arduino IDE, follow the instructions for Manual Installation on the Arduino library guide: https://www.arduino.cc/en/guide/libraries. If you are using PlatformIO you can install only the SDI-12 library using the terminal prompt command: platformio lib -g install “Arduino-SDI-12” or the entire collection of libraries using the command: pio lib -g install https://github.com/EnviroDIY/Libraries.git#platformio. For another IDE, follow the installation instructions for that IDE.

                If you have not yet downloaded any IDE or program to communicate with your Mayfly, I highly recommend PlatformIO over the IDE created by Arduino.cc

              • #2135
                Sara Damiano
                Moderator

                  The next step is to set the SDI-12 address of the sensor. Communication with the sensor depends on its 1-character alphanumeric address (1-9, A-Z, a-z). Unfortunately, Decagon ships all of its sensors programmed to an SDI-12 address of 0, which cannot be used to get measurements from the sensor.

                  Within the SDI-12 library on GitHub, there is an example with instructions for changing the address. Find it here: https://github.com/EnviroDIY/Arduino-SDI-12/tree/master/examples/b_address_change

                • #2136
                  Sara Damiano
                  Moderator

                    Now that your sensor is connected and has an address set, you can get data from it using code like this:

                    Once you have an array of values from the sensor, you can save them to an SD card or anything you’d like.

                  • #2137
                    Sara Damiano
                    Moderator

                      If you would prefer, you can also look into the Modular Sensors library, which has functions already built into it for getting data from a Decagon CTD, a Decagon ES2, and a Decagon 5TM and then logging that data to a SD card.

                      If you downloaded the full package of libraries I mentioned in #2134, the Modular Sensors library is already included in it. If not, you download the zip at https://github.com/EnviroDIY/ModularSensors/archive/master.zip and unzip that for the Arduino IDE or install in PlatformIO using “pio lib -g install https://github.com/EnviroDIY/ModularSensors.git”.

                    • #2139
                      Sara Damiano
                      Moderator

                        One more thing: If you’re going to use your Mayfly as a logger, make sure you set the real time clock first! I’ve written a sketch and tiny executable to synchronize the Mayfly with your computer clock. You can find it here: https://github.com/EnviroDIY/Sodaq_DS3231/tree/master/examples/PCsync

                      • #14480
                        scornia
                        Participant

                          Hi Sara,

                          I am having issues when I come to this step and can use a little help troubleshooting my issue. I cannot get my sensor to connect to an address. I have an SDI-12 sensor with bare wires connected to grove 4-pin terminal adapter set up just as you explained in the instructions. All of the connections seem secure, but when I run the b_address_change sketch, it continuously runs through every slot saying “vacant” and gives the message “No sensor connected. Check physical connection.”

                          I am not sure what the issue could be and was wondering if you may have any ideas.

                          Thanks,

                          Steve

                           

                          • #14484
                            neilh20
                            Participant

                              Just an FYI,  as I understand the SDI-12 spec, the receiving instrument should receive 3.5V for a ‘0’ or space.   The mayfly port is only capable of supplying 3.3V – so it may work for most SDI-12 instruments, and is working for one SDI-12 instrument I’m using

                              Typically with off-spec issues, things can work on some instruments and then not  on others. So hopefully the problem is something simple, but just sharing my analysis.

                            • #14491
                              Shannon Hicks
                              Moderator

                                Check your wiring, the Meter group CTD sensor has a red wire for the data (signal) wire, white is positive voltage, and black is ground. It’s kind of backwards from most common DC sensor wires where red is usually the voltage supply wire. I’ve confirmed with the folks at Meter that the sensor works just fine at 3.3v.

                                • #14492
                                  scornia
                                  Participant

                                    Our wiring looks to be correct. We talked with the folks at Meter and they had us test the voltage across the board which seemed fine. They are sending us an independent tester to see if it is an issue with the sensor itself.

                                  • #14498
                                    Shannon Hicks
                                    Moderator

                                      Can you post a picture of your sensor wiring showing how it’s connected to the terminal board and also a photo showing how it’s connected to the Mayfly? Did you make any changes at all to the address changing sketch? I’ve personally used almost 500 sensors (CTD, soil moisture, conductivity, etc) from Meter group and have never had a bad one right out of the box, so I have a feeling that the problem is likely in the wiring or the board configuration.

                                    • #14503
                                      scornia
                                      Participant

                                        Sure, no problem. I didn’t make any changes to the change address sketch. The  Here is what I am looking at:

                                      • #14506
                                        Shannon Hicks
                                        Moderator

                                          Thanks for the photo. The screw terminal pic looks fine, on pic of the Mayfly, it’s hard to see the jumper pins for the D6-D7 grove jack, but can you verify that there is a jumper (shunt) on the pins as seen in this photo.

                                        • #14510
                                          scornia
                                          Participant

                                            It looks like they are all there. Here is a better photo from a different angle.

                                      • #14488
                                        neilh20
                                        Participant

                                          I have come up with an inline  plug-in circuit that will do the voltage shifting ( and  generate a +12V power and ESD protection)  that I’m working on, so just mentioning it here. If anybody is interested in the discussion we could take it to a separate thread.

                                        • #14532
                                          BrianJastram
                                          Participant

                                            scornia,

                                            I was having the same problem with the address change sketch (using the Atom PlatforIO) so I tried using Arduino IDE and that worked. It saw the SDI-12 address of 0 at pin 7 and I successfully changed it to 1 and now I’m getting values from the Meter CTD-10. Good luck. Let me know if you have any questions.

                                          • #15606
                                            Selbig
                                            Participant

                                              I am able to retrieve values from my Decagon ES2 sensor, but only temperature. Conductivity comes back with a value of 0.0. When I hook it up to a Campbell Scientific CR1000 logger, both conductivity and temperature come back with reasonable values. In fact, temperature is the same using the CR1000 as it is the Mayfly. I’m using the pre-programmed code for the Decagon from modular-sensors (see below). Any idea why the second location in the SDI array is returning but not the first?

                                               

                                              • #15607
                                                Shannon Hicks
                                                Moderator

                                                  I’d need to see the rest of your sketch to make sure everything else is set up correctly for reading the sensor properly.  Can you post your entire sketch, and tell me what version of the Modular Sensors library you’re using, and when you downloaded the other recommended supporting libraries like the EnviroDIY_SDI12  library?

                                              • #15609
                                                Selbig
                                                Participant

                                                  I was able to get it to work correctly. The only thing I changed was removal of the UUIDs for all of the variable pointers. I also moved the voltage pin so D7 was getting 5v instead of 3.3. I don’t know if that was what caused the initial error but it’s working now.

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