ADS1115 changing inputs - impossible callibration

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
HappyKumquat
Normal user
Posts: 10
Joined: 05 Nov 2022, 14:18

ADS1115 changing inputs - impossible callibration

#1 Post by HappyKumquat » 05 Nov 2022, 14:41

Hello together,

recently I started with some esp d1 boards and got esp easy to run well. A lot of things work properly (different sensors, communication to iobroker, etc.). Nonetheless I*m still at beginner level.

So for now I took a d1 to measure the water of four plants. The ADS1115 is recognized by the d1, I get the values out of the sensors (capacitive moisture sensor) BUT ... the sensors are switching channels over and over again. I hope and think I misunderstood the configuration. These are the settings for all of the four sensors:

Device: Analog input - ADS1115 (all 4)
Name: Plant1 --- // Plant2 // Plant3 // Plant4
Enabled: Yes (all 4)

I2C options
I2C Address: 0x48 (72) - (default) (all 4)
Force Slow I2C speed: No (all 4)

Device settings
Input
Gain: 1x gain (FS=4.096V) (all 4)
Input Multiplexer: AIN0 - GND (Single-Ended) --- //AIN1 - GND (Single-Ended) // AIN2 - GND (Single-Ended) // AIN3 - GND (Single-Ended)


If I connect sensor 1 to AIN0 it is not sure if the value will be show properly at plant1. It might be plant2, 3 or 4 which recognizes the attached sensor. Attaching another sensor can end up with another change. Let*s say sensor 1 is connected to AIN0 and show with plant2. Now I connect sensor 2 in addition to AIN1. It could be that sensor 1 is now shown with plant 3 and sensor 2 with plant 4 or similar. Changing values in the two-point callibration can also result in switching the shown values. And sometimes it changes the assignment out of thin air without any change at all.

In my opinion there should be a problem with the ADS1115 or especially with its configuration.

Please let me know if you need more information about the config.

Thanks for all responses in advance!

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

Re: ADS1115 changing inputs - impossible callibration

#2 Post by Ath » 05 Nov 2022, 15:05

I'm not sure if you can use a single ADS1115 in separate tasks with different hardware settings, looking at the code, the multiplexer is initialized at plugin start, not before every read.

Hang in there, I'll create a special test-build where that behavior is applied, for you to test.

Edit: The code was a bit confusing, it does seem to set the multiplexer before every read.

Edit2: Device does support Fast mode I2C (400 kHz) according to the datasheet.
Last edited by Ath on 05 Nov 2022, 17:32, edited 1 time in total.
/Ton (PayPal.me)

User avatar
HappyKumquat
Normal user
Posts: 10
Joined: 05 Nov 2022, 14:18

Re: ADS1115 changing inputs - impossible callibration

#3 Post by HappyKumquat » 05 Nov 2022, 16:02

Thank you for your response.

I've tried what happens if I experiment with the speeds of the I2C interface. Sadly I think it didn't the trick. I tried with standard settings (100 kHz) and also with lower speeds (50 kHz) but neither resulted in a better behavior of the readouts. But - maybe, it is stable while not connecting new sensors to the board.

Therefore I keep the settings to low speed with 100 kHz. Also I build up kind of a testing scenario. Two of the sensors within water and two in a dry environment. So I can track changes and can see if there are spikes or irregularities in the diagramms that tell me if the assignement of the sensors is stable or not.

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

Re: ADS1115 changing inputs - impossible callibration

#4 Post by TD-er » 05 Nov 2022, 16:10

A few simple checks for you:
Are you using long cables between ESP and ADS chip?
Are you using pull-up resistors between SDA and 3V3 and SCL and 3V3? And if so, what value? 10k is typically enough, but on longer cables, you may want to use 4k7.
N.B. having multiple boards/sensors hooked up to the I2C bus may all have pull-up resistors which may in the end result in too low pull-up resistance.

How are the plant sensors powered?
If these have a different ground, or maybe draw too much power, then you may see very flaky measurement results.

How long are the wires between the sensors and the ADS chip?

User avatar
HappyKumquat
Normal user
Posts: 10
Joined: 05 Nov 2022, 14:18

Re: ADS1115 changing inputs - impossible callibration

#5 Post by HappyKumquat » 05 Nov 2022, 16:35

Are you using long cables between ESP and ADS chip?
- no, the ads1115 is soldered to a tripple base and directly connected

Are you using pull-up resistors between SDA and 3V3 and SCL and 3V3? And if so, what value? 10k is typically enough, but on longer cables, you may want to use 4k7.
N.B. having multiple boards/sensors hooked up to the I2C bus may all have pull-up resistors which may in the end result in too low pull-up resistance.

