Simple program using SHT15.
Code:
;
; read a Sensirion SHT15 for temperature, humidity, dewpoint
; display on an 8x2 LCD and forward using a RevEd ERF transceiver
;
#picaxe 20X2 ;no X2 specific characteristics used here
#no_data
; table of natural logs of 0 to 1, as in 1 to 99% humidity
; real logs are negative so signs are reversed in the dewpoint formula
table 00,(255,255,255,255,255,255,255,255,253,241) ;0-9% RH
table 10,(230,221,212,204,197,190,183,177,171,166)
table 20,(161,156,151,147,143,139,135,131,127,124) ; -1.61, -1.56, etc
table 30,(120,117,114,111,108,105,102,099,097,094)
table 40,(92,89,87,84,82,80,78,76,74,71)
table 50,(69,67,65,63,62,60,58,56,54,52)
table 60,(51,49,48,46,45,43,42,40,39,37)
table 70,(36,34,33,31,30,29,27,26,25,24)
table 80,(22,21,20,19,17,16,15,14,13,12)
table 90,(11,09,08,07,06,05,04,03,02,01) ;90-99% RH
;
; pin 1 - +V
; pin 2 - Serial In ISP
; pin 3 - C.7, 0V
; pin 4 - C.6, 0V
; pin 5 - C.5, 0V
; pin 6 - C.4, 0V
; pin 7 - C.3, 0V
; pin 8 - C.2, SHT15 data in/out
; pin 9 - C.1, SHT15 clock out
; pin10 - C.0, 0V
; pin11 - B.7, LCD12
; pin12 - B.6, LCD14
; pin13 - B.5, LCD13
; pin14 - B.4, LCD11
; pin15 - B.3, LCD RS
; pin16 - B.2, LCD E
; pin17 - B.1, SEROUT to ERF
; pin18 - B.0, SERIN from ERF
; pin19 - A.0, Serial Out ISP
; pin20 - 0V
;
symbol sdata = C.2 ; data out to SHT15
symbol sdatai = pinC.2 ; data in from SHT15
symbol sclk = C.1
symbol ERFin = B.0
symbol ERFout = B.1
symbol E = B.2 ; 1 = data, 0 = cmd
symbol RS = B.3
symbol LCD11 = pinB.4
symbol LCD13 = pinB.5
symbol LCD14 = pinB.6
symbol LCD12 = pinB.7
;
symbol MyStationID = 0x54 ; 52, 53, or 54
;
; 20X2 has RAM b0-b55, w0-w27
symbol null = b13 ;null/work
symbol temp10 = b16 ;w8 temperature in ascii: tens position
symbol temp01 = b17 ; temperature in ascii: ones position
symbol humd10 = b18 ;w9 humidity in ascii: tens position
symbol humd01 = b19 ; humidity in ascii: ones position
symbol dewp10 = b20 ;w10 dewpoint in ascii: tens position
symbol dewp01 = b21 ; dewpoint in ascii: ones position
symbol soT = w17 ;b34 b35
symbol tF = W18 ;b36 b37
symbol tC = W19 ;b38 b39
symbol soRH = W20 ;b40 b41
symbol rhlin = W22 ;b44 b45
symbol truRH = W23 ;b46 b47
symbol dpLn = W24 ;b48 b49
symbol dpmT = W25 ;b50 b51
symbol dewpt = W26 ;b52 b53
;
; 9 byte msg transmitted via ERF
; x'55' header
; x'nn' station id
; x'nnnn' two digit temperature in ascii
; x'nnnn' two digit relative humidity in ascii
; x'nnnn' two digit dewpoint in ascii
; x'AA' trailer
;
; INIT
;
setfreq m8
;
input sdata ;pulled up
output sclk
output ERFout
output RS
output E
output B.4
output B.5
output B.6
output B.7
;
gosub InitLCD ; initial setup
;
; MAIN
;
Main:
;
gosub ReadSHT ; acquire local temperature and humidity
gosub UpdateLCD ; display temperature, humidity, dewpoint on local LCD
serout ERFout,N9600_8,(0x55,0x54,temp10,temp01,humd10,humd01,dewp10,dewp01,0xAA) ;send data to display station
REM sertxd ("Temp:",temp10,temp01," Humid:",humd10,humd01," Dewpoint:",dewp10,dewp01," ",13,10)
wait 4 ; appx 1 minute between samples
wait 4
wait 4
wait 4
wait 4
wait 4
wait 4 ; split into 4 second commands to aid reprogramming without a hard reset
wait 4
wait 4
wait 4
wait 4
wait 4
wait 4
wait 4
wait 4
goto Main
Last edited: