diff --git a/Firmware/SHT15-Testing-v11/SHT15-Testing-v11.asm b/Firmware/SHT15-Testing-v11/SHT15-Testing-v11.asm deleted file mode 100644 index dc752f8..0000000 --- a/Firmware/SHT15-Testing-v11/SHT15-Testing-v11.asm +++ /dev/null @@ -1,1000 +0,0 @@ - -; CC5X Version 3.1I, Copyright (c) B Knudsen Data -; C compiler for the PICmicro family -; ************ 28. Sep 2007 16:21 ************* - - processor 16F88 - radix DEC - -INDF EQU 0x00 -PCL EQU 0x02 -FSR EQU 0x04 -PORTA EQU 0x05 -TRISA EQU 0x85 -PORTB EQU 0x06 -TRISB EQU 0x86 -PCLATH EQU 0x0A -Carry EQU 0 -Zero_ EQU 2 -RP0 EQU 5 -RP1 EQU 6 -IRP EQU 7 -RCSTA EQU 0x18 -TXREG EQU 0x19 -RCREG EQU 0x1A -TXSTA EQU 0x98 -SPBRG EQU 0x99 -ANSEL EQU 0x9B -EEDATA EQU 0x10C -EEADR EQU 0x10D -EEDATH EQU 0x10E -EEADRH EQU 0x10F -TXIF EQU 4 -RCIF EQU 5 -RD EQU 0 -EEPGD EQU 7 -response EQU 0x21 -sht15_command EQU 0x24 -i EQU 0x25 -C1cnt EQU 0x26 -C2tmp EQU 0x27 -j EQU 0x24 -in_byte EQU 0x25 -x EQU 0x26 -y EQU 0x28 -z EQU 0x29 -nate EQU 0x36 -counter EQU 0x7F -x_2 EQU 0x36 -nate_2 EQU 0x26 -my_byte EQU 0x27 -i_2 EQU 0x29 -k EQU 0x2A -m EQU 0x2B -temp EQU 0x2C -high_byte EQU 0x2D -low_byte EQU 0x2E -C3cnt EQU 0x36 -C4tmp EQU 0x37 -C5cnt EQU 0x36 -C6tmp EQU 0x37 -C7cnt EQU 0x36 -C8tmp EQU 0x37 -C9rem EQU 0x39 -ci EQU 0x36 - - GOTO main - - ; FILE C:\Global\Code\16F88\SHT15-Testing\SHT15-Testing-v11.c - ;/* - ; 2-1-07 - ; Nathan Seidle - ; nathan at sparkfun.com - ; Copyright Spark Fun Electronics© 2007 - ; - ; Pseudo Sensirion I2C interface example code - ; - ; Uses 16F88 with bootloader for testing - ; - ; Reports the Humidity and Temperature in obfuscated form. - ; Please see Sensirion datasheet for translation equations - ; - ; 9-28-07 Correction by Iván Sarmiento. There was a small bug in the 16bit read. - ;*/ - ; - ;#define Clock_8MHz - ;#define Baud_9600 - ; - ;#include "c:\Global\Code\C\16F88.h" // device dependent interrupt definitions - ; - ;#pragma origin 4 - ORG 0x0004 - ; - ;#define STATUS_LED PORTB.3 - ; - ;#define WRITE_sda() TRISB = TRISB & 0b.1011.1111 //SDA must be output when writing - ;#define READ_sda() TRISB = TRISB | 0b.0100.0000 //SDA must be input when reading - don't forget the resistor on SDA!! - ; - ;#define SCK PORTB.7 - ;#define SDA PORTB.6 - ; - ;#define CHECK_TEMP 0b.0000.0011 - ;#define CHECK_HUMD 0b.0000.0101 - ;#define CHECK_STAT 0b.0000.0111 - ;#define WRITE_STAT 0b.0000.0110 - ; - ;void boot_up(void); - ; - ;void sht15_start(void); - ;void sht15_read(void); - ;void sht15_send_byte(uns8 sht15_command); - ;uns16 sht15_read_byte16(void); - ; - ;void delay_ms(uns16); - ;void printf(const char *nate, int16 my_byte); - ; - ;void main(void) - ;{ -_const1 - MOVWF ci - MOVLW .0 - BSF 0x03,RP1 - MOVWF EEADRH - BCF 0x03,RP1 - RRF ci,W - ANDLW .127 - ADDLW .35 - BSF 0x03,RP1 - MOVWF EEADR - BTFSC 0x03,Carry - INCF EEADRH,1 - BSF 0x03,RP0 - BSF 0x18C,EEPGD - BSF 0x18C,RD - NOP - NOP - BCF 0x03,RP0 - BCF 0x03,RP1 - BTFSC ci,0 - GOTO m001 - BSF 0x03,RP1 - MOVF EEDATA,W - ANDLW .127 - BCF 0x03,RP1 - RETURN -m001 BSF 0x03,RP1 - RLF EEDATA,W - RLF EEDATH,W - BCF 0x03,RP1 - RETURN - DW 0x298A - DW 0x2A48 - DW 0x1AB1 - DW 0x2A20 - DW 0x39E5 - DW 0x34F4 - DW 0x33EE - DW 0x500 - DW 0x37C4 - DW 0x32EE - DW 0x500 - DW 0x3AC8 - DW 0x34ED - DW 0x34E4 - DW 0x3CF4 - DW 0x34A0 - DW 0x1073 - DW 0x3225 - DW 0x500 - DW 0x32D4 - DW 0x386D - DW 0x3965 - DW 0x3A61 - DW 0x3975 - DW 0x1065 - DW 0x39E9 - DW 0x12A0 - DW 0x64 - DW 0x290A - DW 0x39E5 - DW 0x37F0 - DW 0x39EE - DW 0x1065 - DW 0x34F4 - DW 0x32ED - DW 0x1EA0 - DW 0x12A0 - DW 0x36E4 - DW 0x73 -main - ; uns8 choice; - ; - ; boot_up(); - BSF 0x03,RP0 - BCF 0x03,RP1 - CALL boot_up - ; - ; delay_ms(100); - MOVLW .100 - MOVWF x - CLRF x+1 - CALL delay_ms - ; - ; printf("\nSHT15 Testing", 0); - CLRF nate_2 - CLRF my_byte - CLRF my_byte+1 - CALL printf - ; - ; sht15_read(); - CALL sht15_read - ; - ; printf("\nDone", 0); - MOVLW .15 - MOVWF nate_2 - CLRF my_byte - CLRF my_byte+1 - CALL printf - ; - ; while(1); -m002 GOTO m002 - ; - ;}//End Main - ; - ;void boot_up(void) - ;{ -boot_up - ; //OSCCON = 0b.0111.0000; //Setup internal oscillator for 8MHz - ; //while(OSCCON.2 == 0); //Wait for frequency to stabilize - ; - ; //Setup Ports - ; ANSEL = 0b.0000.0000; //Turn off A/D - CLRF ANSEL - ; - ; PORTA = 0b.0000.0000; - BCF 0x03,RP0 - CLRF PORTA - ; TRISA = 0b.0000.0000; - BSF 0x03,RP0 - CLRF TRISA - ; - ; PORTB = 0b.0000.0000; - BCF 0x03,RP0 - CLRF PORTB - ; TRISB = 0b.0000.0100; //0 = Output, 1 = Input RX on RB2 - MOVLW .4 - BSF 0x03,RP0 - MOVWF TRISB - ; - ; //Setup the hardware UART module - ; //============================================================= - ; SPBRG = 51; //8MHz for 9600 inital communication baud rate - MOVLW .51 - MOVWF SPBRG - ; //SPBRG = 129; //20MHz for 9600 inital communication baud rate - ; - ; TXSTA = 0b.0010.0100; //8-bit asych mode, high speed uart enabled - MOVLW .36 - MOVWF TXSTA - ; RCSTA = 0b.1001.0000; //Serial port enable, 8-bit asych continous receive mode - MOVLW .144 - BCF 0x03,RP0 - MOVWF RCSTA - ; //============================================================= - ; - ;} - RETURN - ; - ;//Init the sensor and read out the humidity and temperature data - ;void sht15_read(void) - ;{ -sht15_read - ; uns24 response; - ; - ; //Issue command start - ; sht15_start(); - CALL sht15_start - ; - ; //Now send command code - ; sht15_send_byte(CHECK_HUMD); - MOVLW .5 - CALL sht15_send_byte - ; response = sht15_read_byte16(); - CALL sht15_read_byte16 - MOVWF response - MOVF in_byte+1,W - MOVWF response+1 - CLRF response+2 - ; printf("\nHumidity is %d", response); - MOVLW .21 - MOVWF nate_2 - MOVF response,W - MOVWF my_byte - MOVF response+1,W - MOVWF my_byte+1 - CALL printf - ; - ; sht15_start(); - CALL sht15_start - ; sht15_send_byte(CHECK_TEMP); - MOVLW .3 - CALL sht15_send_byte - ; response = sht15_read_byte16(); //Listen for response from SHT15 - CALL sht15_read_byte16 - MOVWF response - MOVF in_byte+1,W - MOVWF response+1 - CLRF response+2 - ; printf("\nTemperature is %d", response); - MOVLW .37 - MOVWF nate_2 - MOVF response,W - MOVWF my_byte - MOVF response+1,W - MOVWF my_byte+1 - GOTO printf - ; - ;} - ; - ;void sht15_send_byte(uns8 sht15_command) - ;{ -sht15_send_byte - MOVWF sht15_command - ; uns8 i; - ; - ; WRITE_sda(); - BSF 0x03,RP0 - BCF TRISB,6 - ; - ; for(i = 0 ; i < 8 ; i++) - BCF 0x03,RP0 - CLRF i -m003 MOVLW .8 - SUBWF i,W - BTFSC 0x03,Carry - GOTO m004 - ; { - ; sht15_command = rl(sht15_command); - RLF sht15_command,1 - ; SCK = 0; - BCF PORTB,7 - ; SDA = Carry; - BTFSS 0x03,Carry - BCF PORTB,6 - BTFSC 0x03,Carry - BSF PORTB,6 - ; SCK = 1; - BSF PORTB,7 - ; } - INCF i,1 - GOTO m003 - ; - ; //Wait for SHT15 to acknowledge. - ; SCK = 0; -m004 BCF PORTB,7 - ; READ_sda(); - BSF 0x03,RP0 - BSF TRISB,6 - ; while (SDA == 1); //Wait for SHT to pull line low - BCF 0x03,RP0 -m005 BTFSC PORTB,6 - GOTO m005 - ; SCK = 1; - BSF PORTB,7 - ; SCK = 0; //Falling edge of 9th clock - BCF PORTB,7 - ; - ; while (SDA == 0); //Wait for SHT to release line -m006 BTFSS PORTB,6 - GOTO m006 - ; - ; //Wait for SHT15 to pull SDA low to signal measurement completion. - ; //This can take up to 210ms for 14 bit measurements - ; i = 0; - CLRF i - ; while (SDA == 1) //Wait for SHT to pull line low -m007 BTFSS PORTB,6 - GOTO m008 - ; { - ; i++; - INCF i,1 - ; if (i == 255) break; - INCF i,W - BTFSC 0x03,Zero_ - GOTO m008 - ; - ; delay_ms(10); - MOVLW .10 - MOVWF x - CLRF x+1 - CALL delay_ms - ; } - GOTO m007 - ; - ; //Debug info - ; i *= 10; //Convert to ms -m008 BCF 0x03,Carry - RLF i,W - MOVWF C2tmp - CLRF i - MOVLW .5 - MOVWF C1cnt -m009 MOVF C2tmp,W - ADDWF i,1 - DECFSZ C1cnt,1 - GOTO m009 - ; printf("\nResponse time = %dms", i); //Debug to see how long response took - MOVLW .56 - MOVWF nate_2 - MOVF i,W - MOVWF my_byte - CLRF my_byte+1 - GOTO printf - ; - ;} - ; - ;//Specific SHT start command - ;void sht15_start(void) - ;{ -sht15_start - ; WRITE_sda(); - BSF 0x03,RP0 - BCF TRISB,6 - ; SDA = 1; - BCF 0x03,RP0 - BSF PORTB,6 - ; SCK = 1; - BSF PORTB,7 - ; - ; SDA = 0; - BCF PORTB,6 - ; SCK = 0; - BCF PORTB,7 - ; SCK = 1; - BSF PORTB,7 - ; SDA = 1; - BSF PORTB,6 - ; SCK = 0; - BCF PORTB,7 - ;} - RETURN - ; - ;//Read 16 bits from the SHT sensor - ;uns16 sht15_read_byte16(void) - ;{ -sht15_read_byte16 - ; uns8 j; - ; uns16 in_byte; - ; - ; SCK = 0; - BCF PORTB,7 - ; - ; READ_sda(); - BSF 0x03,RP0 - BSF TRISB,6 - ; - ; /********** CHANGE *************/ - ; for(j = 0 ; j < 17 ; j++) - BCF 0x03,RP0 - CLRF j -m010 MOVLW .17 - SUBWF j,W - BTFSC 0x03,Carry - GOTO m013 - ; { - ; if(j!=8) - MOVF j,W - XORLW .8 - BTFSC 0x03,Zero_ - GOTO m011 - ; { - ; nop();nop();nop();nop(); - NOP - NOP - NOP - NOP - ; SCK = 1; - BSF PORTB,7 - ; in_byte = rl(in_byte); - RLF in_byte,1 - RLF in_byte+1,1 - ; in_byte.0 = SDA; - BCF in_byte,0 - BTFSC PORTB,6 - BSF in_byte,0 - ; SCK = 0; - BCF PORTB,7 - ; } - ; else - GOTO m012 - ; { - ; WRITE_sda(); -m011 BSF 0x03,RP0 - BCF TRISB,6 - ; SDA = 0; - BCF 0x03,RP0 - BCF PORTB,6 - ; nop(); - NOP - ; SCK = 1; //clk #9 for acknowledge - BSF PORTB,7 - ; nop();nop();nop(); - NOP - NOP - NOP - ; SCK = 0; - BCF PORTB,7 - ; READ_sda(); - BSF 0x03,RP0 - BSF TRISB,6 - ; } - ; } - BCF 0x03,RP0 -m012 INCF j,1 - GOTO m010 - ; /******** END CHANGE ***********/ - ; - ; return(in_byte); -m013 MOVF in_byte,W - RETURN - ;} - ; - ;//Low-level system routines - ; - ;//General short delay - ;void delay_ms(uns16 x) - ;{ -delay_ms - ; //Clocks out at 1006us per 1ms - ; uns8 y, z; - ; for ( ; x > 0 ; x--) -m014 MOVF x,W - IORWF x+1,W - BTFSC 0x03,Zero_ - GOTO m019 - ; for ( y = 0 ; y < 4 ; y++) - CLRF y -m015 MOVLW .4 - SUBWF y,W - BTFSC 0x03,Carry - GOTO m018 - ; for ( z = 0 ; z < 69 ; z++); - CLRF z -m016 MOVLW .69 - SUBWF z,W - BTFSC 0x03,Carry - GOTO m017 - INCF z,1 - GOTO m016 -m017 INCF y,1 - GOTO m015 -m018 DECF x,1 - INCF x,W - BTFSC 0x03,Zero_ - DECF x+1,1 - GOTO m014 - ;} -m019 RETURN - ; - ;//Sends nate to the Transmit Register - ;void putc(uns8 nate) - ;{ -putc - MOVWF nate - ; while(TXIF == 0); -m020 BTFSS 0x0C,TXIF - GOTO m020 - ; TXREG = nate; - MOVF nate,W - MOVWF TXREG - ;} - RETURN - ; - ;uns8 getc(void) - ;{ -getc - ; while(RCIF == 0); - BCF 0x03,RP0 - BCF 0x03,RP1 -m021 BTFSS 0x0C,RCIF - GOTO m021 - ; return (RCREG); - MOVF RCREG,W - RETURN - ;} - ; - ;uns8 scanc(void) - ;{ -scanc - ; uns16 counter = 0; - CLRF counter - CLRF counter+1 - ; - ; //CREN = 0; - ; //CREN = 1; - ; - ; RCIF = 0; - BCF 0x03,RP0 - BCF 0x03,RP1 - BCF 0x0C,RCIF - ; while(RCIF == 0) -m022 BTFSC 0x0C,RCIF - GOTO m023 - ; { - ; counter++; - INCF counter,1 - BTFSC 0x03,Zero_ - INCF counter+1,1 - ; if(counter == 1000) return 0; - MOVF counter,W - XORLW .232 - BTFSS 0x03,Zero_ - GOTO m022 - MOVF counter+1,W - XORLW .3 - BTFSS 0x03,Zero_ - GOTO m022 - RETLW .0 - ; } - ; - ; return (RCREG); -m023 MOVF RCREG,W - RETURN - ;} - ; - ;//Returns ASCII Decimal and Hex values - ;uns8 bin2Hex(char x) - ;{ -bin2Hex - MOVWF x_2 - ; skip(x); - MOVLW .1 - MOVWF PCLATH - MOVF x_2,W - ADDWF PCL,1 - ; #pragma return[16] = "0123456789ABCDEF" - RETLW .48 - RETLW .49 - RETLW .50 - RETLW .51 - RETLW .52 - RETLW .53 - RETLW .54 - RETLW .55 - RETLW .56 - RETLW .57 - RETLW .65 - RETLW .66 - RETLW .67 - RETLW .68 - RETLW .69 - RETLW .70 - ;} - ; - ;//Prints a string including variables - ;void printf(const char *nate, int16 my_byte) - ;{ -printf - ; - ; uns8 i, k, m, temp; - ; uns8 high_byte = 0, low_byte = 0; - CLRF high_byte - CLRF low_byte - ; uns8 y, z; - ; - ; uns8 decimal_output[5]; - ; - ; for(i = 0 ; ; i++) - CLRF i_2 - ; { - ; //delay_ms(3); - ; - ; k = nate[i]; -m024 MOVF i_2,W - ADDWF nate_2,W - CALL _const1 - MOVWF k - ; - ; if (k == '\0') - MOVF k,1 - BTFSC 0x03,Zero_ - ; break; - GOTO m050 - ; - ; else if (k == '%') //Print var - XORLW .37 - BTFSS 0x03,Zero_ - GOTO m048 - ; { - ; i++; - INCF i_2,1 - ; k = nate[i]; - MOVF i_2,W - ADDWF nate_2,W - CALL _const1 - MOVWF k - ; - ; if (k == '\0') - MOVF k,1 - BTFSC 0x03,Zero_ - ; break; - GOTO m050 - ; else if (k == '\\') //Print special characters - XORLW .92 - BTFSS 0x03,Zero_ - GOTO m025 - ; { - ; i++; - INCF i_2,1 - ; k = nate[i]; - MOVF i_2,W - ADDWF nate_2,W - CALL _const1 - MOVWF k - ; - ; putc(k); - CALL putc - ; - ; - ; } //End Special Characters - ; else if (k == 'b') //Print Binary - GOTO m049 -m025 MOVF k,W - XORLW .98 - BTFSS 0x03,Zero_ - GOTO m030 - ; { - ; for( m = 0 ; m < 8 ; m++ ) - CLRF m -m026 MOVLW .8 - SUBWF m,W - BTFSC 0x03,Carry - GOTO m049 - ; { - ; if (my_byte.7 == 1) putc('1'); - BTFSS my_byte,7 - GOTO m027 - MOVLW .49 - CALL putc - ; if (my_byte.7 == 0) putc('0'); -m027 BTFSC my_byte,7 - GOTO m028 - MOVLW .48 - CALL putc - ; if (m == 3) putc(' '); -m028 MOVF m,W - XORLW .3 - BTFSS 0x03,Zero_ - GOTO m029 - MOVLW .32 - CALL putc - ; - ; my_byte = my_byte << 1; -m029 BCF 0x03,Carry - RLF my_byte,1 - RLF my_byte+1,1 - ; } - INCF m,1 - GOTO m026 - ; } //End Binary - ; else if (k == 'd') //Print Decimal -m030 MOVF k,W - XORLW .100 - BTFSS 0x03,Zero_ - GOTO m044 - ; { - ; //Print negative sign and take 2's compliment - ; - ; if(my_byte < 0) - BTFSS my_byte+1,7 - GOTO m033 - ; { - ; putc('-'); - MOVLW .45 - CALL putc - ; my_byte *= -1; - MOVF my_byte,W - MOVWF C4tmp - MOVF my_byte+1,W - MOVWF C4tmp+1 - MOVLW .16 - MOVWF C3cnt -m031 BCF 0x03,Carry - RLF my_byte,1 - RLF my_byte+1,1 - RLF C4tmp,1 - RLF C4tmp+1,1 - BTFSS 0x03,Carry - GOTO m032 - DECF my_byte+1,1 - DECF my_byte,1 - INCFSZ my_byte,W - INCF my_byte+1,1 -m032 DECFSZ C3cnt,1 - GOTO m031 - ; } - ; - ; - ; if (my_byte == 0) -m033 MOVF my_byte,W - IORWF my_byte+1,W - BTFSS 0x03,Zero_ - GOTO m034 - ; putc('0'); - MOVLW .48 - CALL putc - ; else - GOTO m049 - ; { - ; //Divide number by a series of 10s - ; for(m = 4 ; my_byte > 0 ; m--) -m034 MOVLW .4 - MOVWF m -m035 BTFSC my_byte+1,7 - GOTO m042 - MOVF my_byte,W - IORWF my_byte+1,W - BTFSC 0x03,Zero_ - GOTO m042 - ; { - ; temp = my_byte % (uns16)10; - MOVF my_byte,W - MOVWF C6tmp - MOVF my_byte+1,W - MOVWF C6tmp+1 - CLRF temp - MOVLW .16 - MOVWF C5cnt -m036 RLF C6tmp,1 - RLF C6tmp+1,1 - RLF temp,1 - BTFSC 0x03,Carry - GOTO m037 - MOVLW .10 - SUBWF temp,W - BTFSS 0x03,Carry - GOTO m038 -m037 MOVLW .10 - SUBWF temp,1 -m038 DECFSZ C5cnt,1 - GOTO m036 - ; decimal_output[m] = temp; - MOVLW .49 - ADDWF m,W - MOVWF FSR - BCF 0x03,IRP - MOVF temp,W - MOVWF INDF - ; my_byte = my_byte / (uns16)10; - MOVF my_byte,W - MOVWF C8tmp - MOVF my_byte+1,W - MOVWF C8tmp+1 - CLRF C9rem - MOVLW .16 - MOVWF C7cnt -m039 RLF C8tmp,1 - RLF C8tmp+1,1 - RLF C9rem,1 - BTFSC 0x03,Carry - GOTO m040 - MOVLW .10 - SUBWF C9rem,W - BTFSS 0x03,Carry - GOTO m041 -m040 MOVLW .10 - SUBWF C9rem,1 - BSF 0x03,Carry -m041 RLF my_byte,1 - RLF my_byte+1,1 - DECFSZ C7cnt,1 - GOTO m039 - ; } - DECF m,1 - GOTO m035 - ; - ; for(m++ ; m < 5 ; m++) -m042 INCF m,1 -m043 MOVLW .5 - SUBWF m,W - BTFSC 0x03,Carry - GOTO m049 - ; putc(bin2Hex(decimal_output[m])); - MOVLW .49 - ADDWF m,W - MOVWF FSR - BCF 0x03,IRP - MOVF INDF,W - CALL bin2Hex - CALL putc - INCF m,1 - GOTO m043 - ; } - ; - ; } //End Decimal - ; else if (k == 'h') //Print Hex -m044 MOVF k,W - XORLW .104 - BTFSS 0x03,Zero_ - GOTO m046 - ; { - ; //New trick 3-15-04 - ; putc('0'); - MOVLW .48 - CALL putc - ; putc('x'); - MOVLW .120 - CALL putc - ; - ; if(my_byte > 0x00FF) - BTFSC my_byte+1,7 - GOTO m045 - MOVF my_byte+1,1 - BTFSC 0x03,Zero_ - GOTO m045 - ; { - ; putc(bin2Hex(my_byte.high8 >> 4)); - SWAPF my_byte+1,W - ANDLW .15 - CALL bin2Hex - CALL putc - ; putc(bin2Hex(my_byte.high8 & 0b.0000.1111)); - MOVLW .15 - ANDWF my_byte+1,W - CALL bin2Hex - CALL putc - ; } - ; - ; putc(bin2Hex(my_byte.low8 >> 4)); -m045 SWAPF my_byte,W - ANDLW .15 - CALL bin2Hex - CALL putc - ; putc(bin2Hex(my_byte.low8 & 0b.0000.1111)); - MOVLW .15 - ANDWF my_byte,W - CALL bin2Hex - CALL putc - ; } //End Hex - ; else if (k == 'f') //Print Float - GOTO m049 -m046 MOVF k,W - XORLW .102 - BTFSS 0x03,Zero_ - GOTO m047 - ; { - ; putc('!'); - MOVLW .33 - CALL putc - ; } //End Float - ; else if (k == 'u') //Print Direct Character - GOTO m049 -m047 MOVF k,W - XORLW .117 - BTFSS 0x03,Zero_ - GOTO m049 - ; { - ; //All ascii characters below 20 are special and screwy characters - ; //if(my_byte > 20) - ; putc(my_byte); - MOVF my_byte,W - CALL putc - ; } //End Direct - ; - ; } //End Special Chars - ; - ; else - GOTO m049 - ; putc(k); -m048 MOVF k,W - CALL putc - ; } -m049 INCF i_2,1 - GOTO m024 - ;} -m050 RETURN - - END - - -; *** KEY INFO *** - -; 0x0083 P0 18 word(s) 0 % : boot_up -; 0x00EB P0 11 word(s) 0 % : sht15_start -; 0x0095 P0 30 word(s) 1 % : sht15_read -; 0x00B3 P0 56 word(s) 2 % : sht15_send_byte -; 0x00F6 P0 42 word(s) 2 % : sht15_read_byte16 -; 0x0120 P0 24 word(s) 1 % : delay_ms -; 0x016E P0 215 word(s) 10 % : printf -; 0x0071 P0 18 word(s) 0 % : main -; 0x0138 P0 6 word(s) 0 % : putc -; 0x013E P0 6 word(s) 0 % : getc -; 0x0144 P0 21 word(s) 1 % : scanc -; 0x0159 P0 21 word(s) 1 % : bin2Hex -; 0x0004 P0 70 word(s) 3 % : _const1 - -; RAM usage: 27 bytes (27 local), 341 bytes free -; Maximum call level: 3 -; Codepage 0 has 578 word(s) : 28 % -; Codepage 1 has 0 word(s) : 0 % -; Total of 539 code words (13 %) diff --git a/Firmware/SHT15-Testing-v11/SHT15-Testing-v11.c b/Firmware/SHT15-Testing-v11/SHT15-Testing-v11.c deleted file mode 100644 index d38a334..0000000 --- a/Firmware/SHT15-Testing-v11/SHT15-Testing-v11.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - 2-1-07 - Nathan Seidle - nathan at sparkfun.com - Copyright Spark Fun Electronics© 2007 - - Pseudo Sensirion I2C interface example code - - Uses 16F88 with bootloader for testing - - Reports the Humidity and Temperature in obfuscated form. - Please see Sensirion datasheet for translation equations - - 9-28-07 Correction by Iván Sarmiento. There was a small bug in the 16bit read. -*/ - -#define Clock_8MHz -#define Baud_9600 - -#include "c:\Global\Code\C\16F88.h" // device dependent interrupt definitions - -#pragma origin 4 - -#define STATUS_LED PORTB.3 - -#define WRITE_sda() TRISB = TRISB & 0b.1011.1111 //SDA must be output when writing -#define READ_sda() TRISB = TRISB | 0b.0100.0000 //SDA must be input when reading - don't forget the resistor on SDA!! - -#define SCK PORTB.7 -#define SDA PORTB.6 - -#define CHECK_TEMP 0b.0000.0011 -#define CHECK_HUMD 0b.0000.0101 -#define CHECK_STAT 0b.0000.0111 -#define WRITE_STAT 0b.0000.0110 - -void boot_up(void); - -void sht15_start(void); -void sht15_read(void); -void sht15_send_byte(uns8 sht15_command); -uns16 sht15_read_byte16(void); - -void delay_ms(uns16); -void printf(const char *nate, int16 my_byte); - -void main(void) -{ - uns8 choice; - - boot_up(); - - delay_ms(100); - - printf("\nSHT15 Testing", 0); - - sht15_read(); - - printf("\nDone", 0); - - while(1); - -}//End Main - -void boot_up(void) -{ - //OSCCON = 0b.0111.0000; //Setup internal oscillator for 8MHz - //while(OSCCON.2 == 0); //Wait for frequency to stabilize - - //Setup Ports - ANSEL = 0b.0000.0000; //Turn off A/D - - PORTA = 0b.0000.0000; - TRISA = 0b.0000.0000; - - PORTB = 0b.0000.0000; - TRISB = 0b.0000.0100; //0 = Output, 1 = Input RX on RB2 - - //Setup the hardware UART module - //============================================================= - SPBRG = 51; //8MHz for 9600 inital communication baud rate - //SPBRG = 129; //20MHz for 9600 inital communication baud rate - - TXSTA = 0b.0010.0100; //8-bit asych mode, high speed uart enabled - RCSTA = 0b.1001.0000; //Serial port enable, 8-bit asych continous receive mode - //============================================================= - -} - -//Init the sensor and read out the humidity and temperature data -void sht15_read(void) -{ - uns24 response; - - //Issue command start - sht15_start(); - - //Now send command code - sht15_send_byte(CHECK_HUMD); - response = sht15_read_byte16(); - printf("\nHumidity is %d", response); - - sht15_start(); - sht15_send_byte(CHECK_TEMP); - response = sht15_read_byte16(); //Listen for response from SHT15 - printf("\nTemperature is %d", response); - -} - -void sht15_send_byte(uns8 sht15_command) -{ - uns8 i; - - WRITE_sda(); - - for(i = 0 ; i < 8 ; i++) - { - sht15_command = rl(sht15_command); - SCK = 0; - SDA = Carry; - SCK = 1; - } - - //Wait for SHT15 to acknowledge. - SCK = 0; - READ_sda(); - while (SDA == 1); //Wait for SHT to pull line low - SCK = 1; - SCK = 0; //Falling edge of 9th clock - - while (SDA == 0); //Wait for SHT to release line - - //Wait for SHT15 to pull SDA low to signal measurement completion. - //This can take up to 210ms for 14 bit measurements - i = 0; - while (SDA == 1) //Wait for SHT to pull line low - { - i++; - if (i == 255) break; - - delay_ms(10); - } - - //Debug info - i *= 10; //Convert to ms - printf("\nResponse time = %dms", i); //Debug to see how long response took - -} - -//Specific SHT start command -void sht15_start(void) -{ - WRITE_sda(); - SDA = 1; - SCK = 1; - - SDA = 0; - SCK = 0; - SCK = 1; - SDA = 1; - SCK = 0; -} - -//Read 16 bits from the SHT sensor -uns16 sht15_read_byte16(void) -{ - uns8 j; - uns16 in_byte; - - SCK = 0; - - READ_sda(); - - /********** CHANGE *************/ - for(j = 0 ; j < 17 ; j++) - { - if(j!=8) - { - nop();nop();nop();nop(); - SCK = 1; - in_byte = rl(in_byte); - in_byte.0 = SDA; - SCK = 0; - } - else - { - WRITE_sda(); - SDA = 0; - nop(); - SCK = 1; //clk #9 for acknowledge - nop();nop();nop(); - SCK = 0; - READ_sda(); - } - } - /******** END CHANGE ***********/ - - return(in_byte); -} - -//Low-level system routines - -//General short delay -void delay_ms(uns16 x) -{ - //Clocks out at 1006us per 1ms - uns8 y, z; - for ( ; x > 0 ; x--) - for ( y = 0 ; y < 4 ; y++) - for ( z = 0 ; z < 69 ; z++); -} - -//Sends nate to the Transmit Register -void putc(uns8 nate) -{ - while(TXIF == 0); - TXREG = nate; -} - -uns8 getc(void) -{ - while(RCIF == 0); - return (RCREG); -} - -uns8 scanc(void) -{ - uns16 counter = 0; - - //CREN = 0; - //CREN = 1; - - RCIF = 0; - while(RCIF == 0) - { - counter++; - if(counter == 1000) return 0; - } - - return (RCREG); -} - -//Returns ASCII Decimal and Hex values -uns8 bin2Hex(char x) -{ - skip(x); - #pragma return[16] = "0123456789ABCDEF" -} - -//Prints a string including variables -void printf(const char *nate, int16 my_byte) -{ - - uns8 i, k, m, temp; - uns8 high_byte = 0, low_byte = 0; - uns8 y, z; - - uns8 decimal_output[5]; - - for(i = 0 ; ; i++) - { - //delay_ms(3); - - k = nate[i]; - - if (k == '\0') - break; - - else if (k == '%') //Print var - { - i++; - k = nate[i]; - - if (k == '\0') - break; - else if (k == '\\') //Print special characters - { - i++; - k = nate[i]; - - putc(k); - - - } //End Special Characters - else if (k == 'b') //Print Binary - { - for( m = 0 ; m < 8 ; m++ ) - { - if (my_byte.7 == 1) putc('1'); - if (my_byte.7 == 0) putc('0'); - if (m == 3) putc(' '); - - my_byte = my_byte << 1; - } - } //End Binary - else if (k == 'd') //Print Decimal - { - //Print negative sign and take 2's compliment - - if(my_byte < 0) - { - putc('-'); - my_byte *= -1; - } - - - if (my_byte == 0) - putc('0'); - else - { - //Divide number by a series of 10s - for(m = 4 ; my_byte > 0 ; m--) - { - temp = my_byte % (uns16)10; - decimal_output[m] = temp; - my_byte = my_byte / (uns16)10; - } - - for(m++ ; m < 5 ; m++) - putc(bin2Hex(decimal_output[m])); - } - - } //End Decimal - else if (k == 'h') //Print Hex - { - //New trick 3-15-04 - putc('0'); - putc('x'); - - if(my_byte > 0x00FF) - { - putc(bin2Hex(my_byte.high8 >> 4)); - putc(bin2Hex(my_byte.high8 & 0b.0000.1111)); - } - - putc(bin2Hex(my_byte.low8 >> 4)); - putc(bin2Hex(my_byte.low8 & 0b.0000.1111)); - } //End Hex - else if (k == 'f') //Print Float - { - putc('!'); - } //End Float - else if (k == 'u') //Print Direct Character - { - //All ascii characters below 20 are special and screwy characters - //if(my_byte > 20) - putc(my_byte); - } //End Direct - - } //End Special Chars - - else - putc(k); - } -} diff --git a/Firmware/SHT15-Testing-v11/SHT15-Testing-v11.hex b/Firmware/SHT15-Testing-v11/SHT15-Testing-v11.hex deleted file mode 100644 index a630657..0000000 --- a/Firmware/SHT15-Testing-v11/SHT15-Testing-v11.hex +++ /dev/null @@ -1,70 +0,0 @@ -:020000004A288C -:10000800B600003003178F000313360C7F39233EE8 -:1000180003178D0003188F0A83168C170C14000021 -:1000280000008312031336181E2803170C087F39A3 -:100038000313080003170C0D0E0D031308008A297B -:10004800482AB11A202AE539F434EE330005C437BA -:10005800EE320005C83AED34E434F43CA0347310B1 -:1000680025320005D4326D386539613A7539651025 -:10007800E939A01264000A29E539F037EE3965102C -:10008800F434ED32A01EA012E43673008316031375 -:100098005C206430A600A701F920A601A701A801E9 -:1000A80047216E200F30A600A701A80147215B2831 -:1000B8009B01831285018316850183128601043012 -:1000C80083168600333099002430980090308312CC -:1000D80098000800C42005308C20CF20A1002608F5 -:1000E800A200A3011530A6002108A7002208A80035 -:1000F8004721C42003308C20CF20A1002608A2006D -:10010800A3012530A6002108A7002208A800472936 -:10011800A400831606138312A501083025020318CC -:100128009E28A40D8613031C0613031806178617AA -:10013800A50A91288613831606178312061BA22880 -:1001480086178613061FA628A501061FB428A50A28 -:10015800250A0319B4280A30A600A701F920A928FE -:100168000310250DA700A5010530A6002708A5073F -:10017800A60BBA283830A6002508A700A8014729E9 -:100188008316061383120617861706138613861717 -:100198000617861308008613831606178312A40110 -:1001A800113024020318F7282408083A0319E8280C -:1001B80000000000000000008617A50DA60D251000 -:1001C800061B25148613F5288316061383120613B7 -:1001D800000086170000000000008613831606172B -:1001E8008312A40AD428250808002608270403191E -:1001F8001029A8010430280203180B29A901453049 -:10020800290203180929A90A0329A80AFE28A6030E -:10021800260A0319A703F9280800B6000C1E12299C -:10022800360899000800831203138C1E19291A082E -:100238000800FF01FF01831203138C128C1A302966 -:10024800FF0A0319FF0A7F08E83A031D22297F08DD -:10025800033A031D222900341A080800B6000130A9 -:100268008A00360882073034313432343334343437 -:1002780035343634373438343934413442344334FD -:10028800443445344634AD01AE01A9012908260796 -:100298000420AA00AA0803191D2A253A031D192AB1 -:1002A800A90A290826070420AA00AA0803191D2A52 -:1002B8005C3A031D6629A90A290826070420AA0012 -:1002C80011211B2A2A08623A031D8229AB01083032 -:1002D8002B0203181B2AA71F732931301121A71BD2 -:1002E8007729303011212B08033A031D7D2920304E -:1002F80011210310A70DA80DAB0A6B292A08643A2F -:10030800031DED29A81F9D292D3011212708B700AD -:100318002808B8001030B6000310A70DA80DB70DB7 -:10032800B80D031C9B29A803A703270FA80AB60B1F -:10033800902927082804031DA429303011211B2ADD -:100348000430AB00A81BDF29270828040319DF297C -:100358002708B7002808B800AC011030B600B70D60 -:10036800B80DAC0D0318BC290A302C02031CBE2999 -:100378000A30AC02B60BB32931302B078400831343 -:100388002C0880002708B7002808B800B9011030E9 -:10039800B600B70DB80DB90D0318D6290A303902C1 -:1003A800031CD9290A30B9020314A70DA80DB60BEE -:1003B800CD29AB03A629AB0A05302B0203181B2A4B -:1003C80031302B0784008313000832211121AB0A36 -:1003D800E0292A08683A031D0B2A303011217830A9 -:1003E8001121A81B022AA8080319022A280E0F396E -:1003F800322111210F30280532211121270E0F3902 -:10040800322111210F302705322111211B2A2A08F8 -:10041800663A031D122A213011211B2A2A08753A2F -:10042800031D1B2A270811211B2A2A081121A90AA2 -:040438004A29080045 -:00000001FF diff --git a/Libraries/Arduino/LICENSE.md b/Libraries/Arduino/LICENSE.md new file mode 100755 index 0000000..f8dc62d --- /dev/null +++ b/Libraries/Arduino/LICENSE.md @@ -0,0 +1,9 @@ + +License Information +------------------- + +The hardware is released under [Creative Commons Share-alike 3.0](http://creativecommons.org/licenses/by-sa/3.0/). + +All other code is open source so please feel free to do anything you want with it; you buy me a beer if you use this and we meet someday ([Beerware license](http://en.wikipedia.org/wiki/Beerware)). + + diff --git a/Libraries/Arduino/README.md b/Libraries/Arduino/README.md new file mode 100755 index 0000000..ab72900 --- /dev/null +++ b/Libraries/Arduino/README.md @@ -0,0 +1,42 @@ +SparkFun SHT1X Arduino Library +======================================== +![SHT15 Humidity and Teme Sensor Breakout](https://cdn.sparkfun.com/assets/parts/1/1/1/3/9/13683-01.jpg)](https://www.sparkfun.com/products/12055) + +[SHT15 Humidity and Temperature Sensor Breakout (SEN-13683)](https://www.sparkfun.com/products/13683) + +This is a Arduino Library for the SHT15 Humidity and Temperature Sensor. +Request temperature in both C and F as well as the humidity. + +Repository Contents +------------------- + +* **/examples** - Example sketches for the library (.ino). Run these from the Arduino IDE. +* **/src** - Source files for the library (.cpp, .h). +* **library.properties** - General library properties for the Arduino package manager. + +Documentation +-------------- + +* **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library. +* **[Product Repository](https://github.com/sparkfun/SHT15_Breakout)** - Main repository (including hardware files) for the SHT15 Humidity and Temperature Sensor. +* **[Hookup Guide](https://learn.sparkfun.com/tutorials/sht15-humidity-and-temperature-sensor-hookup-guide)** - Basic hookup guide for the SHT15 Humidity and Temperature Sensor. + +Products that use this Library +--------------------------------- + +* [SEN-13683](https://www.sparkfun.com/products/13683)- SHT15 Humidity and Temperature Sensor + + + +License Information +------------------- + +This product is _**open source**_! + +The **code** is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round! + +Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license. + +Distributed as-is; no warranty is given. + +- Your friends at SparkFun. diff --git a/Libraries/Arduino/examples/SHT15_Basic/SHT15_Basic.ino b/Libraries/Arduino/examples/SHT15_Basic/SHT15_Basic.ino new file mode 100644 index 0000000..3cf63fa --- /dev/null +++ b/Libraries/Arduino/examples/SHT15_Basic/SHT15_Basic.ino @@ -0,0 +1,75 @@ +/****************************************************************************** +SHT15 Example +Joel Bartlett @ SparkFun Electronics +16 Sept 2015 +https://github.com/sparkfun/SparkFun_ISL29125_Breakout_Arduino_Library + +This example shows how to get the temperature in F or C and humidity +Developed/Tested with: +SparkFun RedBoard +Arduino IDE 1.6.5 + +Connections: +GND -> A2 +Vcc -> A3 +DATA -> A4 +SCK -> A5 + +Requires: +SparkFun_SHT1X Arduino Library +https://github.com/sparkfun/SHT15_Breakout/ + +This code is beerware. +Distributed as-is; no warranty is given. +******************************************************************************/ +#include + +//variables for storing values +float tempC = 0; +float tempF = 0; +float humidity = 0; + +//Create an instance of the SHT1X sensor +SHT1x sht15(A4, A5);//Data, SCK + +//delacre output pins for powering the sensor +int power = A3; +int gnd = A2; + +void setup() +{ + Serial.begin(9600); // Open serial connection to report values to host + + pinMode(power, OUTPUT); + pinMode(gnd, OUTPUT); + + digitalWrite(power, HIGH); + digitalWrite(gnd, LOW); +} +//------------------------------------------------------------------------------------------- +void loop() +{ + readSensor(); + printOut(); + delay(1000); +} +//------------------------------------------------------------------------------------------- +void readSensor() +{ + // Read values from the sensor + tempC = sht15.readTemperatureC(); + tempF = sht15.readTemperatureF(); + humidity = sht15.readHumidity(); +} +//------------------------------------------------------------------------------------------- +void printOut() +{ + Serial.print(" Temp = "); + Serial.print(tempF); + Serial.print("F, "); + Serial.print(tempC); + Serial.println("C"); + Serial.print(" Humidity = "); + Serial.print(humidity); + Serial.println("%"); +} diff --git a/Libraries/Arduino/library.properties b/Libraries/Arduino/library.properties new file mode 100755 index 0000000..6f300db --- /dev/null +++ b/Libraries/Arduino/library.properties @@ -0,0 +1,9 @@ +name=SparkFun SHT_1x +version=1.1.0 +author=Joel Bartlett@SparkFun Electronics +maintainer=SparkFun Electronics +sentence=An Arduino Library for the SHT_15 Humidity and Temperature Sensor Breakout from SparkFun Electronics. +paragraph=Retrieve temperature and humidity information over a 2-wire interface +category=Sensors +url=https://github.com/sparkfun/SHT15_Breakout +architectures=* \ No newline at end of file diff --git a/Libraries/Arduino/src/SparkFun_SHT1X.cpp b/Libraries/Arduino/src/SparkFun_SHT1X.cpp new file mode 100644 index 0000000..8e7518d --- /dev/null +++ b/Libraries/Arduino/src/SparkFun_SHT1X.cpp @@ -0,0 +1,223 @@ +/** + * SHT1x Library + * + * Copyright 2009 Jonathan Oxer / + * Based on previous work by: + * Maurice Ribble: + * Wayne ?: + * + * Updated for Arduino 1.6.5 Library Manger by Joel Bartlett + * SparkFun Electronics + * September 16, 2015 + * + * Manages communication with SHT1x series (SHT10, SHT11, SHT15) + * temperature / humidity sensors from Sensirion (www.sensirion.com). + */ + +#include "SparkFun_SHT1x.h" + +SHT1x::SHT1x(int dataPin, int clockPin) +{ + _dataPin = dataPin; + _clockPin = clockPin; +} + + +/* ================ Public methods ================ */ +//Reads the current temperature in degrees Celsius + +float SHT1x::readTemperatureC() +{ + int _val; // Raw value returned from sensor + float _temperature; // Temperature derived from raw value + + // Conversion coefficients from SHT15 datasheet + const float D1 = -40.0; // for 14 Bit @ 5V + const float D2 = 0.01; // for 14 Bit DEGC + + // Fetch raw value + _val = readTemperatureRaw(); + + // Convert raw value to degrees Celsius + _temperature = (_val * D2) + D1; + + return (_temperature); +} + +//////////////////////////////////////////////////////////////////////// +//Reads the current temperature in degrees Fahrenheit +float SHT1x::readTemperatureF() +{ + int _val; // Raw value returned from sensor + float _temperature; // Temperature derived from raw value + + // Conversion coefficients from SHT15 datasheet + const float D1 = -40.0; // for 14 Bit @ 5V + const float D2 = 0.018; // for 14 Bit DEGF + + // Fetch raw value + _val = readTemperatureRaw(); + + // Convert raw value to degrees Fahrenheit + _temperature = (_val * D2) + D1; + + return (_temperature); +} +//////////////////////////////////////////////////////////////////////// +//Reads current temperature-corrected relative humidity +float SHT1x::readHumidity() +{ + int _val; // Raw humidity value returned from sensor + float _linearHumidity; // Humidity with linear correction applied + float _correctedHumidity; // Temperature-corrected humidity + float _temperature; // Raw temperature value + + // Conversion coefficients from SHT15 datasheet + const float C1 = -4.0; // for 12 Bit + const float C2 = 0.0405; // for 12 Bit + const float C3 = -0.0000028; // for 12 Bit + const float T1 = 0.01; // for 14 Bit @ 5V + const float T2 = 0.00008; // for 14 Bit @ 5V + + // Command to send to the SHT1x to request humidity + int _gHumidCmd = 0b00000101; + + // Fetch the value from the sensor + sendCommandSHT(_gHumidCmd, _dataPin, _clockPin); + waitForResultSHT(_dataPin); + _val = getData16SHT(_dataPin, _clockPin); + skipCrcSHT(_dataPin, _clockPin); + + // Apply linear conversion to raw value + _linearHumidity = C1 + C2 * _val + C3 * _val * _val; + + // Get current temperature for humidity correction + _temperature = readTemperatureC(); + + // Correct humidity value for current temperature + _correctedHumidity = (_temperature - 25.0 ) * (T1 + T2 * _val) + _linearHumidity; + + return (_correctedHumidity); +} + + +/* ================ Private methods ================ */ +float SHT1x::readTemperatureRaw() +{ + int _val; + + // Command to send to the SHT1x to request Temperature + int _gTempCmd = 0b00000011; + + sendCommandSHT(_gTempCmd, _dataPin, _clockPin); + waitForResultSHT(_dataPin); + _val = getData16SHT(_dataPin, _clockPin); + skipCrcSHT(_dataPin, _clockPin); + + return (_val); +} +//////////////////////////////////////////////////////////////////////// +int SHT1x::shiftIn(int _dataPin, int _clockPin, int _numBits)// commands for reading/sending data to a SHTx sensor +{ + int ret = 0; + int i; + + for (i=0; i<_numBits; ++i) + { + digitalWrite(_clockPin, HIGH); + delay(10); // I don't know why I need this, but without it I don't get my 8 lsb of temp + ret = ret*2 + digitalRead(_dataPin); + digitalWrite(_clockPin, LOW); + } + + return(ret); +} +//////////////////////////////////////////////////////////////////////// +void SHT1x::sendCommandSHT(int _command, int _dataPin, int _clockPin)// send a command to the SHTx sensor +{ + int ack; + + // Transmission Start + pinMode(_dataPin, OUTPUT); + pinMode(_clockPin, OUTPUT); + digitalWrite(_dataPin, HIGH); + digitalWrite(_clockPin, HIGH); + digitalWrite(_dataPin, LOW); + digitalWrite(_clockPin, LOW); + digitalWrite(_clockPin, HIGH); + digitalWrite(_dataPin, HIGH); + digitalWrite(_clockPin, LOW); + + // The command (3 msb are address and must be 000, and last 5 bits are command) + shiftOut(_dataPin, _clockPin, MSBFIRST, _command); + + // Verify we get the correct ack + digitalWrite(_clockPin, HIGH); + pinMode(_dataPin, INPUT); + ack = digitalRead(_dataPin); + if (ack != LOW) { + //Serial.println("Ack Error 0"); + } + digitalWrite(_clockPin, LOW); + ack = digitalRead(_dataPin); + if (ack != HIGH) { + //Serial.println("Ack Error 1"); + } +} +//////////////////////////////////////////////////////////////////////// +void SHT1x::waitForResultSHT(int _dataPin)// wait for the SHTx answer +{ + int i; + int ack; + + pinMode(_dataPin, INPUT); + + for(i= 0; i < 100; ++i) + { + delay(10); + ack = digitalRead(_dataPin); + + if (ack == LOW) { + break; + } + } + + if (ack == HIGH) { + //Serial.println("Ack Error 2"); // Can't do serial stuff here, need another way of reporting errors + } +} +//////////////////////////////////////////////////////////////////////// +int SHT1x::getData16SHT(int _dataPin, int _clockPin)// get data from the SHTx sensor +{ + int val; + + // get the MSB (most significant bits) + pinMode(_dataPin, INPUT); + pinMode(_clockPin, OUTPUT); + val = shiftIn(_dataPin, _clockPin, 8); + val *= 256; // this is equivalent to val << 8; + + // send the required ACK + pinMode(_dataPin, OUTPUT); + digitalWrite(_dataPin, HIGH); + digitalWrite(_dataPin, LOW); + digitalWrite(_clockPin, HIGH); + digitalWrite(_clockPin, LOW); + + // get the LSB (less significant bits) + pinMode(_dataPin, INPUT); + val |= shiftIn(_dataPin, _clockPin, 8); + + return val; +} +//////////////////////////////////////////////////////////////////////// +void SHT1x::skipCrcSHT(int _dataPin, int _clockPin) +{ + // Skip acknowledge to end trans (no CRC) + pinMode(_dataPin, OUTPUT); + pinMode(_clockPin, OUTPUT); + + digitalWrite(_dataPin, HIGH); + digitalWrite(_clockPin, HIGH); + digitalWrite(_clockPin, LOW); +} diff --git a/Libraries/Arduino/src/SparkFun_SHT1X.h b/Libraries/Arduino/src/SparkFun_SHT1X.h new file mode 100644 index 0000000..5a820d6 --- /dev/null +++ b/Libraries/Arduino/src/SparkFun_SHT1X.h @@ -0,0 +1,45 @@ +/** + * SHT1x Library + * + * Copyright 2009 Jonathan Oxer / + * Based on previous work by: + * Maurice Ribble: + * Wayne ?: + * + * Updated for Arduino 1.6.5 Library Manger by Joel Bartlett + * SparkFun Electronics + * September 16, 2015 + * + * Manages communication with SHT1x series (SHT10, SHT11, SHT15) + * temperature / humidity sensors from Sensirion (www.sensirion.com). + */ + +#ifndef SparkFun_SHT1X_h +#define SparkFun_SHT1X_h + +#if (ARDUINO >= 100) +#include +#else +#include +#endif + +class SHT1x +{ + public: + SHT1x(int dataPin, int clockPin); + float readHumidity(); + float readTemperatureC(); + float readTemperatureF(); + private: + int _dataPin; + int _clockPin; + int _numBits; + float readTemperatureRaw(); + int shiftIn(int _dataPin, int _clockPin, int _numBits); + void sendCommandSHT(int _command, int _dataPin, int _clockPin); + void waitForResultSHT(int _dataPin); + int getData16SHT(int _dataPin, int _clockPin); + void skipCrcSHT(int _dataPin, int _clockPin); +}; + +#endif \ No newline at end of file diff --git a/Libraries/README.md b/Libraries/README.md new file mode 100755 index 0000000..c74b5ec --- /dev/null +++ b/Libraries/README.md @@ -0,0 +1,27 @@ +SparkFun SHT15 Sensor Libraries +=================================================== + +Libraries for use in different environments. + +Directory Contents +------------------- +* **/Arduino** - [Arduino IDE](http://www.arduino.cc/en/Main/Software) libraries + + +License Information +------------------- +This product is open source! +The code is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round! +Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license. + +Distributed as-is; no warranty is given. + +- Your friends at SparkFun. + + + +Update Library Instructions: +---------------------------- +To get the most up-to-date version of the library, you must run the following git subtree commands. + +$git subtree pull -P Libraries/Arduino --squash https://github.com/sparkfun/SparkFun_ISL29125_Breakout_Arduino_Library.git master \ No newline at end of file diff --git a/README.md b/README.md index 34984ee..8d101fc 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,32 @@ SHT15 Breakout ============== -[![SHT15 Breakout](https://dlnmh9ip6v2uc.cloudfront.net/images/products/8/2/5/7/08527-01_i_ma.jpg) -*SHT15 Breakout Board (SEN-08257)*](https://www.sparkfun.com/products/8257) +[![SHT15 Breakout](https://cdn.sparkfun.com/assets/parts/1/1/1/3/9/13683-01.jpg) +*SHT15 Breakout Board (SEN-13683)*](https://www.sparkfun.com/products/13683) Repository Contents ------------------- -* **/Firmware** - Example firmware to use with the sensor * **/Hardware** - All Eagle design files (.brd, .sch) +* **/Libraries** - Contains the Arduino library and examples for the sensor +* **/Production** - Test bed files and production panel files +Documentation +-------------- +* **[Hookup Guide](https://learn.sparkfun.com/tutorials/sht15-humidity-and-temperature-sensor-hookup-guide)** - Basic hookup guide for the sensor. +* **[SparkFun Fritzing repo](https://github.com/sparkfun/Fritzing_Parts)** - Fritzing diagrams for SparkFun products. +* **[SparkFun 3D Model repo](https://github.com/sparkfun/3D_Models)** - 3D models of SparkFun products. + License Information ------------------- -The hardware is released under [Creative Commons Share-alike 3.0](http://creativecommons.org/licenses/by-sa/3.0/). -All other code is open source so please feel free to do anything you want with it; -you buy me a beer if you use this and we meet someday ([Beerware license](http://en.wikipedia.org/wiki/Beerware)). +This product is _**open source**_! + +The **hardware** is released under [Creative Commons ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). + +The **code** is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round! + +Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license. + +Distributed as-is; no warranty is given. + +- Your friends at SparkFun.