2
\$\begingroup\$

I have a electrical problem that I hope to get some help with. Let me first start of by saying that I'm quite a noob in this field (I'm a IT guy), but I hope to learn something.

The problem I have is this: I have a sensor to monitor the humidity of soil. When I power it with 3.3v I get a output of 1.9v when it is fully submerged in water and a output of 3.1 v when it's dry. For my project I actually need a output value between 0.2v and 1.2v

To achieve that, I've created a voltage divider (my first ever) using a 1k and a 2k resistor. When I power it with 3.3v I get a output of 1.04v, which is pretty close to what I want (Close enough I thought). My schema looks like this:

enter image description here

I measure at points A and B

I powered the sensor with the 1.04v (so at point B), so the connections look like this:

enter image description here

I was hoping to get a well scaled value out of it. Unfortunately the results are not quite what I wanted. When it's fully submerged, I now get 0.71v, and when it's fry I get 0.86. It seems I'm now losing a lot of resultion, so I'm guessing there must be a better way to do this.

This is by the way the sensor I'm using: Link

The reason I need a value between 0.2v and 1.2v is that I want to hook it up to a ESP8266 Wifi module / microcontroller.

Any ideas?

\$\endgroup\$
  • \$\begingroup\$ If you need to convert a range 1.9v~3.1v to 0.2~1.2V you will need an amplifier. \$\endgroup\$ – Eugene Sh. Jan 29 '16 at 18:32
4
\$\begingroup\$

Simple Solution, limited range

Well your close but not quiet there. In the description of the sensor on the webpage you linked it says that the operating voltage is 3.3v to 5v. So while you may have been able to only use that 1.04v as Vcc I would suggest just using the 3.3v source.

What you want to do is have the voltage divider on the output of the device. I have the circuit shown below

schematic

simulate this circuit – Schematic created using CircuitLab

Now here is how I got those two values.

First off you have stated that the high voltage for the output was 3.1v. You want this value to be only 1.2v. Using the Voltage divider formula shown below you can almost get all the values you need.

$$V_{out} = V_{in}*\frac{R2}{R1+R2}$$

V_out is the disried 1.2v, V_in is the 3.1v of the sensor. Now I simply picked R1 to be 10k and solved for R2. Now using these values to see what the lower voltage will be you end up with 0.67v. While its not wonderful its the best you will get with a simple voltage divider.

Harder solution, better range

Alright, So I'm going to keep this as simple as I can. In short you have two problems you have to solve. First you need to 'subtract' a voltage of 1.9 from the output of the sensor to shift it, then your range will be 1.2v down to 0v. However this new output has a total range of 1.2v, not 1v. To correct this you need an amplifier with a gain less then one. Now for simple things like this a LM741 is a pre-built amplifier IC. It has 4 pins, a Vcc(+Power), Vss(-Power), Inverting input, and non-inverting input. Operational amplifiers like the LM741 can do many, many different things but I'm only going to cover your application. They can be used as amplifiers(duh), voltage subtractors, voltage adders, comparators, level shifters and the list goes on. However for this application we will be using the voltage subtractor and amplifier properties. The circuit you need is below with an explaining following. I encourage you to read all of it, op amps are used in tons of applications.

schematic

simulate this circuit

In this circuit the inverting input will have a constant voltage, which will 'subtract' a voltage from the voltage on the non-inverting input. The gain on the non-inverting input can then be adjusted to give you the scale you want. Now I'm going to direct you to this link, this site is very helpful for new people and I still refer to it when I don't feel like re-deriving equations for common circuits(why re-invent the wheel?). I'm just going to hop to the end where it has the equation I'm going to use. Keep in mind my subscripts are not the same because my resistors are labeled differently.

$$V_{out}=\frac{R_4}{R_3}*(V_2-V_1)$$

Now the high and low voltage of V2 is known, the voltage output that we want is known. Now I'll be assuming R4 is 10k again, since if you don't there will be technically an infinite number of solutions. The equations below show the equation with the numbers pluged in. First for the high voltage you want, second for the low voltage you want.

