rups22
Posts: 15
Joined: Thu Oct 24, 2019 3:22 pm

Measuring small change in resistance with ADS1015

Sat Feb 29, 2020 6:11 am

Hi all

I'm using my Pi to build a digital fuel guage. The fuel tank of my vehicle contains a variable resistor that moves between 0-100ohms when full and empty.
I am using an ADS1015 and applying 3.3v through the resistor circuit and measuring the output with a python script. However the change in resistance is so small that the voltage change is not measurable. What can I do do improve the resolution? I'm guessing I need to 'amplify' the resistance somehow?
All advice welcome

Thanks

User avatar
Frederir
Posts: 15
Joined: Tue May 24, 2016 12:28 pm
Contact: Website

Re: Measuring small change in resistance with ADS1015

Sat Feb 29, 2020 10:13 am

May be you should use a resistor bridge. If you put 3.3V in a resistor you will measure 3.3V whatever is the value of the resistor...

There is a guy named Wheatstone who could help you : https://en.wikipedia.org/wiki/Wheatstone_bridge
Custom board design based on RPI or other : http://www.aptustech.com/

rups22
Posts: 15
Joined: Thu Oct 24, 2019 3:22 pm

Re: Measuring small change in resistance with ADS1015

Sat Feb 29, 2020 11:21 am

I've used a potentiometer in series with the variable resistor to act as a voltage divider. I assumed that this was basically a Wheatstone bridge ?
Adjusting the 10k pot gives me jumpy but fairly good voltage readings from 0v-3.3v but any adjustment to the 100ohm variable resistor in series registers no change in voltage

I read that the ads1015 can be used to measure millivolt changes ?
Can a differential setup and gain adjustment help me here?

User avatar
Burngate
Posts: 6290
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Measuring small change in resistance with ADS1015

Sat Feb 29, 2020 12:13 pm

Perhaps you could show us a diagram of your proposed circuit, then we can make recommendations?

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Measuring small change in resistance with ADS1015

Sat Feb 29, 2020 12:31 pm

If you were using a standard variable resistor you would just wire the 3.3v and ground to each end of the the resistor and the the middle pin would give you an output varying from 3.3V to 0V.

But I suspect your fuel tank sensor only has 2 wires so you can't do that, so you have to create a potential divider circuit so that you have a similar output.

Image

doing some quick tests with a bench PSU, digital voltmeter and a range of resistors I got these results

Code: Select all

 Ohms | volts
  0   | 2.908
  5   | 2.201
  10  | 1.675
  22  | 1.164
  47  | 0.687
  50  | 0.550
  100 | 0.336 
  
which you ADC should be able to measure without any problems
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
rpdom
Posts: 17029
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Measuring small change in resistance with ADS1015

Sat Feb 29, 2020 12:45 pm

pcmanbob wrote:
Sat Feb 29, 2020 12:31 pm
If you were using a standard variable resistor you would just wire the 3.3v and ground to each end of the the resistor and the the middle pin would give you an output varying from 3.3V to 0V.

But I suspect your fuel tank sensor only has 2 wires so you can't do that, so you have to create a potential divider circuit so that you have a similar output.

Image

doing some quick tests with a bench PSU, digital voltmeter and a range of resistors I got these results

Code: Select all

 Ohms | volts
  0   | 2.908
  5   | 2.201
  10  | 1.675
  22  | 1.164
  47  | 0.687
  50  | 0.550
  100 | 0.336 
  
which you ADC should be able to measure without any problems
That will take quite a bit of current though. Between 30 and 330mA, I believe
Unreadable squiggle

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Measuring small change in resistance with ADS1015

Sat Feb 29, 2020 1:04 pm

Yes it will so you would have to use a separate 3.3v supply which you could power from the 5v pin on the gpio header.

If you increased the 10 ohm resistor to 100 ohms you would limit the current to a maximum of 33mA but you would also limit the voltage swing to 0V to 1.5V.

It becomes a trade off between voltage swing and current drawn.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

rups22
Posts: 15
Joined: Thu Oct 24, 2019 3:22 pm

Re: Measuring small change in resistance with ADS1015

Sat Feb 29, 2020 11:55 pm

OK I've got it working accurately by connecting the variable resistor in series with a 100ohm trimpot and a 100 ohm fixed resistor.
However I want to get rid of the trimpot as it's unnecessary
pcmanbob, In your schematic you show the variable resistor as having 3 wires. Would you be kind enough to send a schematic showing the connections for a 2 wire variable resistor so i can ensure i build this circuit correctly. Thank you again

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Measuring small change in resistance with ADS1015

Sun Mar 01, 2020 8:46 am

In my diagram I only show 2 resistors the one in the fuel level sender ( marked tank sensor ) which is the variable one and the now 100 ohm one.

That is all there is there is no second variable resistor .

Image

same diagram just drawn differently
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

rups22
Posts: 15
Joined: Thu Oct 24, 2019 3:22 pm

Re: Measuring small change in resistance with ADS1015

Sun Mar 01, 2020 12:40 pm

