Home › Forums › Mayfly Data Logger › Looking for a bare-bones 16 bit 0-5V dc data logger sketch to build off of
Tagged: ADD converter, analog signal, mayfly
- This topic has 3 replies, 3 voices, and was last updated 2017-12-28 at 12:59 AM by ChanCafun.
-
AuthorPosts
-
-
2017-01-23 at 1:12 PM #1936
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.
-
2017-01-23 at 1:24 PM #1937
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!)
1234567891011121314#include <Adafruit_ADS1015.h> /* The library for the auxiliary ADD */Adafruit_ADS1115 ads; /* Use this for the 16-bit version */int16_t adc0, adc1; // adc2, adc3; /* Tells which channels are to be read */// Read Channelsadc0 = ads.readADC_SingleEnded(0);adc1 = ads.readADC_SingleEnded(1);// now convert bits into millivoltsfloat lowvoltage = (adc0 * 3.3) / 17585.0;float highvoltage = (adc1 * 3.3) / 17585.0; -
2017-01-23 at 6:43 PM #1938
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.
-
2017-12-28 at 12:59 AM #2467
Hi,
The schematic ADC’s name printed as ADS1105 but not ADS1115.
Attachments:
-
-
AuthorPosts
- You must be logged in to reply to this topic.