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:sut:generalpurpose2:b2 [2020/10/25 08:40] pczekalskien:iot-open:remotelab:sut:generalpurpose2:b2 [Unknown date] (current) – external edit (Unknown date) 127.0.0.1
Line 1: Line 1:
 ==== B2: Presenting temperature and humidity on the LCD ==== ==== B2: Presenting temperature and humidity on the LCD ====
-In this scenario, you will present temperature and humidity as read by the attached DHT22 sensor, on the LCD screen.+In this scenario, you will present temperature and humidity as read by the attached DHT11 sensor, on the LCD screen.
 === Target group === === Target group ===
 Beginners Beginners
Line 10: Line 10:
 #include <LiquidCrystal_I2C.h> #include <LiquidCrystal_I2C.h>
 </code> </code>
-The temperature and humidity sensor is all-in-one, DHT22/DHT11 sensor (white) or DHT11 (blue), connected to the pin D4. Observe your camera to check which sensor is equipped with your lab and consult node documentation.\\+The temperature and humidity sensor is all-in-one, DHT11, connected to the pin D4. Observe your camera to check which sensor is equipped with your lab and consult node documentation.\\
 To read data you may use a dedicated library (libraries): To read data you may use a dedicated library (libraries):
 <code c> <code c>
Line 18: Line 18:
 === Scenario === === Scenario ===
 Once you initialise sensor and LCD display, read sensor data (temperature and humidity, mind they're float values, not integers) and then display them in the loop. Give each loop execution some 5-10s delay. Once you initialise sensor and LCD display, read sensor data (temperature and humidity, mind they're float values, not integers) and then display them in the loop. Give each loop execution some 5-10s delay.
-<note warning>Do not try to read temperature and humidity too frequent. Once every 5s is quite enough both for information and safe enough to not let your readings race with the communication protocol. If you read too frequent, your sensor may not be able to deliver data on time and you will obtain a 'nan' (not a number) instead of temperature and humidity.</note>+<note warning>Do not try to read temperature and humidity too frequently. Once every 5s is quite enough both for information and safe enough to not let your readings race with the communication protocol. If you read too frequent, your sensor may not be able to deliver data on time and you will obtain a 'nan' (not a number) instead of temperature and humidity.</note>
 The first line of the LCD should display: "//Temperature is://"\\ The first line of the LCD should display: "//Temperature is://"\\
 The second line should provide temperature within the "//NN.N C//" form, in Celcius.\\ The second line should provide temperature within the "//NN.N C//" form, in Celcius.\\
Line 42: Line 42:
  
 == Step 2 == == Step 2 ==
-Instantiate software controler components for the LCD display and DHT sensor:+Instantiate software controller components for the LCD display and DHT sensor:
 <code c> <code c>
 LiquidCrystal_I2C lcd(0x3F,20,4);  // set the LCD address to 0x3F for nodes 1 through 5, 8 and 9 LiquidCrystal_I2C lcd(0x3F,20,4);  // set the LCD address to 0x3F for nodes 1 through 5, 8 and 9
 //LiquidCrystal_I2C lcd(0x27,20,4); // for nodes 10 and 11 only! //LiquidCrystal_I2C lcd(0x27,20,4); // for nodes 10 and 11 only!
                                    // for a 20 chars and 4 line display                                    // for a 20 chars and 4 line display
-DHT dht(DHTpin,DHT22,50); //for nodes 1 through 4 +DHT dht(DHTpin, DHT11, 50); 
-//DHT dht(DHTpin,DHT11,50); //for nodes 8 through 11+
 </code> </code>
 == Step 3 == == Step 3 ==
Line 87: Line 86:
 ... ...
 </code> </code>
-<note tip>''sprintf'' uses number of wildcards that are rendered with data. Refer to the c/c++ documentation on ''sprintf''. Here <code c>%2.1f</code> means: having float number render it to string using two digits before decimal point and one after. Temperature in our lab is always above 10C. <code c>%%</code> is an escape character to print a <code c>%</code> (percent) symbol.\\''delay(time)'' is measured in milliseconds.</note>+<note tip>''sprintf'' uses number of wildcards that are rendered with data. Refer to the c/c++ documentation on ''sprintf''. Here <code c>%2.1f</code> means: having float number render it to string using two digits before decimal point and one after. Temperature in our lab is always above 10C. <code c>%%</code> is an escape character to print a <code c>%</code> (percent) symbol. 
 +<code c> 
 +delay(time) 
 +</code> is measured in milliseconds.</note>
  
 === Result validation === === Result validation ===
-Observe temperature and humidity readings on the LCD. The temperature in our lab usually ranges between 20-30C (not, we observed over 30C during really hot summer!) while humidity is usually between 35-60%Rh.+Observe temperature and humidity readings on the LCD. The temperature in our lab usually ranges between 20-30C (not, we observed over 30C during really hot summer!) while humidity is usually between 30-60%Rh.
  
en/iot-open/remotelab/sut/generalpurpose2/b2.1603615242.txt.gz · Last modified: 2020/10/25 10: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