logo elektroda
logo elektroda
X
logo elektroda

ADS1115 or ADC 16-bit 4 channels - Arduino, communication protocol, visualisation

p.kaczmarek2 2052 5
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • ADS1115 module connected to an Arduino board using colorful wires. .
    Here I will introduce the ADS1115, which is a 4-channel, 16-bit ADC. The ADS1115 is available to buy in our country for a dozen or so zlotys, and can be imported from abroad for up to half the price. The ADS1115 uses the I2C protocol, so it is possible to connect as many as four separate such modules on a single bus, thus obtaining 16 ADC channels. The ADS1115 also offers differential operation and a programmable gain value, allowing small voltage variations to be measured.
    ADS1115 module with pins and integrated circuit. .
    I have included a diagram of the popular commercially available ADS1115 module below:
    Electrical schematic of the ADS1115 module with visible connections and pin list. .

    How to connect the ADS1115? .
    Connecting the finished module is really very simple, as everything needed is already present on the board. The I2C bus requires resistors pulling up the SDA and SCL lines to supply power, but the finished module has these resistors already present on board. For this reason, connecting the whole thing comes down to using four wires, power (2.0V to 5.5V), ground, SDA and SCL.

    If using hardware I2C, check which pins on our MCU board have this role. The Arduino UNO SDA is at A4 and SCL is A5.

    If you are planning to make your own board, then you can base it on the schematic from the datasheet note:
    Connection schematic for ADS1115 using I2C protocol .
    This is how several ADS1115s are connected on one bus:
    Diagram of connecting four ADS1115 modules to an I2C bus. .

    When connecting the inputs, care must also be taken to ensure that the voltage on them does not exceed the supply voltage of the entire module. This is specified in the catalogue note, section "Absolute Maximum Ratings":
    Table showing the maximum ratings of ADS1115 .
    The commercially available ADS1115 module has no additional protection on the board.

    How to test the ADS1115? .
    The ADS1115 is an ADC, which means it converts an analogue signal into a digital signal. In simple terms, it performs a voltage measurement. In this case, we only need one potentiometer. Its outermost legs are connected to the power supply (5V or 3.3V), and to GND, while the middle leg is connected to one of the ADS1115 inputs. The potentiometer connected in this way is a voltage divider, and this voltage can be read from the ADS.

    How to select the address of the ADS1115? .
    It would seem that one ADR pin would be two address options - because it can be connected to either the high or low state - but no:
    ADS1115 package pinout diagram .
    Here we have 4 options - because you can still connect the ADR to SCL or SDA:
    I2C address selection table for ADS111x. .

    The ADS1115 communication protocol .
    Getting the ADS1115 up and running in terms of communication protocol is best described in the 'Quick-Start Guide' section of the catalogue note:
    ADS111x hardware configuration schematic .
    Personally, I would add here that it's a good idea to run some sort of I2C scan first, if only based on the example code from the Arduino, so that you can make sure you've connected everything correctly.
    Reading from the ADS1115 is done in two stages:
    - we send bytes to the Config register, these define the operating mode and the channel we are reading from (point 1 in the screenshot)
    - after now start reading the result from the Conversion register (points 2 and 3)
    Config Register
    For a detailed description of the bits of the Config Register, I refer you to the data sheet.

    How to run ADS1115 with Arduino? .
    You can use a ready-made library (to be added via Libraries):
    https://docs.arduino.cc/libraries/ads1115_we/
    Code: C / C++
    Log in, to see the code
    .
    You can also do a simple readout yourself. All you need is the Wire library:
    Code: C / C++
    Log in, to see the code
    .
    First step 1 from the documentation is executed, i.e. the writeConfig function. It defines the operating mode and the channel to be read. Then steps 2 and 3 are performed, i.e. reading two bytes from CONVERSION_REGISTER.
    The result:
    Serial Monitor displaying ADC readings for channels AIN0, AIN1, AIN2, AIN3. .

    Visualisation of communication with ADS1115 .
    The communication can be viewed with the Sigrok analyser:
    Screenshot from PulseView software showing I2C communication with ADS1115 module and view of code in Arduino IDE. .
    I presented it in the topic:
    Salae 24MHz logic state analyzer for £40 - analysis of unknown LED display protocol .
    There is an 8ms interval between stages to allow the module to convert:
    Screenshot showing a captured I2C transmission using ADS1115 in PulseView. .
    The first stage is to send data to the configuration register at address 0x01, in this case 0xC183 is sent to it. All contained in a single transaction, preceded by an I2C start condition and ended by a stop:
    Analysis of I2C data transmission from ADS1115 on a logic graph. .
    The second stage is the readout. Here, separately after the start we send the register address to be read (this is a write, so the 0x48 device address is with Write - 0 bit), and then separately (after the stop and start) we send the 0x48 device address with Read - 1 bit and read two bytes. After the first byte read there is an ACK, because we want to read further, after the second one there is already a NACK:
    Screenshot showing I2C signals on the communication bus for the ADS1115 module. .

    Running with BK7231 .
    We've also run the ADS1115 with the BK7231, so you can also easily report its measurements to Home Assistant, but I'll put the details in a separate topic.
    ADS1115 module connected to various boards, including Arduino. .

    Summary .
    This was a brief demonstration of the ADS1115 module. Getting this module up and running is hassle-free, we have ready-made libraries for the Arduino, and if you want to implement its communication yourself there's not much work anyway - basically one "write" and one "read" from a given address. This isn't the BME280 or there BMP280, where I wouldn't be too keen on creating a controller myself.
    The ADS1115 is capable of a bit more than I've shown, so it's possible I'll try a separate project on it, maybe some voltage or current measurement there (on a shunt), maybe I'll also separately run that ALERT pin and do a read that isn't blocking (without that delay in my example code). This will all be in the next topic already.
    I'm attaching related material, the datasheet note I relied on, there are details of the PGA configuration etc (if you want to implement this yourself), and the captured communication from the ADS1115 in the format for PulseView:
    ads111..pdf Download (1.78 MB) .
    ads1115 te...ino.sr.zip Download (5.16 kB) .
    Have you already used ADS1115 in your projects, and if so, for what? .

    Cool? Ranking DIY
    Helpful post? Buy me a coffee.
    Do you have a problem with Arduino? Ask question. Visit our forum Arduino.
    About Author
    p.kaczmarek2
    Moderator Smart Home
    Offline 
    p.kaczmarek2 wrote 11927 posts with rating 9987, helped 572 times. Been with us since 2014 year.
  • ADVERTISEMENT
  • #2 21358966
    RomanWorkshop
    Level 14  
    I used the module with this converter for the first and so far last time in Discharge recorder (Arduino Nano) and it works quite well. You have to be careful of fakes. Some modules labelled "ADS1115" may in fact contain an ADS1015 (12-bit) converter, and modules labelled "ADS1015" may have an ADS1115 (16-bit) converter. In theory, the two chips can be distinguished by the marking printed on their housing: "BRPI" = ADS1015, "BOGI" = ADS1115. Unfortunately, there are cases of falsification/painting of these markings. In such a situation, the only sure way to check the transducer model is to run the appropriate test sketch (downloadable from the linked page). It determines the model of the converter based on: the value of the 4 youngest bits in the results of the 10 conversions (for the ADS1015 they are always 0) and the execution time of the 10 conversions (for the ADS1015 it is always shorter).

    Original test sketch (ADS1115_WE/examples/Who_Am_I): Link .
  • ADVERTISEMENT
  • #3 21360272
    markosik20
    Level 33  
    Unfortunately the ADS1115 has a problem with the ALERT/RDY pin. It can "hang up" and not issue the end of the conversion, we can then wait indefinitely. You then have to "manually" query the data and re-enable the continuous conversion.
  • ADVERTISEMENT
  • #4 21531088
    Jacek Rutkowski
    Level 28  
    markosik20 wrote:
    Unfortunately the ADS1115 has a problem with the ALERT/RDY pin. It can "hang up" and not issue the end of the conversion, we can then wait indefinitely. You then have to "manually" query the data and re-enable the continuous conversion.

    Hello,
    if I want to continuously read the status of all 4 channels(one at a time of course) should I set up a continuous conversion or a single conversion each time?
    When I read one channel all the time the readings are ok but when I read all of them in sequence with continuous conversion it shows me silly things.
    Is the 1st reading after changing the channel already sure? Do you have to wait longer than the conversion?
  • ADVERTISEMENT
  • #5 21532263
    markosik20
    Level 33  
    Jacek Rutkowski wrote:

    if i want to read the status of all 4 channels continuously (one after the other of course) should i set up a continuous conversion or a single conversion each time?
    When I read one channel all the time the readings are ok but when I read all of them in sequence with continuous conversion it shows me silly things.
    .

    This ADC has one PGA block . You have to change the input in the MUX register so continuous conversion is dropped.
  • #6 21535117
    Jacek Rutkowski
    Level 28  
    markosik20 wrote:
    Jacek Rutkowski wrote:
    .
    if I want to read the state of all 4 channels continuously (one after the other, of course) should I set up a continuous conversion or a single conversion each time?
    When I read one channel all the time the readings are ok but when I read all of them in sequence with continuous conversion it shows me silly things.
    .

    This ADC has one PGA block . You have to change the input in the MUX register so continuous conversion is dropped.

    This I understand but after changing in the ADC register as I trigger a single measurement I get nonsense. When I was using only 1 channel it was ok. I don't know if I have some crashed ones because I took these ADCs from ali or they hang up and need to be restarted somehow?

    [Edit] operator like 150 ;( instead of changing MUX[2:0] bits I was changing DR[2:0] and that's why I was getting nonsense.
ADVERTISEMENT