Connecting an ads1115 to an esp32

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bastler11
Normal user
Posts: 101
Joined: 11 Jan 2021, 21:58
Location: Luebeck

Connecting an ads1115 to an esp32

#1 Post by bastler11 » 12 Apr 2021, 08:04

Hello, I have not many experience to use espeasy on an esp32, so I hope I could get here some information. I want to to measure a signal 0-5V and want to send it to my mqtt adapter in the ioBroker.
So I bought an ads1115 to connect it with my esp32. But what is the right way and what do I have to set up in the espeasy userinterface?

Thanks and best regards!

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Connecting an ads1115 to an esp32

#2 Post by TD-er » 12 Apr 2021, 08:28

It is an I2C sensor, so you must connect it to the pins assigned to the I2C bus.
On the Hardware tab you can see which pins to use for SDA and SCL (or change it if needed).

See the datasheet of the sensor for more information of the sensor.

Most I2C sensor boards already have pull-up resistors present, so that should be very easy to connect. (page 31 of the datasheet for more information on pull-up resistors)

On the Tools tab, you have an I2C Scan button, which will show you a list of all connected I2C devices, so you can check your sensor is connected to the right pins and working.
This also shows you the I2C address you need to know for setting up the task for this.

You will be powering the ADS1115 with 3.3V, meaning you must use resistors to reduce the voltage you want to measure.
As the datasheet shows, the max analog input voltage (page 6) is related to the Vdd (voltage to power the chip).
So if you want to measure 0...5V you may need to add 2 resistors of the same value to divide the voltage in half. (thus making the measurement range 0 ... 6.6V)
By doing so, you must later double the output reading in ESPEasy.
Image
The value of these resistors doesn't really matter, as long as they are not too low (or else you will draw a high current) or too high (causing noise)
I think 10k - 100k would work just fine, as long as you use the same value for both.

Make sure the GND of your ESP (and ADS1115) is the same as the GND you want to measure.

bastler11
Normal user
Posts: 101
Joined: 11 Jan 2021, 21:58
Location: Luebeck

Re: Connecting an ads1115 to an esp32

#3 Post by bastler11 » 12 Apr 2021, 09:35

Thank you very much for your information.

I thought I could connect max 5V to the analog pin😳, so without your note I think I destroyed the ads.

I connected the ads1115 to the 3,3V pin and ground of the esp32. The I2C signal I connect to pin 21 and pin 22. What for me is not clear how to manage this in the interface of espeasy.

bastler11
Normal user
Posts: 101
Joined: 11 Jan 2021, 21:58
Location: Luebeck

Re: Connecting an ads1115 to an esp32

#4 Post by bastler11 » 12 Apr 2021, 09:54

Do I understand it right, in the data sheet VDD is up 7V. So couldn't I connect the ads on the 5V pin of the esp32?

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Connecting an ads1115 to an esp32

#5 Post by Ath » 12 Apr 2021, 09:56

Basic steps for setting up an ADS1115 is in the 'old' documentation on the Wiki: https://www.letscontrolit.com/wiki/inde ... le=ADS1115

This documentation really needs an update, as the current ReadTheDocs page is quite empty :o (I'll see what I can do, though I don't have such sensor available yet)
bastler11 wrote: 12 Apr 2021, 09:54 Do I understand it right, in the data sheet VDD is up 7V. So couldn't I connect the ads on the 5V pin of the esp32?
Well, then you would have to reduce/convert the voltage on the I2C lines, as that will also go to 5V and would burn out those GPIO's on the ESP :shock:
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Connecting an ads1115 to an esp32

#6 Post by TD-er » 12 Apr 2021, 10:59

Yep, what Ton said...
The max analog input voltage is related to the supplied power to the sensor.
You should not go above that Vdd of the sensor.
You could power it from 5V, but then you also must take care of the I2C signals coming from the sensor to make sure they are not at 5V too as that may cause issues to either the ESP or other sensors connected to the same I2C bus (if any)

Also what if you supplied not 5V to the sensor but just 4.5 (e.g. powering it from an USB charger with bad regulator and/or thin USB cable) and you try to measure 5.0V from an external source. Then you would still destroy the ADS sensor.
So it is best to leave some margin and divide the voltage you want to measure by 2.

