Adafruit 1085 (ADS1115)

image

If inputs are on the top and outputs are on the bottom of a node, why does the attached node for ADS1115 ADC have analog inputs A0 - A3 on the bottom? Is this correct? The sensor will be attached to an input for the ADC to convert.

I think the confusion is that the ADS1115 chip has input pins. That means the chip reads in values. Arduino/XOD will read those values, and the node you are using will spit out those values, so the node in your XOD program has output pins to return the value of the chip’s input pins. As you switch from hardware to software, the sense of what a “pin” does is going to change. The hardware input pin gets data that you will want to read. The software gets that value from hardware, then “outputs” it to your program.

The same is true in reverse. If you have an output pin on the Arduino, your program needs to send data to it, so any node sending that data will need an input pin to get the data from your program, then it will send that to the hardware output pin.

OK, if that’s the case shouldn’t the labels be D0 - D3? It’s an ADC. Where should the input from the sensor go? Are sensors shown in the XOD? I was going to use an analog sensor node. Is that necessary? What is the point of the A0 - A3, it’s an I2C component? Thank you for the quick response.

The sensor calls them “channels” A0-A3, so the person writing the node for it chose to stick with those names. I2C is the communication protocol used to talk to many peripherals (including this part). How that communication is done and what the returned data means is completely dependent on the part being communicated with. The node you specified above should allow you to read the values the chip sees on its input pins into your program, but only if you specify the correct address for your chip & wire the hardware correctly. What those values mean will depend on what you are connecting to the chip. What you do with those values inside your program is totally up to you. An analog-read or analog sensor node would be for reading from an analog pin on the arduino, which converts the input into a digital number; the chip you are using already does that conversion, so you just need to use the digital number coming from the node above.

It’s starting to sink in a little. Thank you for your patience. The part i can’t get over is the physical module doesn’t have any output pins other than the SCL and SDA for the I2C bus. Are you saying I don’t have to supply the node with inputs in XOD? The module has input pins A0 - A3. Are you curtain the node was constructed right?

Yes. The node is constructed correctly.

I’m starting to have fun with this ADS1115 ADC (no sarcasm). The node is working great! I’m curious why I can’t get the digital output anywhere close to the 16 bit number that Adafruit claims. Even if it were 16 bit divided by the 4 channels (16,384 = 65,536 / 4). It seams closer to the 12 bit ADS1015. I’m currently using only 1 channel, with a gain of 1.5. Will it do any gain between .66 and 16? That was another question I had. The example in Adafruit shows .66 (default), 1, 2, 4, 8, 16. My guess is 1.5 is not a valid gain value? My input voltage (to ADC) is 0.9V - 3.3V. What are your thoughts?

Hi I see you got your board working. Was there some trick to getting the libraries to work properly? I have it working in the Arduino IDE and see data in the Serial Monitor, but in XOD it giving this error

and I definitely have the libraries

I’ve uninstalled XOD, deleted the cached libraries. Reinstalled everything. Tested on Arduino IDE, again, and it works fine.

I try it on XOD, and get the same error.
I’m running with this current node code, updated to the new node style, but still nothing.

#pragma XOD require "https://github.com/adafruit/Adafruit_ADS1X15"
#pragma XOD require "https://github.com/adafruit/Adafruit_BusIO"

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_UPDATE
#pragma XOD error_raise enable


#include <Wire.h>
#include <Adafruit_ADS1115.h>

node{
    
    meta {
        using Type = Adafruit_ADS1115*;
    }
    
void evaluate(Context ctx) {
    if (!isInputDirty<input_UPDATE>(ctx))
        return;

    Number address = getValue<input_ADDR>(ctx);
    Adafruit_ADS1115 ads(address);
    ads.begin();
    auto gain = getValue<input_GAIN>(ctx);
    if(gain==0.66){ads.setGain(GAIN_TWOTHIRDS);}    // 2/3x gain +/- 6.144V  1 bit = 0.1875mV
    else if(gain==1){ads.setGain(GAIN_ONE);}             // 1x gain   +/- 4.096V  1 bit = 0.125mV
    else if(gain==2){ads.setGain(GAIN_TWO);}             // 2x gain   +/- 2.048V  1 bit = 0.0625mV
    else if(gain==4){ads.setGain(GAIN_FOUR);}            // 4x gain   +/- 1.024V  1 bit = 0.03125mV
    else if(gain==8){ads.setGain(GAIN_EIGHT);}           // 8x gain   +/- 0.512V  1 bit = 0.015625mV
    else if(gain==16){ads.setGain(GAIN_SIXTEEN);}        // 16x gain  +/- 0.256V  1 bit = 0.0078125mV
    int16_t buffer;
    buffer=ads.readADC_SingleEnded(0); emitValue<output_A0>(ctx, buffer);
    buffer=ads.readADC_SingleEnded(1); emitValue<output_A1>(ctx, buffer);
    buffer=ads.readADC_SingleEnded(2); emitValue<output_A2>(ctx, buffer);
    buffer=ads.readADC_SingleEnded(3); emitValue<output_A3>(ctx, buffer);
    buffer=ads.readADC_Differential_0_1(); emitValue<output_A0_1>(ctx, buffer);
    buffer=ads.readADC_Differential_2_3(); emitValue<output_A2_3>(ctx, buffer);
    emitValue<output_DONE>(ctx, 1);
};
}

Any advice? I could really use some help.

I replicated the exact same error on a different computer. Looking at the library, it doesn’t look to be anything wrong. And, it works fine on the Arduino IDE. Other people report that this library works. I tried it with two computer and two different boards, Mega and Uno… Same error all the time. Check the libraries were in the right place, tried everything… Can someone confirm that this library is working with the actual Adafruit ADS1115 in XOD?

In the above code you do not have the correct name for the header file. It should be:

Adafruit_ADS1X15.h

Wayland made an amazing library.
https://xod.io/libs/wayland/ads1115/