ESP8266 and ADS1115

1,446 views
Skip to first unread message

Max

unread,
Aug 17, 2020, 12:18:04 AM8/17/20
to TasmotaUsers
Hi,
I found problem to work with tha I2C ADS1115 module.

My setup:
-  Wemos D1 R2
- Tasmota 8.4.0 (sensor firmware)

Immagine.jpg

As you can see in the picture, I can see the four value coming from the ADS1115 but they are not stable, they continue change, and this happened with or without connect something to one of the four port.

So I thought it was a problem of my module.

I connect to a Arduino Uno and it work perfectly.

So I connect to a Wemos D1 R2 without Tasmota and it works perfectly.


Anybody use the ADS1115 or have any experience on that?


Thanks

Max



Philip Knowles

unread,
Aug 17, 2020, 12:51:18 AM8/17/20
to TasmotaUsers, Max
Which bin are you using?

Regards

Phil J

Sent from Outlook Mobile


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Max <y2k...@gmail.com>
Sent: Monday, August 17, 2020 5:18:03 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: ESP8266 and ADS1115
 
--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/db938750-e6fc-4006-9933-3e349a10c7cfo%40googlegroups.com.

Max

unread,
Aug 17, 2020, 1:21:59 AM8/17/20
to TasmotaUsers
Hi Phil,
I'm using
tasmota-sensors.bin

Max

Philip Knowles

unread,
Aug 17, 2020, 4:29:05 AM8/17/20
to Max, TasmotaUsers

Connect a 1k and 2k5 resistor in series. Connect the 2k5 resistor to 3.3V and the 1k to 0V and the centre point to an input and see what you get.

 

Regards

 

Phil K

 

Sent from Mail for Windows 10

--

You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

Max

unread,
Aug 17, 2020, 7:11:38 PM8/17/20
to TasmotaUsers
HI Phil,
I don't have 2k5 resistor so I use 2k2.
The value read is 14272 very stable, sometime, after a few seconds, it moves to 14288 and then come back again to 14272.
So very stable if compared to the other 3 input that change costantly value always different.

So what do you think?
Thanks
Max


Il giorno lunedì 17 agosto 2020 20:29:05 UTC+12, Philip Knowles ha scritto:

Connect a 1k and 2k5 resistor in series. Connect the 2k5 resistor to 3.3V and the 1k to 0V and the centre point to an input and see what you get.

 

Regards

 

Phil K

 

Sent from Mail for Windows 10

 

From: Max
Sent: 17 August 2020 06:22
To: TasmotaUsers
Subject: Re: ESP8266 and ADS1115

 

Hi Phil,

I'm using

tasmota-sensors.bin

 

Max

Il giorno lunedì 17 agosto 2020 16:51:18 UTC+12, Philip Knowles ha scritto:

Which bin are you using?

Regards

Phil J

Sent from Outlook Mobile

 

 

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.

To unsubscribe from this group and stop receiving emails from it, send an email to sonof...@googlegroups.com.

Philip Knowles

unread,
Aug 18, 2020, 1:12:39 AM8/18/20
to TasmotaUsers, Max
That value would give you approximately 1.03V at the input - a little bit of drift around the value is normal. It looks like the scaling is around 14000 per volt.
If the other inputs are not connected to anything they can float all over the place.

Regards

Phil K

Sent: Tuesday, August 18, 2020 12:11:38 AM
To: TasmotaUsers <sonof...@googlegroups.com>
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/f4244b0e-aaf2-4691-a130-58fc049d3530o%40googlegroups.com.

Max

unread,
Aug 18, 2020, 2:05:38 AM8/18/20
to TasmotaUsers
Phil
so if I understan what you are telling me...
I have to connect all the 4 input to something otherwise anything will float?
I would like to connect on the 4 input, two shunt 30A/75mA.
What do you think?

Max

Philip Knowles

unread,
Aug 18, 2020, 2:22:10 AM8/18/20
to TasmotaUsers, Max
Just connect the unused inputs to 0V and they will be stable. An unused input will act like an aerial and can pick up noise.

Regards

Phil K

Sent from Outlook Mobile


Sent: Tuesday, August 18, 2020 7:05:37 AM
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/5775abb7-420a-470f-909e-00ed4c0809e4o%40googlegroups.com.

Max

unread,
Aug 18, 2020, 7:21:21 PM8/18/20
to TasmotaUsers
Phil,
just here the connection:
- A0 to one part of the shunt;
- A1 to the other part of the shunt;
- A2 to GND
- A3 to GND

Immagine.jpg


Immagine.jpg

Unfortunately it will not be stable...probably there is something else


So I tried to connect A0 with A1, same result, they ae not stable, they move less than before, but they are not stable.

