HIH-5030 / 5031 Low voltage Humidity Sensor.

marks

Senior Member
Not so long ago Hemi345 introduced to the forum a Honeywell humidity sensor with good accuracy.
This looked good eventually got one to try its an smd package , I cheated and mounted it on a SOIC8 adapter board.
the sensor is sensitive to light so i'll mount this upsidedown on the mainboard.

The calculated ADC range is from 155 to 806 ( 0 to 100% RH)
the first few days the readings seem a couple of % lower probaly needed a burn in period lol!
the readings do fluctuate a little but I say this is probaly normal for this type of sensor.
Code:
;  Honeywell HIH-5030 / HIH-5031 analog humidity sensor 
;   VOUT = (VSUPPLY)(0.00636(SensorRH)+0.1515), typical at 25 °C
;    SensorRH = ADCvalueRH -(zero offset) /(slope)
#picaxe 18m2    'version 2.D AXE132  marks 
#terminal 4800
SYMBOL HIH5030      = C.1
 		   
SYMBOL ADCvalueRH   = W0  SYMBOL SensorRH   = W0    	   
SYMBOL D0           = b2
SYMBOL D1           = b3 
SYMBOL D2           = b4 
SYMBOL D3           = b5 
SYMBOL D4           = b6

Main:           
ConvertSensorRH: 
ReadADC10 HIH5030,ADCvalueRH 