bastler11
Normal user
Posts: 101
Joined: 11 Jan 2021, 21:58
Location: Luebeck

Re: Connecting an ads1115 to an esp32

#7 Post by bastler11 » 12 Apr 2021, 12:54

Ok, so I have to set down my 0-5V analog signal, that is no problem.

No to the circuit. I go in the scan menu of ESPEasy, and let it scan. Result: No I2C devices found
In the setting of I2C is SDA - GPIO 4 and SCL - GPIO 5
I connect like this:

ads1115 VDD 3,3V esp32
GND GND
SCL 22
SDA 21
Is there something wrong?

How could I check the I2C bus?
Last edited by bastler11 on 12 Apr 2021, 13:41, edited 1 time in total.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Connecting an ads1115 to an esp32

#8 Post by TD-er » 12 Apr 2021, 13:37

Are you sure those are the pins defined on the ESP32 in your setup? (Hardware tab)
If you can't find anything via the scan, you may need to add 2 pull-up resistors of roughly 4k7 - 10k between the I2C pins and the 3v3
Do not swap SCL and SDA, as you may be used to with serial connections (serial RX/TX need to be crossed RX -> TX and TX -> RX)

bastler11
Normal user
Posts: 101
Joined: 11 Jan 2021, 21:58
Location: Luebeck

Re: Connecting an ads1115 to an esp32

#9 Post by bastler11 » 12 Apr 2021, 13:49

I changed in the hardware tab also the setting of I2C : SDA - GPIO 21 and SCL - GPIO 22 but it does not work.

Now I took a DS18B20 temperature sensor. I had a resistance (4,7k) between + and data. I changed the SDA to GIPO 4. Nothing after scanning :(. Do I have to change any thing in the setup, if I try to use the DS18B20?

bastler11
Normal user
Posts: 101
Joined: 11 Jan 2021, 21:58
Location: Luebeck

Re: Connecting an ads1115 to an esp32

#10 Post by bastler11 » 12 Apr 2021, 13:51

Would there be any possibility to show my screen via team viewer to find out the problem?

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Connecting an ads1115 to an esp32

#11 Post by Ath » 12 Apr 2021, 14:25

DS18b20 does not use I2C interface, but Dallas 1-wire protocol, that's why it won't show up in the I2C scan ;) For testing that sensor you will need to add a Task (Device) for it, and select what GPIO the DS18b20 sensor is connected to. And it can't be shared with I2C interface.
/Ton (PayPal.me)

bastler11
Normal user
Posts: 101
Joined: 11 Jan 2021, 21:58
Location: Luebeck

Re: Connecting an ads1115 to an esp32

#12 Post by bastler11 » 12 Apr 2021, 15:35

OK, thanks I made it and it works with the DS18b20.

Now I will try again to use the ads1115.

But when I try to connect, which GPIO I should take?

bastler11
Normal user
Posts: 101
Joined: 11 Jan 2021, 21:58
Location: Luebeck

Re: Connecting an ads1115 to an esp32

#13 Post by bastler11 » 12 Apr 2021, 16:09

Now it works! I set GPIO 21 and 22 in the hardware menu. Then I set in the menu devices the gain to 1x. Now I took a poti at +3,3V and GND. The middle I connect to A0. The Value I got is between 0 (0V) to 26443 (3,3V).

I have 2 more questions:

To get in the Value the information 3,3, how could I realise that?

What means the gain factor and how could I calibrate the system?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Connecting an ads1115 to an esp32

#14 Post by TD-er » 12 Apr 2021, 17:20

The gain is described in the datasheet I linked before.
On the bottom half of the task configuration for the ADS you use there is a number of fields.
One for the value name, formula and nr of decimals.

The formula can be something like this:

Code: Select all

%value%*2

bastler11
Normal user
Posts: 101
Joined: 11 Jan 2021, 21:58
Location: Luebeck

Re: Connecting an ads1115 to an esp32

#15 Post by bastler11 » 12 Apr 2021, 19:43

Thanks all for support!

Post Reply

Who is online

Users browsing this forum: No registered users and 40 guests