Differences

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

Link to this comparison view

Next revision
Previous revision
en:iot-open:remotelab:ume:smartme:b2 [2019/09/27 13:08] – created salvatdien:iot-open:remotelab:ume:smartme:b2 [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== B2: Presenting temperature and humidity values on the LCD ======+==== IB2: Presenting temperature and humidity values on the LCD ====
  
- +=== Target group ===
- +
-===== Target group =====+
  
 This hands-on lab guide is intended for the Beginners but other target groups may benefit from it, treating it as basics for advanced projects. This hands-on lab guide is intended for the Beginners but other target groups may benefit from it, treating it as basics for advanced projects.
  
-===== Prerequisites =====+=== Prerequisites ===
  
-==== Liquid Crystal ====+=== Liquid Crystal ===
 For this library, you may refer to the [[en:iot-open:remotelab:ume:smartme:b1|B1 exercise]].  For this library, you may refer to the [[en:iot-open:remotelab:ume:smartme:b1|B1 exercise]]. 
  
-==== DHT sensors ====+=== DHT sensors ===
 The nodes of SmartME Network Laboratory are equipped with different versions of DHT sensors: DHT11 and DHT22.  The nodes of SmartME Network Laboratory are equipped with different versions of DHT sensors: DHT11 and DHT22. 
 The sensors look a bit similar and have the same pinout, but have different characteristics.  The sensors look a bit similar and have the same pinout, but have different characteristics. 
 Below you can find the DHT technical specifications: Below you can find the DHT technical specifications:
  
-=== DHT11 ===+== DHT11 ==
   * Ultra-low-cost   * Ultra-low-cost
   * 3 to 5V power and I/O   * 3 to 5V power and I/O
Line 27: Line 25:
   * 4 pins with 0.1" spacing   * 4 pins with 0.1" spacing
    
-=== DHT22 ===+== DHT22 ==
  
   * Low cost   * Low cost
Line 45: Line 43:
 Temperature and relative humidity can be used to determine the apparent temperature or the human perceived equivalent temperature, also called  “heat index”. The heat index was developed in 1978 by George Winterling and was adopted next year. It is also known as humiture, according to Wikipedia contributors. Temperature and relative humidity can be used to determine the apparent temperature or the human perceived equivalent temperature, also called  “heat index”. The heat index was developed in 1978 by George Winterling and was adopted next year. It is also known as humiture, according to Wikipedia contributors.
    
-==== Scenario ====+=== Scenario === 
 First, initialize LCD screen with the labels of temperature and relative humidity.  First, initialize LCD screen with the labels of temperature and relative humidity. 
 Then, after the sensor detection, next to the labels, the sensor values will be displayed, one per line, every 3 seconds. Note, the function readTemperature() reads temperature as Celsius (the default). If you want to read the temperature as Farenight, you have to set the true value as a parameter of the signature in the readTemperature(true) function. The relative humidity is expressed as a percentage. That means that at 100% RH the condensation occurs, while at 0% RH the air is completely dry. Then, after the sensor detection, next to the labels, the sensor values will be displayed, one per line, every 3 seconds. Note, the function readTemperature() reads temperature as Celsius (the default). If you want to read the temperature as Farenight, you have to set the true value as a parameter of the signature in the readTemperature(true) function. The relative humidity is expressed as a percentage. That means that at 100% RH the condensation occurs, while at 0% RH the air is completely dry.
 More, but not used in the proposed exercise, it is possible to compute the heat index in Fahrenheit (the default) by using the function computeHeatIndex(temp_value_farenight, humidity_value), or if you want in Celsius (isFahreheit = false) by using the function computeHeatIndex(temp_value_celsius, humidity_value, false). More, but not used in the proposed exercise, it is possible to compute the heat index in Fahrenheit (the default) by using the function computeHeatIndex(temp_value_farenight, humidity_value), or if you want in Celsius (isFahreheit = false) by using the function computeHeatIndex(temp_value_celsius, humidity_value, false).
 Result Result
-You should see the values of temperature and relative humidity, that are sampled and displayed every 3 seconds (3000 ms).+You should see the values of temperature and relative humidity, that is sampled and displayed every 3 seconds (3000 ms).
 Start Start
 There are no special steps to be performed. There are no special steps to be performed.
  
-==== Steps ====+=== Steps ===
  
-=== Step 1 ===+== Step 1 ==
 Include LCD driver library and DHT library: Include LCD driver library and DHT library:
 <code c> <code c>
Line 64: Line 63:
  
  
-=== Step 2 ===+== Step 2 ==
 Instantiate the software controller component for the LCD display. Then set up:  Instantiate the software controller component for the LCD display. Then set up: 
   - the DHTPIN (which refers to the digital pin we use to get the signal);   - the DHTPIN (which refers to the digital pin we use to get the signal);
Line 70: Line 69:
 Then initialize the DHT sensor. Then initialize the DHT sensor.
    
 +<code c>
 // initialize the library with the numbers of the interface pins // initialize the library with the numbers of the interface pins
 LiquidCrystal lcd(7, 6, 5, 4, 13, 2); LiquidCrystal lcd(7, 6, 5, 4, 13, 2);
Line 78: Line 78:
 // Initialize DHT sensor  // Initialize DHT sensor 
 DHT dht(DHTPIN, DHTTYPE); DHT dht(DHTPIN, DHTTYPE);
 +</code>
    
-Step 3+== Step 3 == 
  
 Initialize display and Initialize the DHT sensor - we suggest to do it in the setup() function: Initialize display and Initialize the DHT sensor - we suggest to do it in the setup() function:
  
 +<code c>
 void setup() { void setup() {
 // set up the LCD's number of columns and rows: // set up the LCD's number of columns and rows:
Line 91: Line 94:
 // Print the Humidity label to the LCD. // Print the Humidity label to the LCD.
 lcd.print("Hum. %"); lcd.print("Hum. %");
-  
 dht.begin(); dht.begin();
 } }
 +</code>
  
    
-Step 4+== Step 4 == 
 Implement loop() to sample and display the values of temperature and relative humidity on the LCD display, every 3 seconds: Implement loop() to sample and display the values of temperature and relative humidity on the LCD display, every 3 seconds:
    
    
 +<code c>
 void loop() { void loop() {
   // Wait three seconds between measurements.   // Wait three seconds between measurements.
Line 110: Line 115:
 // read temperature as Fahrenheit // read temperature as Fahrenheit
 //float f = dht.readTemperature(true); //float f = dht.readTemperature(true);
-   
-  
 // compute heat index in Fahrenheit (the default) // compute heat index in Fahrenheit (the default)
 float hif = dht.computeHeatIndex(f, h); float hif = dht.computeHeatIndex(f, h);
 // compute heat index in Celsius (isFahreheit = false) // compute heat index in Celsius (isFahreheit = false)
 float hic = dht.computeHeatIndex(t, h, false); float hic = dht.computeHeatIndex(t, h, false);
-  
 // print Temperature value to the LCD // print Temperature value to the LCD
 lcd.setCursor(14, 0); lcd.setCursor(14, 0);
Line 124: Line 126:
 lcd.print(h); lcd.print(h);
 } }
-  +</code> 
-Result validation+ 
 + 
 +=== Result validation ===
 Observe the temperature and relative humidity values shown in the LCD display. The display will refresh values every 3 seconds. Observe the temperature and relative humidity values shown in the LCD display. The display will refresh values every 3 seconds.
    
-Platformio.ini +=== Platformio.ini === 
- +<code>
 [env:uno] [env:uno]
 platform = atmelavr platform = atmelavr
Line 144: Line 148:
 lib_deps_external = lib_deps_external =
  https://github.com/arduino-libraries/LiquidCrystal.git#1.0.7  https://github.com/arduino-libraries/LiquidCrystal.git#1.0.7
-  +</code>
-B2.cpp+
  
 +=== IB2.cpp ===
 +
 +
 +<code c>
 #include <LiquidCrystal.h> #include <LiquidCrystal.h>
 #include "DHT.h" #include "DHT.h"
Line 194: Line 201:
    lcd.print(h);    lcd.print(h);
 } }
 +</code>
    
  
  
en/iot-open/remotelab/ume/smartme/b2.1569589733.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