$$1.2=\frac{10k}{R_3}*(3.1-V_1)$$ $$0.2=\frac{10k}{R_3}*(1.9-V_1)$$

Now when you solve this you get that R3 need to be 12k and V1 needs to be 1.66v. V1 can be obtained by a voltage divider. There's an example further up so i'm going to skip that.

Note 1: Since you are connection this to a microcontroller you may want to add in a zener diode to limit the upper range range of the voltage, with either circuit if the sensor does go above 3.1v, you will go over 1.2v on the output, which if the microcontroller can can only go up to 1.2v, you can damage it. A simple way to do this is with a zener diode. Below is breif circuit of how to do it. You can do homework to understand how it works.

schematic

simulate this circuit

Note 2: Many micro-controllers will have a analog to digital converter(ADC) built into them and the input range of the ADC is from the Vcc of the micro-controller which is commonly 3.3v down to 0v. So you may not even need to do this and instead just attach the output of the sensor right to the micro-controller. Then you can use the ADC to get a number representing the voltage and do whatever you want with it.

\$\endgroup\$
  • \$\begingroup\$ Just tried this, and it actually works :) I now get values between 0.67v and 1.2v. Guess I now have to dive into the more complicated solutions to get a better resolution \$\endgroup\$ – ErikL Jan 29 '16 at 20:20
  • \$\begingroup\$ If you are dead set on the 0.2 to 1.2v range then you should look into something called voltage scale and shift. Its commonly made with two operational amplifiers. In a little time I'll update the post to include it. \$\endgroup\$ – Dave851 Jan 29 '16 at 20:27
  • \$\begingroup\$ The microcontroller I'm using is a ESP8266 ESP12f by the way. Unfortunately there's not a lot of documentation available about the ADC pin it provides, except that it needs a value between 0.2 and 1.2v, with anything higher, it will just read 1024. \$\endgroup\$ – ErikL Jan 29 '16 at 20:32
3
\$\begingroup\$

You should power it from the 3.3V and divide the output voltage down to get the input voltage you need.

Try something like 3K/1.8K.

\$\endgroup\$
1
\$\begingroup\$

I think there are really two problems here.

(1) A DC offset - you require 0.2V - 1.2V you have 1.9V to 3.1V so if everything was shifted down by 1.7V you would have .2V to 1.4V

(2) The range (min -max) doesn't quite match.

The humidity sensor is designed to run from 3V3 so keep it at that but remember that all voltages are relative.

enter image description here

(1) Offset:

Using a suitable op amp we can effectively 'shift' the '0V'to a mid voltage level (say 1V6). The humidity sensor still gets the the full 3V3 which is now supplied as +1V7 and -1V6 (relative to the new '0V' line which is really at +1.6V relative to the '3V3 zero' connected to the humidity sensor).

The outputs (relative to the 0V line) are now 1.5V and 0.3V .

(2) Range:

To reduce the range we add a potential divider circuit (Vout x 0.8). This could be made up from fixed resistors ( say 8k, 2k) or a variable resistor (say 10k).

This now produces an output between 1.2V and 0.24V. Pretty well spot on for your requirements.

The important thing to remember is not to use the voltage supply for the humidity sensor for anything else. You can connect the 0V line to another 0V line in the larger circuit to make a common ground.

\$\endgroup\$
0
\$\begingroup\$

I think your best bet for keeping max. resolution would be NOT to simply divide the voltage, but rather to use an ADC and DAC.
1:Use a 0-3.4V(range) ADC to convert your analog signal with whatever resolution you need.
2:Feed all but the most significant bit (effectively removes 1.7V from input signal, without dividing) to a DAC with output range of 0.2-1.2V

Alternately, you could use a voltage divider from your 3.3v vcc to gnd, then feed the "signal ground" out from the middle of the voltage divider, providing an effective 1.7v offset to the signal; moving your signal range (relative to this signal ground) to 0.2-1.4v

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.