This is only a preview of the June 2009 issue of Silicon Chip. You can view 31 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "High-Current, High-Voltage Battery Capacity Meter, Pt.1":
Items relevant to "GPS Driver Module For The 6-Digit Clock, Pt.2":
Articles in this series:
Items relevant to "Build A Beam-Break Flash Trigger":
Items relevant to "PICAXE Humidity Measuring Using The HopeRF HH10D":
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
PICAXE humidity
using the HopeRF
Recent SILICON CHIP articles on HopeRF 433MHz data transceivers have
drawn our attention to other monitoring modules made by this Chinese
firm. Amongst their offerings is a well-priced and calibrated humidity
sensor, the HH10D. This has shown itself capable of extremely simple
interfacing to even the humblest PICAXE, although factory calibration
values first need reading via an I2C-level PICAXE such as the 18X.
A
lthough atmospheric humidity
levels may not be considered
as interesting as temperature,
numerous environmental situations
arise when humidity insights can be
crucial.
Relative humidity (RH) levels range
from a bone dry 0% to 100% (when
the air is so saturated that dew forms).
Although temperature dependant,
human comfort levels typically range
between 40-60% RH.
Drier air may cause skin conditions,
static discharges and thirst due to
excessive sweating. Higher RH levels
are associated with food spoiling, disease, moulds and human discomfort,
due to an inability for perspiration to
evaporate.
In contrast plants may wilt in dry
air (and hence usually favour higher
humidity levels) but food preservation,
equipment storage and crop drying
best suits low RH levels.
Naturally the likely onset of rain
may be associated with a rise in the
atmospheric RH levels too – a technique used by many home weather
stations.
Relative humidity is classically
measured by techniques ranging from
paper and hair stretching to more sci-
entific dual “wet and dry bulb” thermometers, with simple instruments
based around this latter approach still
capable of very good results.
Although inconvenient, a couple
of similar thermometers and a moist
cotton shoelace can readily give doit-yourself RH insights.
The moist bulb cools as the evaporating water takes thermal energy from it,
with the degree of “wet” temperature
drop being inversely related to the
RH.
(Refer to www.picaxe.orconhosting.
net.nz/humtable.jpg for the resulting
wet/dry tables).
Electronic humidity measuring has
predictably developed, being normally
now done with specialised capacitors,
since an exposed and porous dielectric
slowly changes its moisture content
in response to humidity levels in surrounding air. If used in an RC oscillator
circuit, small frequency changes can
be linked to the altered capacitance
value.
Humidity module
The HopeRF HH10D relative humidity sensor module, available from
Microzed and Futurlec for around
$13, utilises a capacitive-type sensor
element linked to two on-board ICs.
The first is an M24C01 EEPROM which
is used to hold two factory calibration
related values required to calculate the
relative humidity as a percentage.
The second IC is a humble CMOS
555 timer whose output signal varies
in frequency with the change in capacitance as the humidity level changes.
Of course, such an RC oscillator is a
classic 555 application, although the
frequency is usually altered by resistor
variation.
Accessing the EEPROM
calibration data
The EEPROM requires an I2C communications bus to read the calibration
data but as these are fixed values, the
data needs only be read once.
If you only have a small PICAXE-08M
then tedious “bit-bashing” may be
needed to read the two calibration
values. Larger PICAXE chips (such
as the 18X) however handle I2C commands directly and just a few lines of
code will display these constants via
a DEBUG screen.
The HopeRF datasheet does not
give the EEPROM I2C slave address,
which is the same as other EEPROM
and FRAM chips, however their data-
(Left): an enlarged photo of the HopeRF HH10D
humidity measureing module, with the physical
component layout shown at right. The same module
can be seen from the opposite side in the breadboard
layout on the opposite page. Note the label fixed to the
back of the PC board – this is explained in the text.
76 Silicon Chip
R1
SENSOR
POSITION
JB
R2
U1
EEPROM
C2
C4
R
3
U2
CMOS 555
C
1
X
SCL
X
SDA
(NC)
(NC)
FOUT
+3V
C3
GND
HopeRF HH10D HUMIDITY SENSOR – COMPONENT SIDE
siliconchip.com.au
measuring
HH10D module
By Wayne Geary
and Stan Swan
sheet does indicate that the EEPROM
external address pins are configured
to address 01.
While the HH10D datasheet indicates that there are three calibration
values, only two are in fact used:
• The Sensitivity value is stored in
EEPROM locations 10 and 11
• The Offset value is stored in
EEPROM locations 12 and 13.
Here is an example of the program
lines required to use a PICAXE with
inbuilt I2C communications bus. This
has been written using commands that
any PICAXE X, X1 or X2 type chip
can use.
I2CSLAVE %10100010, i2cfast,
i2cbyte
READI2C 10, b0, b1, b2, b3
DEBUG
The PICAXE DEBUG command
will display theses byte variables in
a Programming Editor window for
recording.
Those experienced with the PICAXE
chips will know that word variables
(w) use the byte variable (b) with the
odd number as the Least Significant
Byte (LSB) and the byte variable with
the even number as the Most Significant Byte (MSB) The HH10D humidity
module however has the even location
as the LSB and the odd location as
the MSB.
As an example, using the above lines
of program, we might see the byte variables in decimal format as:
siliconchip.com.au
Almost any classic PICAXE layout could be used, since only a single monitoring
wire is needed! Here’s a hybrid PC board and breadboard approach, with the
PICAXE-08M mounted on a trimmed AXE021 protoboard. That TO-92 package
is a 78L03C low power 3V regulator. Although PICAXEs are more tolerant,the
HH10D must not be supplied any more than 3.3V.
b0 = 01, b1 = 85, b2 = 30 and b3
= 29
From these byte values we can determine the calibration values as:
Sensitivity (Sens) = 1 * 256 + 85
= 341
Offset Value = 30 * 256 + 29 =
7709
It’s suggested you make a note of
these calibration values, perhaps printing them on a small label to stick to the
rear side of the small humidity module
PCB. An example is given below:
HH10D
Sens 341
Offs 7709
For users without I 2 C capable
PICAXEs at hand, it may be tolerable
to just use values approximating ours –
testing of several HH10D units showed
most modules were close in value to
these anyway.
However cross-checks against readings from a known good weather station (or even a classic dual thermometer “wet and dry bulb” hygrometer)
could aid later fine tuning calibration.
Humidity Module connection
and output.
Once the calibration data is read, the
HH10D humidity module is very easy
to use. Of the 5 connections only three
are required for VDD supply (3V), Gnd
(0V) and FOUT (Soh).
Note that the 3V rated module must
June 2009 77
Don’t you just love how PICAXEs
make circuitry so simple? The HopeRF
HH10D Humidity Module interfaces
dirctly with PICAXE chips, albeit
with a bit of fiddling around with
programming to overcome some of the
lower-end PICAXE chips’ limitations.
Note the supply voltage in this circuit
– 3V instead of the usual 4.5V – even
though the PICAXE is quite happy at
the higher voltage, such would make
short work of the HH10D (absolute
maximum 3.3.V, as shown in the spec
table below).
CON1
DB9
6
7
8
9
2
3
ON
1
22k
4
5
10k
TO PC
SERIAL
PORT
2
1
7
IC1
3 PICAXE 6
-08M
4
8
5
0
1
2
HOPERF
HH10D
HUMIDITY
SENSOR
SCL
FOUT
+V
GND
3V
3
4 I/O
PINS
(CHANNELS)
SC
2009
8
4
1
Picaxe HUMIDITY SENSOR
NOT be run on any more than 3.3V – a supply value that
fortunately PICAXE-08Ms still readily work with.
For testing, two AA 1.5V cells should hence be suitable
to supply the entire reading setup.
For breadboard or soldered prototype mounting, the
module’s 5-pin SIP header terminal strip connectors may
better suit being resoldered from the other side of their
holder PC board, as this then allows the capacitive sensor
to be more conveniently mounted away from other circuitry
and upright into clear air.
Ensure the correct module connections are being used
if this simple modification is made! Right-angle SIP strips
could also be used for vertical mounting – the exact choice
depends on your application.
The output signal on the pin FOUT (called Soh in the
datasheet formula) is a frequency of approximately 6-8kHz
which varies as the humidity level varies.
The PICAXE COUNT command, which rapidly counts
the number of times a designated input pin changes from a
low to a high state within a given time period, can readily
help here. This makes use of the frequency of a signal being of course the number of such cycles per second (recall
f=1/T), so simply COUNTing the HH10D signal for 1 second
should give the frequency.
From the HH10D module datasheet we are given the
following formula to calculate the Relative Humidity as a
percentage value:
RH(%)= (offset-Soh) * sens/212
Substituting the calibration values extracted from the
sample module gives:
RH(%)= (7709-Soh) * 341/4096
However, a few minor problems experienced with
PICAXE maths now arise:
• only integer (whole number) maths are performed
• the largest number held by a word variable (W) is 65535
• it does not support brackets for precedence.
#PICAXE 08M
‘Sample HopeRF HH10D humidity module program for June 2009 SiChip
‘Ref resources => www.picaxe.orconhosting.net.nz/hopehum.htm
‘IO DEFINITIONS
SYMBOL humid
=3
‘
‘ VARIABLE DEFINITIONS
SYMBOL axefactr
= b2
SYMBOL Soh
= w2
‘w2 = b5:b4
SYMBOL diff
= w3
‘w3 = b7:b6
SYMBOL RH
= w4
‘w4 = b9:b8
‘
‘ CONSTANTS -strictly need to be read via I2C for each module, but can be assumed close
SYMBOL Offset
= 7709
‘HH10D offset calibration constant - a second module has 340
SYMBOL Sens
= 341
‘HH10D sensitivity calibration constant - a second module has 7762
‘
‘ MAIN PROGRAM
Main:
COUNT humid, 1000, Soh
‘read the frequency (ie cycles in 1 second)
diff = Offset - Soh
axefactr = diff / 19 + 1
‘factor prevents number roll over error if >65535
RH = 10 * Diff / axefactr * Sens
‘int. result (x10 gives possible 0.1 resolution)
axefactr = 4096 / axefactr
‘a factor to prevent number roll over error
RH = RH / axefactr
‘final value for RH%
RH = RH / 10
‘divide by 10 (for now) as just whole integer RH%
SEROUT 1, N2400, (“RH% = “, #RH)
PAUSE 5000
‘wait for 5 seconds until next reading
GOTO Main
78 Silicon Chip
siliconchip.com.au
As might be seen, multiplying a number greater than 192
by 341 will result in an overflow of the values! Likewise,
dividing by 4096 may result in loss of accuracy as no fractional part is retained.
To improve the accuracy of the maths, allow one decimal
place and also avoid overflow within the PICAXE maths, we
have introduced a factor. This factor is a variable number
defined to keep the intermediate results as large as possible
which will help minimise error.
Our variable called Axefactr (short for “PICAXE factor”)
is a value determined as follows:
HOPERF
INCLUDING
THE HopeRF HH10D
HUMIDITY SENSOR
USED IN THIS
ISSUE!
Axefactr = (offset- Soh) / 19 + 1
This number will calculate correctly with the PICAXE.
The result will be a number from 1 to 64 inclusive. Using
this factor and multiplying the early part of the calculation by 10 makes it possible to extract 1 decimal place ( if
required), at the completion of the calculation.
Digital Sensors
RH10(%)= (((offset - Soh) / 19) + 1) * 10) * Sens /
(4096 / Axefactr)
This awkward calculation needs to be broken over several
lines of code in the PICAXE. To save on the limited number
of variables available to the PICAXE chips, some are reused
for a new variable part way through the calculation.
After all the number crunching and formula tweaking,
just a single PICAXE-08M input pin (here 3) suffices for
eventual reading of this final value, with a SERTXD showing %RH readings on the Editors F8 terminal.
The code shown at left can also be downloaded from
www.picaxe.orconhosting.net.nz/hopehum.bas. In future,
we plan to extend use of this humidity module with the
HopeRF 433 MHz wireless data transceivers.
Article resources and references can be linked to, from
www.picaxe.orconhosting.net.nz/hopehum.htm
SC
RF IC & Modules
Sensor Performance Specifications and
HH10D Humidity Module Characteristics
Parameters
Min
Typ
Max
Units
Resolution
0.3
0.08
0.05
%
3
Accuracy
Repeatability
-0.3
%
0.3
%
Uncertainty
2
%
Response Time
8
s
Hysteresis
1
%
Interchangeability
Fully Interchangeable
Humidity Range
1
99
%
Temperature range
-10
+60
°C
Working voltage
2.7
3.3
V
3
Semiconductor
Devices
SAW Devices
Distributed in Australia by
Power consumption
120
150
180
A
Microzed Computers Pty Ltd
Output Frequency Range
5.0
6.5
10
kHz
Phone: 1300 735 420 Fax: 1300 735 421
1%
Stability versus time
per year
Here are the manufacturer’s specifications for the HH10D
Humidity Module. All it needs are supply and data output
lines to interface with the PICAXE.
siliconchip.com.au
www.microzed.com.au
June 2009 79
|