: 1-Wire Humidity Sensor in Java

Maker QR in Java : 1-Wire Humidity Sensor
Example: 1-Wire Humidity Sensor
Encoding QR-Code In Java
Using Barcode creator for Java Control to generate, create Denso QR Bar Code image in Java applications.
At the time of this writing there were over 20 containers, one for each device family Now we ll take a closer look at the container for one of the more interesting 1-Wire device families, the DS2438 A/D (Analog to Digital) converter The DS2438 includes an A/D converter, a temperature sensor, an elapsed time meter, and 40 bytes of nonvolatile memory The practical uses for a device that can measure analog voltages and currents as well as sense temperature are nearly unlimited For example, the DS2438 can be used to create sensors that monitor various environmental conditions including temperature, solar radiance, humidity, and barometric pressure We would expect a container designed to encapsulate the DS2438 s behavior to provide simple methods for accessing the memory, reading the current temperature, and returning the voltage read on its A/D pin For our purposes we ll need to be able to read the temperature and the input voltage on the Vad pin as well as
Bar Code Printer In Java
Using Barcode printer for Java Control to generate, create bar code image in Java applications.
Containers
Bar Code Recognizer In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
the supply voltage (Vdd) OneWireContainer26 (the DS2438 has a family id of 0x26) provides the following methods to serve these purposes 13
Quick Response Code Encoder In C#.NET
Using Barcode creation for .NET Control to generate, create Denso QR Bar Code image in .NET applications.
public void doADConvert(int channel, byte[] state) throws OneWireIOException, OneWireException public double getADVoltage(int channel, byte[] state) throws OneWireIOException, OneWireException public void doTemperatureConvert(byte[] state) throws OneWireIOException, OneWireException public double getTemperature(byte[] state)
QR Code Drawer In VS .NET
Using Barcode drawer for ASP.NET Control to generate, create Denso QR Bar Code image in ASP.NET applications.
Both the voltage and temperature measurements are split into two phases: performing a conversion and reading the result So, for example, to read an analog voltage from the DS2438, an application invokes doADConvert, followed by getADVoltage The channel parameter of the doADConvert method allows the caller to specify which analog voltage is desired In Example 41 we ll need to read both Vad and Vdd This example uses a DS2438 and its associated container to create a 1-Wire humidity sensor The circuit diagram for the humidity sensor is shown in Figure 43 This circuit uses a core humidity sensor from Honeywell that outputs an analog voltage that can be used in conjunction with the supply voltage and temperature to calculate the relative humidity using Equation 1 and Equation 2 The DS2438 (U1) provides a 1-Wire communication interface for the composite sensor as well as the analog-to-digital conversion and the temperature measurement The schottky diode, D2, is used to protect the circuit from negative voltages greater than about 400 millivolts in magnitude D1 and C1 are used to build a parasite power supply that steals energy from the bus during high periods Finally, R1 and C1 serve as a low-pass lter
QR Drawer In VS .NET
Using Barcode printer for .NET framework Control to generate, create Quick Response Code image in .NET framework applications.
Vdd DATA (1- Wire)
Denso QR Bar Code Encoder In Visual Basic .NET
Using Barcode printer for .NET Control to generate, create QR Code image in .NET applications.
1 2 3
UPC A Maker In Java
Using Barcode creation for Java Control to generate, create UPCA image in Java applications.
D1 DQ 8 Vdd D2
Data Matrix 2d Barcode Encoder In Java
Using Barcode maker for Java Control to generate, create Data Matrix ECC200 image in Java applications.
100K R1
Paint GS1-128 In Java
Using Barcode generator for Java Control to generate, create USS-128 image in Java applications.
Vdd DS2438
Generate EAN13 In Java
Using Barcode drawer for Java Control to generate, create European Article Number 13 image in Java applications.
HIH-3605-A
Generating Code 128B In Java
Using Barcode drawer for Java Control to generate, create Code 128 Code Set C image in Java applications.
C1 01uF
ITF14 Maker In Java
Using Barcode creator for Java Control to generate, create ITF-14 image in Java applications.
C2 01uF GND
Code 128A Maker In .NET
Using Barcode generator for Visual Studio .NET Control to generate, create Code 128A image in Visual Studio .NET applications.
1-Wire humidity sensor
Recognize Code 128B In Visual Studio .NET
Using Barcode decoder for .NET framework Control to read, scan read, scan image in VS .NET applications.
13 This part actually contains much more functionality and therefore many more methods than needed for our example
Making UPC-A In VS .NET
Using Barcode printer for ASP.NET Control to generate, create UPC-A image in ASP.NET applications.
4
Create Data Matrix 2d Barcode In C#.NET
Using Barcode drawer for Visual Studio .NET Control to generate, create Data Matrix ECC200 image in VS .NET applications.
The 1-Wire Net
EAN 128 Drawer In .NET
Using Barcode generation for Visual Studio .NET Control to generate, create EAN / UCC - 14 image in .NET framework applications.
The output of the humidity sensor is an analog voltage proportional to the supply voltage From the HIH-3605 data sheet, the relative humidity at 25 C can be computed with respect to the supply voltage (Vdd) using Equation 1
EAN13 Drawer In .NET Framework
Using Barcode creator for .NET framework Control to generate, create GTIN - 13 image in Visual Studio .NET applications.
RHsensor = (Vout/Vdd
Barcode Creator In Visual C#.NET
Using Barcode creator for VS .NET Control to generate, create bar code image in .NET applications.
016) / 00062
(EQ 1)
Of course, what we re really interested in is the true relative humidity without any dependence on the supply voltage or a xed temperature Equation 2 provides the means to compute the true relative humidity
RHtrue = RHsensor / (10546
000216*T)
(EQ 2)
Where T is measured in degrees celsius ( C) From these equations we can see that we need three measurements to compute a value for RHtrue: Vout, Vdd, and T Fortunately, the A-to-D converter can measure both Vad and Vdd Now we re armed with all of the information we need to write a small program to read the relative humidity using OneWireContainer26 Listing 410
import import import import import
HumiditySensor
comdalsemionewireOneWireAccessProvider; comdalsemionewireadapterDSPortAdapter; comdalsemionewireOneWireException; comdalsemionewirecontainerOneWireContainer; comdalsemionewirecontainerOneWireContainer26;
public class HumiditySensor { DSPortAdapter adapter; OneWireContainer26 owc; byte[] state; HumiditySensor(DSPortAdapter adapter) throws OneWireException { thisadapter = adapter; // Only find DS2438 family devices adaptertargetFamily(0x26); adaptersetSpeed(adapterSPEED_REGULAR); owc = (OneWireContainer26) adaptergetFirstDeviceContainer(); if (owc == null) { throw new OneWireException("No DS2438 A to D chip found"); } state = owcreadDevice(); } public double getTemperature() throws OneWireException { owcdoTemperatureConvert(state); state = owcreadDevice(); return owcgetTemperature(state); } public double getSensorRH() throws OneWireException {