pause 4000
		sertxd (CR, LF,"  ADCvalueRH = ",#ADCvalueRH)
		
		SensorRH = ADCvalueRH -155 *2**50366                    
	    ; SensorRH = ADCvalueRH -(0.1515*1023) /(0.00636*1023), typical at 25 °C	     
      	BinTOASCII ADCvalueRH,D4,D4,D3,D2,D1 
                 IF  D4 = "0" THEN : D4 = " "                   ' leading zero blanking 
                  IF D3 = "0" THEN : D3 = " " : ENDIF           ' leading zero blanking 
                 ENDIF                                                                     		     	     
            sertxd (CR,   "    SensorRH = ",D4,D3,D2,".",D1,"%")		
 GOTO Main
To reduce noise and level out the reading we will average out ten readings we can also cheat and use this to good effect
to increase the resolution.For temperature correction we will use our ds18b20 temperature sensor all values we will
send to the serial terminal to be viewed.
Code:
;  Honeywell HIH-5030 / HIH-5031 analog humidity sensor 
;  ADCvalueRH  = RH% * 0.00636 + 0.1515 * 1023
;          RH% = ADCvalueRH / 1023 - 0.1515 / 0.00636 
#picaxe 18m2    'version 2.D AXE132  marks 
#terminal 4800
SYMBOL DS18B20    = C.0
SYMBOL HIH5030    = C.1
 		   
SYMBOL ADCvalueRH   = W0  SYMBOL SensorRH = W0  SYMBOL TrueRH   = W0      	   
SYMBOL Temperature  = W0  SYMBOL TempMsb  = b1  SYMBOL TempLsb  = b0
SYMBOL T            = W1
SYMBOL Average      = W2
SYMBOL avr          = b6 
SYMBOL Sign         = b7
SYMBOL D0           = b8
SYMBOL D1           = b9 
SYMBOL D2           = b10 
SYMBOL D3           = b11 
SYMBOL D4           = b12

Main:
ConvertTemperature:
ReadTEMP12 DS18B20,T 
       Temperature = T                                    
       Sign = " "                                                    ' Display +   
     IF TempMsb > 127 THEN                       
       Sign = "-"                                                    ' Display - 
       Temperature = - Temperature                                    
     ENDIF 
            Temperature = Temperature *8**51200                      : GOSUB Blanking' Celsius(-55.00°C to 125.00°C)                                                              
            sertxd (CR, LF, "  Temperature ",Sign,D4,D3,D2,".",D1,D0,"°C")
            
       Temperature = T                                    
       Sign = " "                                                    ' Display +
       Temperature = Temperature +880 *16**46080 -6700                  
     IF TempMsb > 127 THEN                       
       Sign = "-"                                                    ' Display - 
       Temperature = - Temperature                                    
     ENDIF                                                           : GOSUB Blanking' Fahrenheit(-67.00°F to 257.00°F)       
            sertxd (CR, LF, "  Temperature ",Sign,D4,D3,D2,".",D1,D0,"°F")
            
ConvertSensorRH: 
Average = 0
FOR avr = 1 TO 10 
ReadADC10 HIH5030,ADCvalueRH  
Average = Average+ADCvalueRH 
PAUSE 400
NEXT avr
		sertxd (CR, LF,"  ADCvalueRH =  ",#ADCvalueRH)
		
		SensorRH = Average -1550 *2**50366                       : GOSUB Blanking
	    ; SensorRH = ADCvalueRH -(0.1515*1023) /(0.00636*1023), typical at 25 °C	     
            sertxd (CR, LF, "    SensorRH = ",D4,D3,D2,".",D1,D0,"%")
		
ConvertTrueRH:                 		
            T = T +880 *8**46208 +25526 : TrueRH = SensorRH *2**T    : GOSUB Blanking 
          ; TrueRH = (SensorRH)/(1.0546 - 0.00216T), T in °C	     
            sertxd (CR, LF, "      TrueRH = ",D4,D3,D2,".",D1,D0,"%", CR,LF, "------------------------")         
GOTO main 
           
Blanking:        BinTOASCII TrueRH,D4,D3,D2,D1,D0 
                  IF  D4 = "0" THEN : D4 = " "                       ' leading zero blanking 
                   IF D3 = "0" THEN : D3 = " " : ENDIF               ' leading zero blanking 
                  ENDIF                                              : RETURN
 

Attachments

Last edited:

marks

Senior Member
Finaly here's some code we can use to display temperature and trueRH on a OLED or LCD on the axe132 to one decimal place!
We have also increased our oversampling to 20 readings the displayed results are still quite responsive and seem quite accurate.
And the OLED from REvED seemed to work better at 3.3v ,less glare.
Code:
;  Honeywell HIH-5030 / HIH-5031 analog humidity sensor 
#picaxe 18m2    'version 2.D AXE132 8Bit marks   							
'     DB7            = B.7	
'     DB6            = B.6	
'     DB5            = B.5	
'     DB4            = B.4	
'     DB3            = B.3	
'     DB2            = B.2	
'     DB1            = B.1		
'     DB0            = B.0
      SYMBOL Rx      = C.5
     	SYMBOL E       = C.6			                  
      SYMBOL RS      = C.7
	SYMBOL HIH5030 = C.1
	SYMBOL DS18B20 = C.0				                  
 SYMBOL senddata     = pinsb
 SYMBOL index        = b0		   
 SYMBOL ADCvalueRH   = W1  SYMBOL SensorRH  = W1  SYMBOL TrueRH   = W1
 SYMBOL Temperature  = W1  SYMBOL TempMsb   = b3  SYMBOL TempLsb  = b2
 SYMBOL T            = W2  
 SYMBOL average      = W3
 SYMBOL avr          = b8
 SYMBOL Sign         = b9
 SYMBOL D0           = b10
 SYMBOL D1           = b11 
 SYMBOL D2           = b12 
 SYMBOL D3           = b13 
 SYMBOL D4           = b14

SETFREQ M32
 	dirsB = %11111111			
 	dirsC = %11001111
Initialise: 	
	FOR  index = 0 to 6                                               
          LOOKUP index, ($38,$38,$38,$0C,$01,$02,$06),senddata : PULSOUT E,1 ' Initialise LCD/OLED
          '(8bit/2line/5x8)*3(Display On/flashing Cursor)(Clear Display)(Return Home)(Entry Mode Set)	
 	NEXT index : PAUSE 10
Main:            
Average = 0
FOR avr = 1 to 20 
ReadADC10 HIH5030,ADCvalueRH 
Average = Average+ADCvalueRH
  
  IF avr = 6 or avr = 12 or avr = 18 then 
  ConvertTemperature:
  ReadTEMP12 DS18B20,T
       Temperature = T                                        
       Sign = " "                                                    ' Display +   
     IF TempMsb > 127 THEN                       
       Sign = "-"                                                    ' Display - 
       Temperature = - Temperature                                    
     ENDIF 
            Temperature = Temperature *8**51200+5                    ' Celsius(-55.0°C to 125.0°C)rounded up
                  BinTOASCII Temperature,D4,D3,D2,D1,D0 
                  IF  D4 = "0" THEN : D4 = " "                       ' leading zero blanking 
                   IF D3 = "0" THEN : D3 = " " : ENDIF               ' leading zero blanking 
                  ENDIF 
    DisplayTemperature:
           LOW  RS : senddata = 128 : PULSOUT E,1                    ' commandmode (128-147) Line 1 Cursor Position
           HIGH RS                                                   ' charactermode
           FOR  index = 0 TO 7
 	          LOOKUP index,(Sign,D4,D3,D2,".",D1,223,"C"),senddata 
 	                       PULSOUT E,1                             ' sending characters  
           NEXT index 
            
    ConvertTemperatureF:
        Temperature = T                                    
       Sign = " "                                                    ' Display +
       Temperature = Temperature +880 *16**46080 -6700               ' Fahrenheit(-67.0°F to 257.0°F)rounded up   
     IF TempMsb > 127 THEN                       
       Sign = "-"                                                    ' Display - 
       Temperature = - Temperature                                    
     ENDIF    
       Temperature =   Temperature +5                                                   
                  BinTOASCII Temperature,D4,D3,D2,D1,D0 
                  IF  D4 = "0" THEN : D4 = " "                       ' leading zero blanking 
                   IF D3 = "0" THEN : D3 = " " : ENDIF               ' leading zero blanking 
                  ENDIF 
    DisplayTemperatureF:
           HIGH RS                                                   ' charactermode
           FOR  index = 0 TO 7
 	          LOOKUP index,(Sign,D4,D3,D2,".",D1,223,"F"),senddata 
 	                       PULSOUT E,1                             ' sending characters  
           NEXT index                                                                                 
  ENDIF  
NEXT avr
 
ConvertTrueRH:
            SensorRH = Average -3100 **50366     		
            T = T +880 *8**46208 +25526 : TrueRH = SensorRH *2**T +5 ' Humidity(0.0%RH to 100.0%RH)rounded up  
                  BinTOASCII TrueRH,D4,D3,D2,D1,D0 
                  IF  D4 = "0" THEN : D4 = " "                       ' leading zero blanking 
                   IF D3 = "0" THEN : D3 = " " : ENDIF               ' leading zero blanking 
                  ENDIF                                
DisplayTrueRH:
           LOW  RS : senddata = 192 : PULSOUT E,1                    ' commandmode (192-211) Line 1 Cursor Position
           HIGH RS                                                   ' charactermode
           FOR  index = 0 TO 10
 	          LOOKUP index,(" RH ",D4,D3,D2,".",D1,32,"%"),senddata 
 	                       PULSOUT E,1                             ' sending characters  
           NEXT                 
GOTO main
 
Last edited:

marks

Senior Member
Hih-4000

There's still a few that use the HIH-4000 and the equation used is for many of Honeywell's humidity sensors
so I thought I would repost the above code with the necessary changes.
The sensor can be used from 4 to 5.5v but calibrated at 5v @ 25 degrees Celsius,
many don't show this but it should be used with a small load resistor (68k)
like shown on the HIH-5030 drawing above.
The calculated ADC10 range is from 163 to 797 ( 0 to 100% RH)
Code:
;  Honeywell HIH-4000 analog humidity sensor 
;   VOUT = (VSUPPLY)(0.0062(SensorRH)+0.16), typical at 25 °C
;    SensorRH = ADCvalueRH -(zero offset) /(slope)
#picaxe 18m2    'version 2.D AXE132  marks 
#terminal 4800
SYMBOL HIH4000      = C.1
 		   
SYMBOL ADCvalueRH   = W0  SYMBOL SensorRH   = W0    	   
SYMBOL D0           = b2
SYMBOL D1           = b3 
SYMBOL D2           = b4 
SYMBOL D3           = b5 
SYMBOL D4           = b6

Main:           
ConvertSensorRH: 
ReadADC10 HIH4000,ADCvalueRH 

pause 4000
		sertxd (CR, LF,"  ADCvalueRH = ",#ADCvalueRH)
		SensorRH = ADCvalueRH -163 *2**51685 'HIH-4000-001  ADC10value 163 to 797 (0.8v to 3.9v)supply 5v at 25°C                 	     
      	BinTOASCII ADCvalueRH,D4,D4,D3,D2,D1 
                 IF  D4 = "0" THEN : D4 = " "                   ' leading zero blanking 
                  IF D3 = "0" THEN : D3 = " " : ENDIF           ' leading zero blanking 
                 ENDIF                                                                     		     	     
            sertxd (CR,   "    SensorRH = ",D4,D3,D2,".",D1,"%")		
GOTO Main
Requires a DSb1820 to be able to calculate True RH
Code:
;  Honeywell HIH-4000 analog humidity sensor 
#picaxe 18m2    'version 2.D AXE132  marks 
#terminal 4800
SYMBOL DS18B20    = C.0
SYMBOL HIH4000    = C.1 		   
SYMBOL ADCvalueRH   = W0  SYMBOL SensorRH = W0  SYMBOL TrueRH   = W0      	   
SYMBOL Temperature  = W0  SYMBOL TempMsb  = b1  SYMBOL TempLsb  = b0
SYMBOL T            = W1
SYMBOL Average      = W2
SYMBOL avr          = b6 
SYMBOL Sign         = b7
SYMBOL D0           = b8
SYMBOL D1           = b9 
SYMBOL D2           = b10 
SYMBOL D3           = b11 
SYMBOL D4           = b12

Main:
ConvertTemperature:
ReadTEMP12 DS18B20,T 
       Temperature = T                                    
       Sign = " "                                                    ' Display +   
     IF TempMsb > 127 THEN                       
       Sign = "-"                                                    ' Display - 
       Temperature = - Temperature                                    
     ENDIF 
            Temperature = Temperature *8**51200                      : GOSUB Blanking' Celsius(-55.00°C to 125.00°C)                                                              
            sertxd (CR, LF, "  Temperature ",Sign,D4,D3,D2,".",D1,D0,"°C")
            
       Temperature = T                                    
       Sign = " "                                                    ' Display +
       Temperature = Temperature +880 *16**46080 -6700                  
     IF TempMsb > 127 THEN                       
       Sign = "-"                                                    ' Display - 
       Temperature = - Temperature                                    
     ENDIF                                                           : GOSUB Blanking' Fahrenheit(-67.00°F to 257.00°F)       
            sertxd (CR, LF, "  Temperature ",Sign,D4,D3,D2,".",D1,D0,"°F")
            
ConvertSensorRH: 
Average = 0
FOR avr = 1 TO 10 
ReadADC10 HIH4000,ADCvalueRH  
Average = Average+ADCvalueRH 

PAUSE 400
NEXT avr
		sertxd (CR, LF,"  ADCvalueRH =  ",#ADCvalueRH)
		
		SensorRH = Average -1630 *2**51685                       : GOSUB Blanking
	    ; SensorRH = ADCvalueRH -(0.1600*1023) /(0.0062*1023), typical at 25 °C	     
            sertxd (CR, LF, "    SensorRH = ",D4,D3,D2,".",D1,D0,"%")
		
ConvertTrueRH:                 		
            T = T +880 *8**46208 +25526 : TrueRH = SensorRH *2**T    : GOSUB Blanking 
          ; TrueRH = (SensorRH)/(1.0546 - 0.00216T), T in °C	     
            sertxd (CR, LF, "      TrueRH = ",D4,D3,D2,".",D1,D0,"%", CR,LF, "------------------------")         
GOTO main 
           
Blanking:        BinTOASCII TrueRH,D4,D3,D2,D1,D0 
                  IF  D4 = "0" THEN : D4 = " "                       ' leading zero blanking 
                   IF D3 = "0" THEN : D3 = " " : ENDIF               ' leading zero blanking 
                  ENDIF                                              : RETURN
 

Attachments

elektroenchen

New member
Guten Tag,
kann mir jemand erklaeren wie die Zahl 51685 im folgenden Code entsteht? Elektroenchen dankt es euch.

Good day,
Can anyone explain to me how the number 51685 appears in the following code? Elektroenchen thanks you 🤔

Code:
SensorRH = ADCvalueRH -163 *2**51685 'HIH-4000-001  ADC10value 163 to 797 (0.8v to 3.9v)supply 5v at 25°C
 

hippy

Ex-Staff (retired)
Can anyone explain to me how the number 51685 appears in the following code?
N ** 51685

The '**' makes that mathematically equivalent to -

N * 51685 / 65536

Where 51685 / 65536 is approximately -

N * 0.8

I would guess the conversion algorithm needs to do something like that but has to achieve it in a way a PICAXE allows, which means integer only maths while avoiding 16-bit overflow, hence -

N * 0.8 => N * 51685 / 65536 => N ** 51685
 
Top