So I tried to connect A1 to GND and leave A0 open,nothing connect on it...Almost stable, it move a litlle bit.

Philip Knowles

unread,
Aug 18, 2020, 11:34:57 PM8/18/20
to TasmotaUsers, Max
Sorry, what exactly are you connecting to it?
Model number would help.

Regards

Phil K

Sent from Outlook Mobile


Sent: Wednesday, August 19, 2020 12:21:20 AM
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/ed353d0b-c5fc-4b7d-91dc-28df56c3487do%40googlegroups.com.

Max

unread,
Aug 20, 2020, 12:20:34 AM8/20/20
to TasmotaUsers
Hi Phil.
I tried to connect a 50A shunt.
Here the connection

Immagine.jpg


This is the Shunt 50A/75mV. The red connections go to A0 and A1 of the ADS1115.

Immagine.jpg




Max


Philip Knowles

unread,
Aug 20, 2020, 2:24:03 AM8/20/20
to TasmotaUsers, Max
Is the shunt on the positive or negative side of the load?

Regards

Phil K

Sent: Thursday, August 20, 2020 5:20:33 AM
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/83b9e88f-b8c0-486f-a13f-7637d44d4cf8o%40googlegroups.com.

Philip Knowles

unread,
Aug 21, 2020, 1:33:48 PM8/21/20
to Max, TasmotaUsers

Meant to say that you need to do the maths. The whole point of using the differential measurement is to cancel out the noise so you need to subtract one from the other and the result may be more stable.

 

Regards

 

Phil K

 

Sent from Mail for Windows 10

 

From: Max
Sent: 20 August 2020 05:20
To: TasmotaUsers
Subject: Re: ESP8266 and ADS1115

 

Hi Phil.

I tried to connect a 50A shunt.

Here the connection

 

 

This is the Shunt 50A/75mV. The red connections go to A0 and A1 of the ADS1115.

 

 

 

 

Max

 

 



Il giorno mercoledì 19 agosto 2020 15:34:57 UTC+12, Philip Knowles ha scritto:

Sorry, what exactly are you connecting to it?

Model number would help.

Regards

Phil K

Sent from Outlook Mobile

 

From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Max <y2k...@gmail.com>
Sent: Wednesday, August 19, 2020 12:21:20 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: ESP8266 and ADS1115

 

Phil,

just here the connection:

- A0 to one part of the shunt;

- A1 to the other part of the shunt;

- A2 to GND

- A3 to GND

 

 

Unfortunately it will not be stable...probably there is something else

 

So I tried to connect A0 with A1, same result, they ae not stable, they move less than before, but they are not stable.

So I tried to connect A1 to GND and leave A0 open,nothing connect on it...Almost stable, it move a litlle bit.

 

Max

 

 

 

 


Il giorno martedì 18 agosto 2020 18:22:10 UTC+12, Philip Knowles ha scritto:

Just connect the unused inputs to 0V and they will be stable. An unused input will act like an aerial and can pick up noise.

Regards

Phil K

Sent from Outlook Mobile

 

From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Max <y2k...@gmail.com>
Sent: Tuesday, August 18, 2020 7:05:37 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: ESP8266 and ADS1115

 

Phil

so if I understan what you are telling me...

I have to connect all the 4 input to something otherwise anything will float?

I would like to connect on the 4 input, two shunt 30A/75mA.

What do you think?

 

Max

Il giorno martedì 18 agosto 2020 17:12:39 UTC+12, Philip Knowles ha scritto:

That value would give you approximately 1.03V at the input - a little bit of drift around the value is normal. It looks like the scaling is around 14000 per volt.

If the other inputs are not connected to anything they can float all over the place.

 

Regards

 

Phil K

To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/83b9e88f-b8c0-486f-a13f-7637d44d4cf8o%40googlegroups.com.

 

Max

unread,
Aug 21, 2020, 11:02:04 PM8/21/20
to TasmotaUsers
Hi Phil,
thank for your help, but I do my home work.

I applyed the same formula that I've already use on Arduino Uno with success:
amps = ((A0-A1) * 256.0) / 32768.0;//100mv shunt
amps = amps * 1.333;  //for 75mv shunt

I use this formula on Nore-Red and the result are:

Immagine.jpg



If I apply the same configuration and math formula on Arduino Uno or another ESP8266 with IDE the results are:

Immagine.jpg


As you can see is very stable, also on ZERO when nothing is connect to thge shunt.

Max


Philip Knowles

