Download presentation
Presentation is loading. Please wait.
Published byCameron Grant Modified over 9 years ago
1
Network and Systems Laboratory nslab.ee.ntu.edu.tw se
2
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
3
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
4
Network and Systems Laboratory nslab.ee.ntu.edu.tw Taroko Connections
5
Network and Systems Laboratory nslab.ee.ntu.edu.tw Start Transmission and Send Command How to start What are the commands available
6
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
7
Network and Systems Laboratory nslab.ee.ntu.edu.tw Software Implementation
8
Network and Systems Laboratory nslab.ee.ntu.edu.tw Software Implementation
9
Network and Systems Laboratory nslab.ee.ntu.edu.tw Software Implementation
10
Network and Systems Laboratory nslab.ee.ntu.edu.tw Convert to Physical Values 12-bit humidity, 14-bit temperature Temperature Humidity
11
Network and Systems Laboratory nslab.ee.ntu.edu.tw Device Driver Download here http://nslab.ee.ntu.edu.tw/courses/wsn-labs-spring- 09/labs/sht11Driver.rar http://nslab.ee.ntu.edu.tw/courses/wsn-labs-spring- 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);
12
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)
13
Network and Systems Laboratory nslab.ee.ntu.edu.tw Example
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.