- I'm using a presoldered board. As far as I've seen it should be a 10k resistor. Beyond the ADS1115 I'm going to connect a BMP280 (for temps), DHT22 (for humidity), one relais and the battery shield.
The combination of the DHT + BMP is because I got the BMP sensors instead of the DHT.
DHT is causing issues (sometimes there are wrong values send - 25.5 for °C and % rel. humidity)
Nontheless, these are not connected right now. At the moment I'm only using the ADS1115 in combination with the d1 mini and a battery shield. I've tested with and without connection to a power supply.

How are the plant sensors powered?
If these have a different ground, or maybe draw too much power, then you may see very flaky measurement results.

- they share the same ground and connection to 3.3 V with the d1 board. The issue starts with only one or two sensors. There seems to be no change if I've connected 1,2 or all 4 sensors at once.

How long are the wires between the sensors and the ADS chip?
- some 1.5 to 2 m. The cables I use are high quality microphone cable (leftovers) with low resistance. The switching in the assignement also happened with the short 15 cm cables within my first tests.

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

Re: ADS1115 changing inputs - impossible callibration

#6 Post by Ath » 05 Nov 2022, 16:46

What is the update interval for the tasks? If they all try to do a read at the same interval (and they will be started nearly at the same time after a reboot), then most likely that will interfere. A solution could be to use prime numbers for the Interval values, excluding 1, (3, 5, 7, 11, or 53, 59, 61, 67 if you want to be around 1 update per minute) so they will be read at least 1 second apart.
/Ton (PayPal.me)

User avatar
HappyKumquat
Normal user
Posts: 10
Joined: 05 Nov 2022, 14:18

Re: ADS1115 changing inputs - impossible callibration

#7 Post by HappyKumquat » 05 Nov 2022, 16:52

Okay, I did several tests and something seemed to work. The diagramms are now stable and there seems to be no switching furthermore.
I'd go on with testing and will be back and report if I figured out where the problem came from.

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

Re: ADS1115 changing inputs - impossible callibration

#8 Post by Ath » 05 Nov 2022, 17:19

HappyKumquat wrote: 05 Nov 2022, 16:52 Okay, I did several tests and something seemed to work. The diagramms are now stable and there seems to be no switching furthermore.
I'd go on with testing and will be back and report if I figured out where the problem came from.
Great.

Have you used the 'diagramms' of ESPEasy (the Stats checkbox, next to the Decimals for the Values), or from an external system, like Home Assistant, Domoticz etc.?
/Ton (PayPal.me)

User avatar
HappyKumquat
Normal user
Posts: 10
Joined: 05 Nov 2022, 14:18

Re: ADS1115 changing inputs - impossible callibration

#9 Post by HappyKumquat » 05 Nov 2022, 17:33

Ath wrote: 05 Nov 2022, 17:19
HappyKumquat wrote: 05 Nov 2022, 16:52 Okay, I did several tests and something seemed to work. The diagramms are now stable and there seems to be no switching furthermore.
I'd go on with testing and will be back and report if I figured out where the problem came from.
Great.

Have you used the 'diagramms' of ESPEasy (the Stats checkbox, next to the Decimals for the Values), or from an external system, like Home Assistant, Domoticz etc.?
I'm using a combination of the D1s with ESPEasy and a Synology NAS with an instance of ioBroker. Within ioBroker I can see the data history of all sensors at once with eCharts.
Didn't know that there's a way to aquire more data from the D1 beyond the real-time / last values of the measurements.

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

Re: ADS1115 changing inputs - impossible callibration

#10 Post by Ath » 05 Nov 2022, 17:40

HappyKumquat wrote: 05 Nov 2022, 17:33 Didn't know that there's a way to aquire more data from the D1 beyond the real-time / last values of the measurements.
On ESP8266 that's limited to 16 datapoints (because of memory restrictions), on ESP32 to 64.
/Ton (PayPal.me)

User avatar
HappyKumquat
Normal user
Posts: 10
Joined: 05 Nov 2022, 14:18

Re: ADS1115 changing inputs - impossible callibration

#11 Post by HappyKumquat » 06 Nov 2022, 12:42

Back from testing and I'm a little bit frustrated. Everything seems to work properly.

Initially I've connected all the sensors to the board. Made the settings to get sensor 1 assigned to sensor 1, 2 to 2, etc.
Made some tests. Disconnected all sensors and reconnected them to try if they will be recognized again correct. And this worked fine.
I left the "testing-bench" over night to get back the next morning.

Everything seemed to be just fine - except one small fluctuation in the diagramms. Within this fluctiation you can see that the sensors "virtually" switched place again. I could confirm this by reconnecting the sensors. This has shown that the assignement is not correct anymore and thus a callibration is still not possible.

Slowing down the I2C speed seemed to help. Nonetheless it is still not fixed.