unread,
Aug 22, 2020, 1:25:16 AM8/22/20
to TasmotaUsers, Max
Ok. Was the wiring the same (I don't mean connections the same but the wiring route).
When you connected the resistors you were getting 14272 as a reading for 1.03V.  That would give you a scale of roughly 14 per mV. For 0.83A on a 50A/75mV shunt you should  get 1.2mV which would give you a reading of 17. The readings are nowhere near that so  there is something interfering.  If you aren't using a twisted pair/shielded cable trying to measure 1.2mV accurately will be almost impossible.
Based on the reading you got with your resistor I suspect the formula is incorrect too. Your formula is giving a reading of roughly 3 per mV.
Once you get a stable reading I would try connecting an car indicator bulb (21W)  to a 12V battery. Depending on the state of charge you should get between 1.65 - 1.75A (measure the battery voltage to be accurate)  which would give you around 2.5mV across the shunt.
If your formula is correct you would get a reading of about 9. Based on what you got with the resistors I think you'd get 36.
The ADS1115 has a programmable and Arduino and Tasmota may be using different gains which may explain the 4x difference.

Regards

Phil K

Sent from Outlook Mobile

Sent: Saturday, August 22, 2020 4:02:03 AM
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/fadf0753-dca6-425b-85de-98984d91f337o%40googlegroups.com.

Justin Adie

unread,
Aug 22, 2020, 4:43:01 AM8/22/20
to Max, TasmotaUsers, Philip Knowles
Wouldn’t it be better to use the ads1115 in differential mode?  It’s a few lines of code to change in xsns_12_ads1115.ino. 

Tasmota is using a reference voltage of 6.144v.   but the ino file has all the other settings in it so it’s easy to select a different reference voltage.  

On 22 Aug 2020, at 07:25, Philip Knowles <knowles...@gmail.com> wrote:

Ok. Was the wiring the same (I don't mean connections the same but the wiring route).
When you connected the resistors you were getting 14272 as a reading for 1.03V.  That would give you a scale of roughly 14 per mV. For 0.83A on a 50A/75mV shunt you should  get 1.2mV which would give you a reading of 17. The readings are nowhere near that so  there is something interfering.  If you aren't using a twisted pair/shielded cable trying to measure 1.2mV accurately will be almost impossible.
Based on the reading you got with your resistor I suspect the formula is incorrect too. Your formula is giving a reading of roughly 3 per mV.
Once you get a stable reading I would try connecting an car indicator bulb (21W)  to a 12V battery. Depending on the state of charge you should get between 1.65 - 1.75A (measure the battery voltage to be accurate)  which would give you around 2.5mV across the shunt.
If your formula is correct you would get a reading of about 9. Based on what you got with the resistors I think you'd get 36.
The ADS1115 has a programmable and Arduino and Tasmota may be using different gains which may explain the 4x difference.

Regards

Phil K

Sent from Outlook Mobile


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Max <y2k...@gmail.com>
Sent: Saturday, August 22, 2020 4:02:03 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: ESP8266 and ADS1115
 
Hi Phil,
thank for your help, but I do my home work.

I applyed the same formula that I've already use on Arduino Uno with success:
amps = ((A0-A1) * 256.0) / 32768.0;//100mv shunt
amps = amps * 1.333;  //for 75mv shunt

I use this formula on Nore-Red and the result are:

<Immagine.jpg>



If I apply the same configuration and math formula on Arduino Uno or another ESP8266 with IDE the results are:

Philip Knowles

unread,
Aug 22, 2020, 4:51:17 AM8/22/20
to Max, Justin Adie, TasmotaUsers
He's trying to use it in differential mode but without the change. Not having a pop at you Justin but the info you have quoted should be in the docs - some peripherals have it some don't. In Max's case, with a 75mV FSD he would be better using a gain of 16 which gives a 256mV FSD on the input but the Tasmota docs don't explain how to set it up.

Regards

Phil K

Sent from Outlook Mobile


From: Justin Adie <justi...@adieandco.com>
Sent: Saturday, August 22, 2020 9:42:51 AM
To: Max <y2k...@gmail.com>
Cc: TasmotaUsers <sonof...@googlegroups.com>; Philip Knowles <knowles...@gmail.com>

Justin Adie

unread,
Aug 22, 2020, 5:47:26 AM8/22/20
to Philip Knowles, Max, TasmotaUsers
Appreciate that he’s trying to get differential mode.  But is it as simple (in the chip) as subtracting one from the other?  If so, then there’s little value in adding the complexity to the ADS1115 so I suspect something else goes on in that chip.  

Anyway, if anyone wants to test this code here is an adapted driver for differential mode at 16x gain for channels 0 & 1.    I’ve not compiled or tested it (I have two ADS1115 in the post box but that’s half a mile away and I’ve not had enough coffee to warrant the trot). 



xsns_12_ads1115.txt
Reply all
Reply to author
Forward
0 new messages