Sorry the 3rd unconnected wire from the VR confused me
I've set it up as per your schematic and it's working great! I'm reading 2.62volts when VR is 100ohms and 3.794volts when VR is 10ohms
Are my calculations correct: I am drawing between 25mA and 50mA? (I'm using 5 volts input). Are these current levels safe? I believe the 5v rail can handle quite a lot?

One strange issue, the Pi will not boot with the ADC connected to the voltage divider, I have to boot the Pi and then connect the voltage wire to the ADC's input. I'm guessing it's a power issue? Any ideas?
Thanks

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Measuring small change in resistance with ADS1015

Sun Mar 01, 2020 12:49 pm

Do not use the 5V pin to power the voltage divider circuit, as when the fuel sensor reads ohms you will put 5v on to the ADC.

You should not put more than 3.3v on to the input of your ADC or you could damage your pi & ADC.

If you circuit is connected to 3.3v and connected correctly your pi should boot with the circuit and the ADC connected to your pi.

I would suggest building or buying a 5V to 3.3V DC-DC converter circuit and using that to power the potential divider circuit rather than using the 3.3v pin on the pi gpio header as there is not much current available from those pins, and drawing to much current could cause your pi to reboot or even damage it.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

rups22
Posts: 15
Joined: Thu Oct 24, 2019 3:22 pm

Re: Measuring small change in resistance with ADS1015

Sun Mar 01, 2020 2:21 pm

Understood
Glad you told me

Would this be sufficient? https://www.jaycar.com.au/arduino-compa ... e/p/XC4486

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Measuring small change in resistance with ADS1015

Sun Mar 01, 2020 3:25 pm

No , You need a dc-dc step down buck converter.

examples
https://www.ebay.co.uk/itm/MP2307-Adjus ... SwfLxbCyNw
or may be even this
https://www.ebay.co.uk/itm/1A-DC-DC-Buc ... SwQ19auhSq
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

rups22
Posts: 15
Joined: Thu Oct 24, 2019 3:22 pm

Re: Measuring small change in resistance with ADS1015

Sun Mar 01, 2020 11:48 pm

I've found this https://www.jaycar.com.au/arduino-compa ... r/p/XC4514
I've set it to 3.3v and it's working well
However the Pi still won't boot up with the voltage divider circuit connected to the ADC.
Would I be safe to connect the regulator to my spare 5v USB power source directly to see if that makes any difference? I'm guessing I would still have a common ground?
Attachments
IMG_0882.jpg
IMG_0882.jpg (155.61 KiB) Viewed 800 times

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Measuring small change in resistance with ADS1015

Mon Mar 02, 2020 9:45 am

I can't understand why your pi will not boot with a external circuit connected to the ADC chip.

Can you draw a diagram of how you think its all connected and also post some pictures so we can check its actually connected correctly .

You don't have a original car wiring still connected to the fuel tank sender do you ?

I don't think powering the sender part of the circuit from a different power source will make any difference , if you do try it then you need to connect the ground of the 3.3v dc-dc converter output to the pi ground.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

rups22
Posts: 15
Joined: Thu Oct 24, 2019 3:22 pm

Re: Measuring small change in resistance with ADS1015

Mon Mar 02, 2020 10:21 am

OK I've just connected the VDD of the ADC to the 3.3v coming from the regulator instead of being powered from the GPIO's 3.3v and the Pi is now booting fine. Am I ok to continue with this setup? Seems stable and all the readings are good

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Measuring small change in resistance with ADS1015

Mon Mar 02, 2020 10:44 am

I don't see why not ,

I sounds like that the external 3.3v was some how finding its way through your ADC/circuit back to the pi 3.3v pin causing it not to boot.

I would sill like to see a diagram /picture of your circuit just to make sure there are no silly errors causing the poblem.

Diagram be a picture of a hand drawn diagram if that easier.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

rups22
Posts: 15
Joined: Thu Oct 24, 2019 3:22 pm

Re: Measuring small change in resistance with ADS1015

Tue Mar 03, 2020 12:42 am

I've taken the liberty of drawing my entire setup for you to check over. Will send photo as well
Attachments
Don Vito Raspberry Pi Setup_schem.png
Don Vito Raspberry Pi Setup_schem.png (144.54 KiB) Viewed 692 times

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Measuring small change in resistance with ADS1015

Tue Mar 03, 2020 10:17 am

A quick look at your diagram and the only thing I would suggest is to change the resistor R2 in the relay circuit to a 1K as a 220 ohm resistor will allow a current of 15mA to flow in the event you set the gpio 22 to output and high while the relay was closed,
which is very close to the maximum you can draw from a gpio pin.

I assume you have a pull up set in software for gpio 22.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

rups22
Posts: 15
Joined: Thu Oct 24, 2019 3:22 pm

Re: Measuring small change in resistance with ADS1015

Wed Mar 04, 2020 3:20 am

I'm not using any pull up in software
I have been getting a lot of false readings i assume from interference on the relay circuit
I have added a 1k resistor, a 10k resistor and a 100nF ceramic capacitor to combat this and protect the GPIO in case of accidental output.
Does this look ok?
Attachments
Don Vito Raspberry Pi Setup_schem2.png
Don Vito Raspberry Pi Setup_schem2.png (152.41 KiB) Viewed 641 times

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Measuring small change in resistance with ADS1015

Wed Mar 04, 2020 9:08 am

Yes you will have a lot of false triggers if you don't have a pull up because your gpio pin will be floating so it can be in any state and it can change due to local electrical fields.

If I am reading your diagram correctly you don't have you pull up / protection resistor connected correctly, it should look like this

Image
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

rups22
Posts: 15
Joined: Thu Oct 24, 2019 3:22 pm

Re: Measuring small change in resistance with ADS1015

Wed Mar 04, 2020 10:42 am

Ah I see. Will change that now. Thanks again

Return to “Interfacing (DSI, CSI, I2C, etc.)”