Jeremy Harris
Senior Member
I've seen a few approaches to measuring temperature and relative humidity here, and elsewhere, but none seemed to meet my needs for one reason or another. I wanted a 5 V sensor that would give temperature with 0.1 deg C resolution and 0.5 deg C accuracy and relative humidity to around 3 to 5 % accuracy. Some of the devices around almost do this, but either need 3 V supplies (like the HH10D from Hope RF, which works on 5V but is inaccurate when so run) or the DHT11/DHT22 which have interface issues with the Picaxe because of the signal timing.
After a fair bit of experimentation, I've come up with a combined temperature and relative humidity sensor that is relatively cheap (less that £15), accurate (tested accuracy is better than 3% RH) and easy to build. I used a Humirel HS1101 relative humidity sensor, which is available for around £2 if bought direct from China in small quantities (check out Sure Electronics, for example). This is the same sensor that's used in the Hope RF module. I used a CMOS 555 to convert the sesnor varying capacitance to frequency, and fed this to an 08M2. I also connected a DS18B20 to the O8M2. All the parts fit on a small circuit board that is about 20mm wide and 50mm long and which can be easily mounted inside a short piece of rectangular wiring conduit as a cheap housing.
The 08M2 does some simple arithmetic to convert the frequency and DS18B12 data into meaningful numbers and outputs this as serial data at 4800 baud. This seems to drive fairly long wires OK. The data can then be parsed and read by any device you like, I'm using these as sensors for an environmental data logger (using a 14M2) that stores the logged data to a microSD card, together with a date and time stamp.
The schematic, circuit board layout and code are below, if anyone is interested.
Before using the sensor it need to be calibrated, something that is fairly easy to do. Calibration requires a couple of clean jam jars, some insulating tape, a programming lead hooked up to the sensor board with thin wires, some anhydrous copper sulphate and some pure salt (sodium chloride). Anhydrous copper sulphate will need to be prepared, by baking the bright blue copper sulphate pentahydrate crystals (that are usually sold as plain "copper sulphate") in an oven at 150 deg C until they turn into a light grey powder. In this form copper sulphate is a powerful desiccant and will quickly start to absorb moisture from the air, so it needs to be transferred quickly to a sealed container.
To start the calibration process, edit the lines of code to comment out the normal data transmission line and uncomment the calibration line (these are marked by comments in the code below). The sensor module will now transmit temperature in deg C as ASCII and the frequency of the CMOS 555 in Hz, and these can be read using the terminal window in the Picaxe Programming Editor. Prepare a 0% RH chamber by sprinkling a few mm thickness of anhydrous copper sulphate into a jam jar, fitting the lid tightly and giving it a good shake. It may warm up slightly as moisture is absorbed, as the reaction is exothermic.
Next bang the jar on a hard surface to settle the powder at the bottom and quickly undo the lid, place the sensor module in the clear space at the top of the jar and close the lid, trapping the wires. Run a length of insulating tape around the lid/jar join to seal it and the wires. Next the jar needs to be left for a few hours at a constant temperature of around 20 deg C for all the moisture to be taken out of the air inside. This can be monitored by connecting the module to the terminal and watching the frequency change. It will increase, probably to somewhere around 8000 to 8400 Hz, as the air dries out. When the frequency has been reasonably stable (it will vary by a few Hz due to noise) for a time, note down the final 0% RH frequency, as you will need to enter it into the module code later. The module can now be removed from the jar and the jar re-sealed for use again if required.
To set the sensitivity of the module it needs to be calibrated at a known high relative humidity. Luckily, the air above a saturated salt will give a constant relative humidity over a modest temperature range. Ordinary pure table salt, when mixed with just enough water to form a thick slurry, will give a relative humidity of 75.7% at 20 deg C, and only vary by about 0.1% for around 5 or more degrees either side of that temperature. Using the second clean jam jar, place a thin layer of salt slurry in the base, place the sensor as before in the clear space and close and seal the lid with tape. Leave this for a few hours at as constant a room temperature as possible for the relative humidity to stabilise. As before, you can see when it has stabilised because the frequency will stop slowly changing. Note the frequency you end up with, it should be around 800 to 1000 Hz lower than the 0% RH frequency.
With both frequencies the sensitivity factor can be determined, using the formula: sensitivity = (75.7*4096)/(0% frequency - 75.7% frequency)
The module code can now be changed back to the final version by commenting out the calibration output line, un-commenting the normal output line and inserting the 0% RH frequency in the "LET offset = " line at the top of the code and the calculated sensitivity figure in the line beneath this. The module is now calibrated and will output data about once per second in the format "T", "sign_byte",whole_deg_byte,"decimal_deg_byte","H",relative_humidity_byte, where bytes in quotes are ASCII (for example, sign_byte is either "+" or "-", ASCII 43 and 45 respectively). The format of the output serial data stream can easily be changed; this format happened to work well with my logging application. I rename the code file to reflect the offset and sensitivity factors and also label the board with them, following final programme download.
I don't pretend that the code is either that tidy or well-optimised, but it does work OK and timing etc isn't at all critical in this application, so I'm happy with it. There are snippets in there that I've adapted from code others have generously shared and I acknowledge the help this has been, with thanks to the original authors.
There is more on the core project that this is a part of in this thread in the "Finished Projects" area: http://www.picaxeforum.co.uk/showthread.php?20551-Environmental-uSD-card-data-logger
After a fair bit of experimentation, I've come up with a combined temperature and relative humidity sensor that is relatively cheap (less that £15), accurate (tested accuracy is better than 3% RH) and easy to build. I used a Humirel HS1101 relative humidity sensor, which is available for around £2 if bought direct from China in small quantities (check out Sure Electronics, for example). This is the same sensor that's used in the Hope RF module. I used a CMOS 555 to convert the sesnor varying capacitance to frequency, and fed this to an 08M2. I also connected a DS18B20 to the O8M2. All the parts fit on a small circuit board that is about 20mm wide and 50mm long and which can be easily mounted inside a short piece of rectangular wiring conduit as a cheap housing.
The 08M2 does some simple arithmetic to convert the frequency and DS18B12 data into meaningful numbers and outputs this as serial data at 4800 baud. This seems to drive fairly long wires OK. The data can then be parsed and read by any device you like, I'm using these as sensors for an environmental data logger (using a 14M2) that stores the logged data to a microSD card, together with a date and time stamp.
The schematic, circuit board layout and code are below, if anyone is interested.
Before using the sensor it need to be calibrated, something that is fairly easy to do. Calibration requires a couple of clean jam jars, some insulating tape, a programming lead hooked up to the sensor board with thin wires, some anhydrous copper sulphate and some pure salt (sodium chloride). Anhydrous copper sulphate will need to be prepared, by baking the bright blue copper sulphate pentahydrate crystals (that are usually sold as plain "copper sulphate") in an oven at 150 deg C until they turn into a light grey powder. In this form copper sulphate is a powerful desiccant and will quickly start to absorb moisture from the air, so it needs to be transferred quickly to a sealed container.
To start the calibration process, edit the lines of code to comment out the normal data transmission line and uncomment the calibration line (these are marked by comments in the code below). The sensor module will now transmit temperature in deg C as ASCII and the frequency of the CMOS 555 in Hz, and these can be read using the terminal window in the Picaxe Programming Editor. Prepare a 0% RH chamber by sprinkling a few mm thickness of anhydrous copper sulphate into a jam jar, fitting the lid tightly and giving it a good shake. It may warm up slightly as moisture is absorbed, as the reaction is exothermic.
Next bang the jar on a hard surface to settle the powder at the bottom and quickly undo the lid, place the sensor module in the clear space at the top of the jar and close the lid, trapping the wires. Run a length of insulating tape around the lid/jar join to seal it and the wires. Next the jar needs to be left for a few hours at a constant temperature of around 20 deg C for all the moisture to be taken out of the air inside. This can be monitored by connecting the module to the terminal and watching the frequency change. It will increase, probably to somewhere around 8000 to 8400 Hz, as the air dries out. When the frequency has been reasonably stable (it will vary by a few Hz due to noise) for a time, note down the final 0% RH frequency, as you will need to enter it into the module code later. The module can now be removed from the jar and the jar re-sealed for use again if required.
To set the sensitivity of the module it needs to be calibrated at a known high relative humidity. Luckily, the air above a saturated salt will give a constant relative humidity over a modest temperature range. Ordinary pure table salt, when mixed with just enough water to form a thick slurry, will give a relative humidity of 75.7% at 20 deg C, and only vary by about 0.1% for around 5 or more degrees either side of that temperature. Using the second clean jam jar, place a thin layer of salt slurry in the base, place the sensor as before in the clear space and close and seal the lid with tape. Leave this for a few hours at as constant a room temperature as possible for the relative humidity to stabilise. As before, you can see when it has stabilised because the frequency will stop slowly changing. Note the frequency you end up with, it should be around 800 to 1000 Hz lower than the 0% RH frequency.
With both frequencies the sensitivity factor can be determined, using the formula: sensitivity = (75.7*4096)/(0% frequency - 75.7% frequency)
The module code can now be changed back to the final version by commenting out the calibration output line, un-commenting the normal output line and inserting the 0% RH frequency in the "LET offset = " line at the top of the code and the calculated sensitivity figure in the line beneath this. The module is now calibrated and will output data about once per second in the format "T", "sign_byte",whole_deg_byte,"decimal_deg_byte","H",relative_humidity_byte, where bytes in quotes are ASCII (for example, sign_byte is either "+" or "-", ASCII 43 and 45 respectively). The format of the output serial data stream can easily be changed; this format happened to work well with my logging application. I rename the code file to reflect the offset and sensitivity factors and also label the board with them, following final programme download.
I don't pretend that the code is either that tidy or well-optimised, but it does work OK and timing etc isn't at all critical in this application, so I'm happy with it. There are snippets in there that I've adapted from code others have generously shared and I acknowledge the help this has been, with thanks to the original authors.
There is more on the core project that this is a part of in this thread in the "Finished Projects" area: http://www.picaxeforum.co.uk/showthread.php?20551-Environmental-uSD-card-data-logger
Attachments
-
29.1 KB Views: 323
-
5.2 KB Views: 178