Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tutorials_temperature [2016/02/24 04:50] admin created |
tutorials_temperature [2016/11/25 16:55] (current) admin |
||
---|---|---|---|
Line 7: | Line 7: | ||
We will need to use a dedicated library written specially for it. Download the library from {{::sht2x.zip| here}} and unzip its contents into the folder named //Arduino\libraries// or use Arduino IDE's Add ZIP Library command. | We will need to use a dedicated library written specially for it. Download the library from {{::sht2x.zip| here}} and unzip its contents into the folder named //Arduino\libraries// or use Arduino IDE's Add ZIP Library command. | ||
- | <code C> | + | <html><script src="https://gist.github.com/deathmeek/50b0c204290ea49e8f4d3bc61d142137.js"></script></html> |
- | #include <Wire.h> | + | |
- | #include <SHT2x.h> | + | |
- | + | ||
- | int controlPin = 7; | + | |
- | + | ||
- | void setup() | + | |
- | { | + | |
- | pinMode(controlPin, OUTPUT); //sensor on/off control | + | |
- | + | ||
- | Wire.begin(); | + | |
- | Serial.begin(9600); | + | |
- | + | ||
- | digitalWrite(controlPin, LOW); //enable all sensors | + | |
- | } | + | |
- | + | ||
- | void loop() | + | |
- | { | + | |
- | + | ||
- | + | ||
- | Serial.print("Humidity(%RH): "); | + | |
- | Serial.print(SHT2x.GetHumidity()); | + | |
- | Serial.print(" Temperature(C): "); | + | |
- | Serial.println(SHT2x.GetTemperature()); | + | |
- | + | ||
- | //digitalWrite(controlPin, HIGH); //disable all sensors | + | |
- | + | ||
- | delay(1000); | + | |
- | } | + | |
- | + | ||
- | </code> | + | |
+ | <note tip>Next tutorial will teach you how to implement a [[tutorials_barometer|barometer]]!</note> |