simulate this circuit – Schematic created using CircuitLab
So I am having trouble trying to figure out how to scale voltage from 22-32V to 0-5V. I know that Vout= 0.5Vin - 11 will give me the proper voltage values I need. I am trying to monitor the voltage of a battery with my Arduino.
I tried doing a voltage divider for R1= 54K and R2=10k. When Vin=32 I do get Vout=5V, but when Vin=22 Vout=3.43. I have read that a third resistor or Op amp will help but I am just not sure how to pick the third value. How can I include the bias needed? Any links or examples would be greatly appreciated.