Trouble making node-red-contrib-iiot-rpi-ads1115 2.0.5 work

Hi, I’m very new to using Node-red and raspberry pi, but have managed to get several sensors working.
Having trouble getting this one to work.
Maybe my wiring is off. Or the way I have it set up. When I loaded the example, it said ads1115 already used. So I am using your ads1115-m because I have already used it for a water level sensor on A2 which works very well.
Any help would be much appreciated. Thanks

Any suggestions @iiot2k

Node-Red and Node.js work as a single task.
Reading all inputs of the ADS1115 takes time.
During this time, Node-Red is blocked.
That's why I read the inputs of the ADS1115 asynchronously.
You have to imagine that if you have several ADS1115 on the I2C bus, you have to synchronize the read access, since only one read access is possible on the I2C bus at the same time.
I'm working on the next version to add I2C ports (/dev/i2c-1 ..).
It takes a lot of effort to synchronize everything.
Yes, you need several ADS1115 on different ports for the test.
But I still don't understand the problem.
But put your flow here as JSON.
How did you connect the ADS1115 to the Raspberry Pi?

[
    {
        "id": "e0930a1136dcddae",
        "type": "function",
        "z": "ab9e56b06c521566",
        "name": "Calculate Water Level",
        "func": "\n\n\nconst emptyValue = 2070\nconst fullValue = 520\n\nconst percentage = (value) => {\nreturn ((value - emptyValue) / (fullValue - emptyValue))\n}\n\n\n\nmsg.payload = Math.round(percentage(msg.payload) * 100);\n\n\n\nreturn msg;\n\n\n\n",
        "outputs": 1,
        "timeout": "15",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 420,
        "y": 480,
        "wires": [
            [
                "2a3ada6c6804faaa",
                "3da75e84395b2418"
            ]
        ]
    },
    {
        "id": "2a3ada6c6804faaa",
        "type": "debug",
        "z": "ab9e56b06c521566",
        "name": "Water Level",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 750,
        "y": 440,
        "wires": []
    },
    {
        "id": "3da75e84395b2418",
        "type": "ui_gauge",
        "z": "ab9e56b06c521566",
        "name": "",
        "group": "7884bf978a436956",
        "order": 1,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "Water Level",
        "label": "%",
        "format": "{{value}}",
        "min": "0",
        "max": "100",
        "colors": [
            "#ca3838",
            "#e6e600",
            "#00b500"
        ],
        "seg1": "25",
        "seg2": "50",
        "diff": false,
        "className": "",
        "x": 910,
        "y": 500,
        "wires": []
    },
    {
        "id": "4d9f073991ea48c8",
        "type": "iiot-ads1115-m",
        "z": "ab9e56b06c521566",
        "devadr": "0",
        "tupdate": 100,
        "mux0": "4",
        "rate0": "4",
        "gain0": "2",
        "rawdata0": true,
        "enabled0": true,
        "mux1": "5",
        "rate1": "4",
        "gain1": "2",
        "rawdata1": true,
        "enabled1": true,
        "mux2": "6",
        "rate2": "4",
        "gain2": "0",
        "rawdata2": false,
        "enabled2": true,
        "mux3": "7",
        "rate3": "4",
        "gain3": "2",
        "rawdata3": false,
        "enabled3": false,
        "x": 140,
        "y": 460,
        "wires": [
            [
                "4602ab4544a7522d"
            ],
            [
                "4602ab4544a7522d"
            ],
            [
                "e0930a1136dcddae"
            ],
            []
        ]
    },
    {
        "id": "eb0d68430d47c416",
        "type": "ui_gauge",
        "z": "ab9e56b06c521566",
        "name": "",
        "group": "131e1b13ec654f82",
        "order": 0,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "voltage",
        "label": "V",
        "format": "{{value}}",
        "min": 0,
        "max": "50",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "diff": false,
        "className": "",
        "x": 540,
        "y": 260,
        "wires": []
    },
    {
        "id": "3ec8496a3622228c",
        "type": "ui_gauge",
        "z": "ab9e56b06c521566",
        "name": "",
        "group": "131e1b13ec654f82",
        "order": 0,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "current",
        "label": "A",
        "format": "{{value}}",
        "min": 0,
        "max": "5",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "diff": false,
        "className": "",
        "x": 540,
        "y": 220,
        "wires": []
    },
    {
        "id": "2923f939ef788210",
        "type": "ui_gauge",
        "z": "ab9e56b06c521566",
        "name": "",
        "group": "131e1b13ec654f82",
        "order": 0,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "power",
        "label": "W",
        "format": "{{value}}",
        "min": 0,
        "max": "250",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "diff": false,
        "className": "",
        "x": 530,
        "y": 300,
        "wires": []
    },
    {
        "id": "4602ab4544a7522d",
        "type": "function",
        "z": "ab9e56b06c521566",
        "name": "calculate",
        "func": "// Rounds number to fix decimal after point.\n// https://www.jacklmoore.com/notes/rounding-in-javascript/\nfunction toFix(value, decimals) {\n    return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals);\n}\n\n// scale raw data to engineering value\nfunction scale(raw_value, input_min, input_max, output_min, output_max)\n{\n    var factor = (output_max - output_min) / (input_max - input_min);\n    var offset = output_min - (input_min * factor);\n    return (raw_value * factor) + offset;\n}\n\nvar current = scale(msg.payload[0], 0, 2048, 0, 5);\nvar voltage = scale(msg.payload[1], 0, 2048, 0, 50);\nvar power = current * voltage;\n\nreturn [\n    { payload: toFix(current, 1) }, // output 1\n    { payload: toFix(voltage, 1) }, // output 2\n    { payload: toFix(power, 2) }    // output 3  \n];\n\nreturn msg",
        "outputs": 3,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 360,
        "y": 260,
        "wires": [
            [
                "3ec8496a3622228c"
            ],
            [
                "eb0d68430d47c416"
            ],
            [
                "2923f939ef788210"
            ]
        ]
    },
    {
        "id": "7884bf978a436956",
        "type": "ui_group",
        "name": "Water Tank",
        "tab": "9ecefeb346417832",
        "order": 4,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "131e1b13ec654f82",
        "type": "ui_group",
        "name": "Tankless Water Heater",
        "tab": "9ecefeb346417832",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "9ecefeb346417832",
        "type": "ui_tab",
        "name": "RV",
        "icon": "Temperature",
        "disabled": false,
        "hidden": false
    }
]

