Advertisement
microrobotics

SHT10 Sample Code for Arduino

Aug 6th, 2017
8,453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.77 KB | None | 0 0
  1. #include <SHT1x.h>
  2.  
  3. // Specify data and clock connections and instantiate SHT1x object
  4. #define dataPin  10
  5. #define clockPin 11
  6. SHT1x sht1x(dataPin, clockPin);
  7.  
  8. void setup()
  9. {
  10.    Serial.begin(38400); // Open serial connection to report values to host
  11.    Serial.println("Starting up");
  12. }
  13.  
  14. void loop()
  15. {
  16.   float temp_c;
  17.   float temp_f;
  18.   float humidity;
  19.  
  20.   // Read values from the sensor
  21.   temp_c = sht1x.readTemperatureC();
  22.   temp_f = sht1x.readTemperatureF();
  23.   humidity = sht1x.readHumidity();
  24.  
  25.   // Print the values to the serial port
  26.   Serial.print("Temperature: ");
  27.   Serial.print(temp_c, DEC);
  28.   Serial.print("C / ");
  29.   Serial.print(temp_f, DEC);
  30.   Serial.print("F. Humidity: ");
  31.   Serial.print(humidity);
  32.   Serial.println("%");
  33.  
  34.   delay(2000);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement