# @redplc/node-red-rpi-ads1115

[![platform](https://img.shields.io/badge/platform-Node--RED-red)](https://nodered.org)
[![platform](https://img.shields.io/badge/platform-redPlc-ffa500)](https://flows.nodered.org/node/@redplc/node-red-redplc/)
[![platform](https://img.shields.io/badge/platform-Raspberry--Pi-ff69b4)](https://www.raspberrypi.com/)

Node-RED node for [ads1115](https://www.ti.com/product/ADS1115) 16bit adc using with [redPlc](https://www.npmjs.com/package/@redplc/node-red-redplc/) nodes

## ads1115 analog to digital converter
- 16bit Conversion Resolution.
- Four Analog Inputs.
- Each input can be selected Single-Ended, Differential or Disabled.
- Internal Voltage Reference.
- Internal Oscillator.
- Programmable Data Rate 8 SPS to 860 SPS.
- The PGA offers input ranges from ±256 mV to ±6.144 V.
- I2C Interface with Four Pin-Selectable Addresses.

## Usage
- Install [redPlc](https://www.npmjs.com/package/@redplc/node-red-redplc/) nodes.
- Use redPlc s-inject node for trigger update.
- Connect to first output on s-inject node.
- Daisy chain nodes in series.
- For logical operations use redPlc nodes. 
- Data is exchanged with global context variable arrays.
- Array index is equal input number for easy handling.
- This node works on Raspberry Pi with 32bit or 64bit OS.
- Input voltage more than VCC can damage adc input.
- The output value is mV or adc raw data.
- Works also on Raspberry Pi 5
- Enable I2C with raspi-config.
- In this case i2c-1 is enabled.
- If you use i2c-0 port add<br>
  **dtparam=i2c_vc=on**<br>
  to /boot/config.txt,<br>
  then Pin27=SDA, Pin28=SCK.<br>
- For other ports add this to /boot/config.txt.

## Array Index Mapping

|Input|Array-Index|
|:----|:---:|
|A0|0|
|A1|1|
|A2|2|
|A3|3|

## Address Pin Connection To

|I2C Address|ADDR Pin|
|:----|:---|
|48H|GND or open|
|49H|VCC|
|4AH|SDA|
|4BH|SCL|


## Example
This example gets voltage and current from ADC and displays on Dashboard.<br>
The module node ads1115 is set for input A0 and A1 to Input-Range 2048mV.<br>
Other adc inputs are disabled.<br>
2048mV is equal 50V on input A0 and 5A on input A1.<br>
In rung **01** the adc values are scaled to voltage and current<br>
and stores in analog variable MA0.0 and MA0.1.<br>
Input scale MIN is **0** and **MAX** is 2048.<br>
Output scale MIN is **0** and **MAX** is 50 (V) for voltage (input A0).<br>
Output scale MIN is **0** and **MAX** is 5 (A) for current (input A1).<br>
The redPlc export nodes reads the analog variables and sends to Dashboard gauge.  
