HH10D Issues

tjetson

Senior Member
Hi

I'm trying to read the i2c values from the HH10D and I am having some trouble. If I read from location 10, then I get:

1 114 29 205

I am unsure what to do next. According to the Silicon Chip article (using my values):
Sens = 1 * 256 + 114 = 370

Offset = 29 * 256 + 205 = 7629

These values differ slightly from SC's values of 341 and 7709. If I then use their code to determine RH%, I get 24% humidity. This isn't right! In my room, an old baro/thermo/hyrgometer reads about 41%. This is the code I use to calculate everything:
Code:
symbol humid = c.1

'Variables
symbol axefactr = b2
symbol Soh = w2
symbol diff = w3
symbol RH = w4

'Constants
symbol Offset = 7629
symbol Sens = 370

Main:
	Count humid, 1000, Soh
	diff = offset - Soh
	axefactr = diff / 19 + 1
	RH = 10 * diff / axefactr * sens
	axefactr = 4096 / axefactr
	RH = RH / axefactr
	RH = RH / 10
	sertxd ("RH% = ",#RH,cr,lf)
	pause 5000
goto main
And this is the code I use to read the initial values:
Code:
i2cslave %10100010, i2cfast, i2cbyte
readi2c 10, (b0, b1, b2, b3)

debug

Can anyone find fault with any of my code? Also, I should mention I am running on a 20X2. The sensor and axe both run off a pair of AAs @ 3.182volts. All of this is set up on a breadboard. The i2c pullups (4.7k) are fitted. My multimeter on frequency says the Fout pin is 6.86kHz.
 

hippy

Ex-Staff (retired)
I'm not familiar with the HH01D, the Silicon Chip article, nor really sure what your code is meant to do or how it works, some pointers and explanations will help, especially on how the 'humid' handling calculation is meant to work and what equation it is derived from.

Try putting SERTXD's in the code to report the results of calculations, see if you can spot an error in there, perhaps run it through simulation to see what is going on.
 

MartinM57

Moderator
Have you done a search on the forum for "HH10D" (no quotes) - there seems to be quite a lot of stuff about reading it and the calibration values....
 

westaust55

Moderator
Your Sens and Offset values look okay and the Fout value from you multimeter is in range.

My maths suggest that for 6.86kHz, you should be calculating the RH as 69%

See the attached table:

Can you try just the lines:

Code:
symbol humid = c.1
symbol Soh = w2

Do
Count humid, 1000, Soh

SERTxd ("Fout = ", #Soh, 13,10)
Loop
and see what frequency your PICAXE chip is seeing

The higher humidity value (340%) suggests a frequency or pulse count that is too low as if the PICAXE is missing pulses.
 

Attachments

tjetson

Senior Member
I let it run for a few readings:
Code:
Fout = 3477
Fout = 3477
Fout = 3477
Fout = 3477
Fout = 3477
Fout = 3477
Fout = 3478
Fout = 3478
Fout = 3478
Fout = 3477
Fout = 3478
Fout = 3477
Fout = 3478
Fout = 3477
Fout = 3478
Fout = 3478
Fout = 3477
Fout = 3477
Fout = 3477
Fout = 3477
So the Picaxe seems to be giving me around half of the actual frequency, right?
 

tjetson

Senior Member
Something interesting has occured. At the bottom of the editor, on the right hand side it says PICAXE 20X2 4M. That got me thinking that maybe the frequency was wrong. First I tried setfreq m8, and the values didn't change. I tried 16, and they went to half (19xx or so). Then I realised I was going in the wrong direction. I tried setfreq m4 and now it gives me around 6946 for my values in your code.

However, using MY code, changing the frequency doesn't give me any correct RH values.

I closed the editor, opened again a little later and that 4M had disappeared. I cleared the hardware, changed pins for Fout and downloaded your program again, still gives me values in the 3k range.
 
Last edited:

hippy

Ex-Staff (retired)
That "PICAXE-20X2 4MHz" in the Program Editor is an artefact hanging over from when a previous PICAXE was selected. The status display isn't being updated entirely correctly but does not affect the operation of any program nor PICAXE.

That you are using a 20X2 is likely the clue. COUNT periods at 8MHz are half what they would be at 4MHz. A COUNT for 1000 is 1 second at 4MHz, but only 500ms at 8MHz.
 

tjetson

Senior Member
Ok, so if I set the Picaxe frequency as m4, I get a correct-looking value for the Fout of the sensor. I then get 62% Humidity! This all appears to work great. Thanks for everyone's help. If I wanted to use m8 instead, would the code need the count 1000 to be changed to 500 or 2000?

EDIT: Actually, my humidity guage says my humidity is actually more like 46%. So it seems I've got the frequency to give me a nice value, but my maths isn't working properly. BTW if I change between 19 and 17 as discussed above it changes between 62% and 2%. Hmm...

EDIT 2: It now looks like my humidity guage is wrong. 62% looks to be fairly right I think.
 
Last edited:

westaust55

Moderator
Thats okay.

If you look in the PICAXE manual 2 under the COUNT and PAUSE commands etc you will see works such as:
"- Period is a variable/constant (1-65535ms at 4MHz)."
and
"Affect of increased clock speed:
The period value is 0.5ms at 8MHz and 0.25ms at 16MHz."
 
Top