• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Help with maths (RH sensor & ADC)

Not open for further replies.


Well-Known Member
Most Helpful Member
i need some maths help, as i have admitted before my maths is poor, i am trying to do something about it but at the moment i need some help with what is probably simple maths. first off i am not after code (i want a bash at that first). a couple of weeks ago when i first knew about the incubator comp i phoned Honeywell uk to ask about there humidity sensors and sample program :D (always worth a try!) i went for honeywell because dad uses sensiron sht71's normally and i wanted something different and more accurate, also i wanted something a bit easier to use than sensiron's software routines which are a bit complicated and voltage dependent.
so i spoke with a nice lady in customer service who told me that honeywell dont actually have a samples program as such but suggested i call my normall supplier and ORDER one from them ( o_O), so i explained my age and that i really wanted to try one of there sensors as i have tried others but on paper there's seemed better more accurate and easier to use and i didnt have £30 to spend on a sensor! :D she took my number and address, i thought oh well thats that and hung up. Today a packet turned up with a note that basically said i was very cheeky to ask but she had dug around and found some old obsolete sensors that one of there distributors had tucked away that were customer returns but worked perfect! so ive got a RS bag with 5x HIH-3610 humidity sensors in.
now the hard part! ive looked at the datasheet to see whats what (data sheet here http://rosset.org/linux/datasheet/HIH3610.pdf ),
the good news is i can use the ADC on a pic to read it, the bad news is i dont really understand the maths so here is a screen shot of the relevant page

now my problem with this sheet is things like the section where it say's voltage output vout=Vsupply(0.0062(Sensor RH)+0.16) and things like this because, i am ashamed to admit i have no idea what to do except maybe you do the bits in brackets first, but there are no / or x signs so i dont know if i have to x or / or what! i am slowly trying to learn maths but still have huge amounts to learn. anyway i did a google to try and find out what the actual calculation was. One the sites i came upon (apart from phanderson which again seemed complicated) i came across this site http://vwlowen.co.uk/picaxe/weather-station/page-2.htm
which is basically the same sensor but done with picaxe basic, i dont want to copy the code (i am doing it in C anyway) but i had a look at how he worked out the RH from the ADC reading, and here is a shot of that bit
sensor maths.JPG
so i thought i would simply plug my values in and get the equation for my ADC, but i need it checking first to make sure he got it right then to make sure i have it right lol,
now what i was thinking was killing 2 birds one stone and use the pic 30f because it has a great ADC unit and 12 bit's! (you can also make it 10 bit)
anyway doing it his way i get the following (oh forgot to add that the sensor is calibrated at 5V so i was going to use 5V regulated for the sensors and ADC ref)
first he works out the voltage for each ADC step so in my case thats

5V/4096 (12bit) = 0.001220703125

he then rounding off that figure and i was going too but decided against because using just the first 4 digits after the Decimal point makes a big difference in 12bit
then it says because the graph has 0.8V offset he divides that by the mV per ADC to get the number of ADC steps for the offset, now first i did it without rounding it up or down

so for me thats 0.8V/0.001220703125 =655.36 ok i round this to 655steps for the offset but just to show the difference if i had of rounded it to 4 digits like he has it works out like this

0,8V/0.0012=666.6666666666667 0r rounded 667 wich is a big difference so i decided to stick with 655 and live without the .36
so next step
he uses the graph from datasheet and taking offset into account the graph slope is linear (roughly) and is voltage out/%RH

so he gets for Volts per %RH (2.65-0.8)/60 = 0.0308 (rounded )(although it says that a later datasheet say's it's 0.0306)

so the ADC steps per %RH is Volts per %RH / Volts per ADC step

so in my case it's 0.0308/0.001220703125 =25.23136(or rounded 25.23)

then its %RH =ADC reading-655/25.23

to do away with floating point he then x top and bottom by 100 so for me

%RH=ADC(reading)-655(the offset)*100/2523

so is this correct way to do it? like i say i dont need code help (at the moment anyway) just making sure i am on the right track with the figures :D


Well-Known Member
The formula is correct, assuming you put parantheses around ADC and offset.

It's all easier though. Their formula:

V = Vsupply x (0.0062 x RH + 0.16)


V/Vsupply = 0.0062 x RH + 0.16

V/Vsupply - 0.16 = 0.0062 x RH

RH = (V/Vsupply - 0.16)/0.0062

ADC 4096 reading corresponds to Vsupply, so V/Vsupply is the same as ADC/4096. Therefore

RH = (ADC/4096 - 0.16)/0.0062


RH = ADC x 0.0394 - 25.8

or, if you prefer

RH = (ADC - 655) x 0.0394

The problem with this is that their formula is typical, so each sensor will have a similar formula, but they all will be slightly different. To be accurate the sensor needs calibration. In my experience, humidity sensors are very hard to calibrate. You probably won't be able to calibrate better than 5%RH even though the specsheet says 2%RH.


Well-Known Member
Most Helpful Member
thanks north guy, i am trying to keep away from floats with this, as long as i know i am on the right track ;) not 100% sure i will use 12 bit 30f depends!! as for calibrating i do have access to a calibrated sht71 but i am happy for now with 5% if thats what i get, its still better/quicker than 2 ds18s20's or such like set up as a wetbulb config! that way lies plenty pain!! alot/some pro companies comercial units use those and it's horrible and at times very unstable!


Well-Known Member
Most Helpful Member
i have been thinking hard about this, and as my man use will involve temperature ranges around 38.6C i should really be using the temperature compensation as well, i will think about it a little more and if i get stuck will post here :D


Well-Known Member
Since you're going to use it in nearly constant temperature, you can simply calibrate it at 38C, and it'll be fine.


Well-Known Member
Most Helpful Member
that is probably what i will do to get u and running (getting low on time!) but long run i will return to it and just for the learning aspect and practice in maths etc i will have a go at adding temperature compensation


Well-Known Member
Most Helpful Member
for now i am thinking ahead i have found some sensors (temp) that are i2c bus but not that accurate 2C +- but might do for brooder and maybe even fan temp leveling (doubt it tho for that) but if i do use them it's mainly a learning exercise as they output in two's compliment which if i am honest i have done everything to avoid so far!! but have had a peek into it today and it dosnt seem that bad after all (once you sift through all the complicated nonsense that written and get to the nitty gritty of invert and add one, so code wise i am going to spend time later making sure i really understand Boolean logic!
trying hard to get past the whole cut and paste type programming! and actually learn all this stuff! hence my huge increase in asking questions :D and sudden depletion of the bank account buying books! still i prefer to spend my pocket money and wages (when i get them) of stuff like books!
need also to go back into saving's mode! and stop spending! finally spent m birthday money today! but now i have i am not sure it was worth it! i have been wanting a microchip serial analyzer for a while so finally ordered one today (many reason why i want one), but having had a proper look at the circuit diagram i am starting to think i could have built it from the spares box, as long as the mosfets could be changed for ones i have hanging about then i could probably build one on single side board (all i have) with parts i already have! i cant see any really critical parts in the design although i may be wrong! and the source code is free!
going to look into it before i open the package, i could save alot of cash sending it back if i can make one!
anyway just some mumblings sorry about that
Not open for further replies.

Latest threads

EE World Online Articles