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 [2019/08/04 20:14] 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 sensor, connected to the pin D3.+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 32: Line 32:
  
 === Steps === === Steps ===
-// Write some extra information if i.e. some steps are optional otherwise cancel this paragraph (but do not remove header).//+
 == Step 1 == == Step 1 ==
-Include LCD driver library:+Include LCD and DHT sensor driver libraries:
 <code c> <code c>
 #include <LiquidCrystal_I2C.h> #include <LiquidCrystal_I2C.h>
Line 42: Line 42:
  
 == Step 2 == == Step 2 ==
-Instantiate software controler component for the LCD display:+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 a 20 chars and 4 line display +LiquidCrystal_I2C lcd(0x3F,20,4);  // set the LCD address to 0x3F for nodes 1 through 5, 8 and 9 
-DHT dht(DHTpin,DHT22,50);+//LiquidCrystal_I2C lcd(0x27,20,4); // for nodes 10 and 11 only! 
 +                                   // for a 20 chars and 4 line display 
 +DHT dht(DHTpin, DHT11, 50); 
 </code> </code>
 == Step 3 == == Step 3 ==
Line 54: Line 56:
  
 == Step 4 == == Step 4 ==
-Initialize LCD and dht sensor:+Initialize LCD and DHT sensor:
 <code c> <code c>
 ... ...
-  lcd.init(D2,D1);                      // initialize the lcd +  lcd.init(D2,D1);     // initialize the lcd 
   lcd.backlight();   lcd.backlight();
   lcd.home();   lcd.home();
 ... ...
   dht.begin();   dht.begin();
-  delay(1000);                          // give it a second to let the sensor initialize+  delay(1000);         // give it a second to let the sensor initialize
 ... ...
 </code> </code>
Line 84: 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. Temperature ranges between 20-30C while humidity 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.1564949688.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