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

Looking for a bare-bones 16 bit 0-5V dc data logger sketch to build off of

Home Forums Mayfly Data Logger Looking for a bare-bones 16 bit 0-5V dc data logger sketch to build off of

Viewing 3 reply threads
  • Author
    Posts
    • #1936
      Sara Damiano
      Moderator

        Converting a message/update from Paul Dyer into a forum post:

        I am working on an application to log data from some magnetic flow meters measuring liquid flow in some 15 foot diameter circulating water lines. I have my application built and tested. It seems to work fine with the exception of being able to use the high resolution(16 bit) A/D converter. I am trying to use AA0 (silkscreen) or AIN0(diagram). I can not find any examples or documentation on how to make the call or process the data. If it is not too much trouble, I would appreciate it if you could send me a short sketch showing how to get this data.

      • #1937
        Sara Damiano
        Moderator

          How are you trying to talk to the analog pins? To get the 16 bit ADD conversion you must use the auxiliary ADD converter/library for the Ti ADS 1115. Here’s a bit of code that may help you along. (Please note that this code is completely the work of Shannon Hicks!)

        • #1938
          Shannon Hicks
          Moderator

            The auxiliary A/D converter on the Mayfly is a ADS1115, so I prefer to use the Adafruit library for interacting with it (https://github.com/adafruit/Adafruit_ADS1X15). It uses the I2C port with the default address of 0x48. If you want to add other external ADS1x15 chips, just set the address on any additional chips to 0x49, 0x4A, or 0x4B.

            See the library examples for how to do single-ended or differential measurements. You can also adjust the gain or sampling frequency, but I usually use the default gain of 2/3, like in the example that Sara quoted above, which is why there’s a formula for converting bits into millivolts. At the default gain, the Mayfly’s aux ADC is 1 bit = 0.1875mV.

            Keep in mind that because the Mayfly operates at a Vcc of 3.3v, you can’t safely measure any voltage higher than 3.3v or you will damage the ADC. The Mayfly has a set of small jumper pins next to the Grove connectors for choosing either 3.3v or 5v is on the “V” pin of the Grove connector (see the second half of this page: http://envirodiy.org/mayfly/hardware/jumper-settings/). We did this because we typically use the Mayfly with sensors that require 5v for excitation, but only output a signal from 0-2.5v, so we’re not at risk of over-voltage on the measured signal pin. So if you’re connecting a sensor with 0-5v output, you’re going to need to scale the output by 2/3 to protect the Mayfly’s ADC.

            As I mentioned in this thread (http://envirodiy.org/topic/datalogging-cyclops-rhodamine-wt-sensor/), there are at least 2 ways to measure 0-5v analog signals with your Mayfly:

            As for measuring the output of the sensor, there are a couple different options. One would be to put the sensor output across a resistor divider that drops the 5v to 3.3v (i.e. a 10k and 20k resistor in series across the sensor output, so when the sensor outputs a max of 5v, the voltage between the two resistors is 2/3 of that, which is 3.3v). Or you could add a separate ADC board (like the Adafruit ADS1115 breakout board). Power the breakout board from the 5v switched output of the Mayfly and then it will be able to handle a max input of 5v. But you’d need to connect the breakout to the I2C port of the Mayfly, so you’d need to add some digital level-shifting on those 2 I2C lines to protect the Mayfly from higher voltage of the breakout. I’m sure there are a few other methods, but those are the two quickest and easiest.

          • #2467
            ChanCafun
            Participant

              Hi,

              The schematic ADC’s name printed as ADS1105 but not ADS1115.

              Attachments:
          Viewing 3 reply threads
          • You must be logged in to reply to this topic.