Logging Mayfly with Decagon SDI-12 Sensor

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

Tagged: , ,

This topic contains 8 replies, has 2 voices, and was last updated by Profile photo of Sara Damiano Sara Damiano 2 months, 3 weeks ago.

  • Author
    Posts
  • #2129
    Profile photo of Sara Damiano
    Sara Damiano
    Participant

    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
    Profile photo of Sara Damiano
    Sara Damiano
    Participant

    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
    Profile photo of Shannon Hicks
    Shannon Hicks
    Keymaster

    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:
    https://envirodiy.org/wp-content/uploads/grove_stereo.jpg
    We hope to have these in our Amazon store later in April.

    • #2138
      Profile photo of Sara Damiano
      Sara Damiano
      Participant

      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
    Profile photo of Sara Damiano
    Sara Damiano
    Participant

    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
    Profile photo of Sara Damiano
    Sara Damiano
    Participant

    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
    Profile photo of Sara Damiano
    Sara Damiano
    Participant

    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
    Profile photo of Sara Damiano
    Sara Damiano
    Participant

    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
    Profile photo of Sara Damiano
    Sara Damiano
    Participant

    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

You must be logged in to reply to this topic.