Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:iot-open:remotelab:itt:thermohygro [2018/12/06 06:16] rim.puksen:iot-open:remotelab:itt:thermohygro [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 1: Line 1:
-===== Temperature and humidity sensor module =====+===== ITT Temperature and humidity sensor module =====
 This laboratory is located in the office of ITT Group in Tallinn, Estonia. This laboratory is located in the office of ITT Group in Tallinn, Estonia.
  
Line 14: Line 14:
  
 === Sensors === === Sensors ===
-This laboratory uses the DHT22 temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure temperature. The sensor only transmits digital data (no analog values). The sensor is calibrated and doesn't require extra components so you can get right to measuring relative humidity and temperature.+This laboratory uses the DHT22 temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure temperature. The sensor only transmits digital data (no analogue values). The sensor is calibrated and doesn't require extra components so you can get right to measuring relative humidity and temperature.
  
 === Specifications === === Specifications ===
Line 25: Line 25:
 === Electrical connection === === Electrical connection ===
  
-1-wire data connection is connected to port GPIO2.+The 1-wire data connection is connected to port GPIO2.
  
 === Software, libraries and externals === === Software, libraries and externals ===
Line 38: Line 38:
  
 ==== Hands-on labs ==== ==== Hands-on labs ====
-//List study scenarios (hands-on labs), linking to the Dokuwiki pages with hands-on labs descriptions (there should be a separate page for each scenario). Classify each scenario and refer to the target group using starting keywords: + 
-  * Beginners +=== Example code === 
-  * Undergraduates + 
-  * Masters +<code c> 
-  * Professionals +#include <Arduino.h> 
-Note, assume that more professional group automatically contains less professional onesNote - use language and as appropriate to the target groupi.e.:// +#include <ittiot.h> 
-<code> + 
-  * Beginners: Elementary operations on the Arduino 2x16 LCD screen+#include <DHT.h> 
-  * Undergraduates: Visualizing temperature and humidity on the remote screen+#define DHTPIN D4     // what pin we're connected to 
-  * Masters: Using power saving states to limit power consumption.+#define DHTTYPE DHT22   // DHT 22  (AM2302) 
 + 
 +DHT dht(DHTPINDHTTYPE); 
 + 
 +void iot_connected() 
 +{ 
 +  Serial.println("MQTT connected callback"); 
 +  iot.log("IoT DHT example!"); 
 +
 + 
 +void setup() 
 +{ 
 +  Serial.begin(115200); 
 +  Serial.println("Booting"); 
 +  iot.printConfig(); // print json config to serial 
 +  iot.setup(); 
 +  pinMode(16OUTPUT); 
 +  dht.begin(); 
 + 
 +
 + 
 +void loop() 
 +
 +  iot.handle(); 
 + 
 +  float h = dht.readHumidity(); 
 + float t = dht.readTemperature(); 
 + 
 +  char buf[10]; // Put whatever length you need here 
 + String(t).toCharArray(buf,10); 
 + 
 +  digitalWrite(16,HIGH); 
 +  iot.publishMsg("temp",buf); 
 + delay(2000); 
 +  digitalWrite(16,LOW); 
 + 
 + String(h).toCharArray(buf,10); 
 +  iot.publishMsg("hum",buf); 
 + delay(2000); 
 +}
 </code> </code>
 +
 ==== Support ==== ==== Support ====
-//Give some information on how to access help, how to get support in case of the trouble etc.//+info@ittgroup.ee
  
en/iot-open/remotelab/itt/thermohygro.1544077010.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0