Network and Systems Laboratory nslab.ee.ntu.edu.tw se
Network and Systems Laboratory nslab.ee.ntu.edu.tw SPI Master–Slave mode Synchronous protocol All transmissions are referenced to a common clock Clock generated by the master (MCU) Four main signals Master Out Slave In (MOSI): data from master to slave Master In Slave Out (MISO): data from slave to master Serial Clock (SCLK or SCK): clock Chip Select (CS): select particular peripheral when multiple peripherals are connected to master
Network and Systems Laboratory nslab.ee.ntu.edu.tw SHT11 Relative humidity and temperature sensors Digital output Manufacturer defined interface two wires bi-direction 1.Use a GPIO pin as clock (SCK), it is always output direction 2.Use another GPIO as DATA, dynamic setting it to input(read) or output(write) direction
Network and Systems Laboratory nslab.ee.ntu.edu.tw Taroko Connections
Network and Systems Laboratory nslab.ee.ntu.edu.tw Start Transmission and Send Command How to start What are the commands available
Network and Systems Laboratory nslab.ee.ntu.edu.tw An Example: SHT11 Timing diagram Pull-up Data pin in output direction Set data pin to input direction, then SHT11 controls the DATA line
Network and Systems Laboratory nslab.ee.ntu.edu.tw Software Implementation
Network and Systems Laboratory nslab.ee.ntu.edu.tw Software Implementation
Network and Systems Laboratory nslab.ee.ntu.edu.tw Software Implementation
Network and Systems Laboratory nslab.ee.ntu.edu.tw Convert to Physical Values 12-bit humidity, 14-bit temperature Temperature Humidity
Network and Systems Laboratory nslab.ee.ntu.edu.tw Device Driver Download here 09/labs/sht11Driver.rar 09/labs/sht11Driver.rar Important functions in SHT1x_sensirion.c void sht1xInit(); void sht1xReset(); char sht1xMeasure(unsigned char *p_value, unsigned char *p_checksum, unsigned char mode); void sht1xCalculate(float *p_humidity,float *p_temperature);
Network and Systems Laboratory nslab.ee.ntu.edu.tw Functions char sht1xMeasure(unsigned char *p_value, unsigned char *p_checksum, unsigned char mode); mode: { TEMP, HUMI } Store measured value to *p_value Store 8-CRC checksum to *p_checksum void sht1xCalculate(float *p_humidity,float *p_temperature); Convert measured value to physical value Put the measured value in *p_humidity, *p_temperature Result will also place in *p_humidity, *p_temperature (overwrite)
Network and Systems Laboratory nslab.ee.ntu.edu.tw Example