Any other idea what I could try?

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

Re: ADS1115 changing inputs - impossible callibration

#12 Post by TD-er » 06 Nov 2022, 13:02

A very simple test would be to add various resistor combinations to the inputs.
e.g. GND --- 10k --- pin --- 33k ---- 3V3
And then different combinations per pin.
This way the sampled values should always be the same +/- some noise.
But still you would see if inputs are changed.

User avatar
HappyKumquat
Normal user
Posts: 10
Joined: 05 Nov 2022, 14:18

Re: ADS1115 changing inputs - impossible callibration

#13 Post by HappyKumquat » 06 Nov 2022, 13:29

TD-er wrote: 06 Nov 2022, 13:02 A very simple test would be to add various resistor combinations to the inputs.
e.g. GND --- 10k --- pin --- 33k ---- 3V3
And then different combinations per pin.
This way the sampled values should always be the same +/- some noise.
But still you would see if inputs are changed.
I'm sorry, but I don't get the purpose of this test. As far as I understand would the resistors change the values of the measurements and create a bigger gap betwenn the values. I'm convinced about the switching of the inputs. The data from the diagramms show this clearly without any doubt. Or is there another purpose for this test?

User avatar
HappyKumquat
Normal user
Posts: 10
Joined: 05 Nov 2022, 14:18

Re: ADS1115 changing inputs - impossible callibration

#14 Post by HappyKumquat » 06 Nov 2022, 13:35

Small update:
I've switched the d1 to deepsleep and readouts every 120 seconds. Now the diagramms are messed up. What have seemed to be kind of stable is now just horrible. I'd try to analyse if I can find any kind of pattern ...

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

Re: ADS1115 changing inputs - impossible callibration

#15 Post by TD-er » 06 Nov 2022, 13:36

The idea is that there is some delay used in the code to 'stabilize' the input before taking the sample.
Maybe this delay is too short and with a constant voltage we can see if it changes anyway.
If it remains constant then maybe test with a larger voltage difference between pins which are being sampled in order.

User avatar
HappyKumquat
Normal user
Posts: 10
Joined: 05 Nov 2022, 14:18

Re: ADS1115 changing inputs - impossible callibration

#16 Post by HappyKumquat » 07 Nov 2022, 22:08

Back again with quite a lot of data and measurements.

No deep-sleep with short timings for readouts (same values) but switching timings for all sensors. You might see, when I've changed the timings.
https://drive.google.com/file/d/1XX_IIA ... sp=sharing

No deep-sleep with short timings for readouts (different values - prime numbers)
https://drive.google.com/file/d/1WvAtYd ... sp=sharing

No deep-sleep with long timings for readouts (same values)
https://drive.google.com/file/d/1caMQY2 ... sp=sharing

Deep-sleep with short timings for readouts (same values) which resulted in 2 readouts within one cycle (6 seconds between readouts and 15 seconds on-time before deep-sleep)
https://drive.google.com/file/d/1jbxxoB ... sp=sharing

The latest setting:
Deep-sleep with long timings for readouts (same values) which results in 1 readout per cycle.
https://drive.google.com/file/d/1eTWMOB ... sp=sharing

At the moment I might have found a solution. To be sure if it's stable further on, it would need more time and measurements. While testing I've found out that it is crucial for my setup to have the same timings for the readouts and also to have long timings for the devices. I hope that this is going to work stable. If I'd be honest - I think this is not the final solution. Nonetheless I've to go with it for the moment. Temperatures are getting cold outside and this project is for monitoring the waterlevel of some plants. Due to the fact that the d1 will be installed and it is a bit difficult to get there (behind all of the plants) - this has to work for this season. Next year I'd came back and check if I can optimize the settings.

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

Re: ADS1115 changing inputs - impossible callibration

#17 Post by TD-er » 07 Nov 2022, 22:11

I have not yet found my ADS1115 boards, so I can't do the testing for you to see whether it can be reproduced here.

User avatar
HappyKumquat
Normal user
Posts: 10
Joined: 05 Nov 2022, 14:18

Re: ADS1115 changing inputs - impossible callibration

#18 Post by HappyKumquat » 07 Nov 2022, 22:57

TD-er wrote: 07 Nov 2022, 22:11 I have not yet found my ADS1115 boards, so I can't do the testing for you to see whether it can be reproduced here.
Thank you for your support. I think I'll have enough time spring next year, when the plants finished over-wintering. I'll try your suggestion to combine some resistors and simulate the sensor connection.

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

Re: ADS1115 changing inputs - impossible callibration

#19 Post by TD-er » 28 Dec 2022, 00:36

A user just reported to have similar issues, here: https://github.com/letscontrolit/ESPEasy/issues/3159

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 134 guests