ads1115-device

wayland/ads1115/ads1115-device

An ADS1115 device.
ads1115-device
@/ads1115-device
An ADS1115 device.
I2Cxod/i2c/i2c
I²C bus
ADDRbyte
I²C address
ads1115-device
I2C
ADDR
DEV
DEV@/ads1115-device
An ADS1115 device.
To use the node in your project you should have the wayland/ads1115 library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

// Tell XOD where it can download the libraries:
#pragma XOD require "https://github.com/adafruit/Adafruit_ADS1X15"

//Include C++ libraries
#include <Adafruit_ADS1X15.h>
#include <Wire.h>

node {

    meta {
        // Define our custom type as a pointer on the class instance.
        using Type = Adafruit_ADS1115*;
    }

    // Create an object of class Adafruit_ADS1115
    Adafruit_ADS1115 sensor = Adafruit_ADS1115();

    void evaluate(Context ctx) {
        // It should be evaluated only once on the first (setup) transaction
        if (!isSettingUp())
            return;

        auto wire = getValue<input_I2C>(ctx);
        auto addr = getValue<input_ADDR>(ctx);
        
        // Try to initialize sensor
        if (!sensor.begin(addr, wire)) {
            raiseError(ctx);
            return;
        }
        emitValue<output_DEV>(ctx, &sensor);
    }
}