Please dont connect the ads1115 to the 5V of Rpi.
On the ads1115 module the pullup resistors are connected to 5V.
You can damage the i2c pins.
Use a level shifter if you supply the ads1115 module with 5V.
The voltage sensor divide the input voltage to lower voltage. A 1.5V battery voltage is too low for measurement.

Thanks for the warning. I followed that example, except I had used the 3.3volt.
I have tried to read a 12volt battery as well, but I am not getting any readings at all.

I think you may have damaged the ADS1115 by connecting a 12V battery to one of the input pins. Have you got another ADS1115 you could try after correcting the wiring >>> I would power the ADS1115 from 3.3V not 5V (as also mentioned by @iiot2k above).

The ADS1115 and ADS1015 4-channel breakout boards are perfect for adding high-resolution analog to digital conversion to any microprocessor-based project. These boards can run with power and logic signals between 2v to 5v, so are compatible with many 3.3v and 5v processors. However, take note of the following I found. You can ignore the picture of the Arduino - that was just an illustration in the link I found on the web. It's the warning that's the important fact. Maximum analog input is VDD +0.3V

My IoT students used an ADS1115 in their Solar-Powered Weather Station project 3 or 4-years ago.
Although they used a Wemos D1 Mini (rather than a RPi) and powered the ADS1115 from 3.3V, their wiring was similar to yours except they didn't use the ALRT and ADDR connections. They also used simple 2:1 voltage-divider networks (two resistors in series) on all four inputs. Here's part of their schematic.

EDIT: Just found this link which might help with the wiring.

Scroll down in the article and read the section headed... Interfacing ADS1115 Module with Raspberry Pi

2 Likes
  • Check with the command i2cdetect -y 1 whether the ads1115 is accessible.
  • If yes, check address
  • If No Check whether I2C SDA and SCL are connected correctly.
  • Apply a small voltage (e.g 1.5V) to the various inputs of the ads1115 and check whether the node can read it.

Possible causes:

  • ads1115 defective
  • I2C inputs on the Raspberry Pi are defective.

For such applications I always use an INA219 module.
The module also measures current and power.

1 Like

Thanks for your help. Much appreciated.
No idea why my sensor wouldn’t work on the Ads1115. My other float sensor works fine on all A0-A3 pins.
So I went with the suggestion to use the INA219 sensor. No problem connecting it to the Rpi4 with the ads1115 and it works great.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.