Components and supplies
Arduino Pro Mini 328 - 5V/16MHz
Alphanumeric LCD, 16 x 2
Project description
Code
The Circuit
arduino
1/* 2 3 The circuit: 4 5 Select - Arduino nano, board: select - ATmega328P (old Bootloader), processor 6 5v to VCC 7 gnd to GND 8 9 LCD 16X2: 10 LCD 1(VSS) pin to ground 11 LCD 2(VDD) pin to vcc 12 10K potentiometer: 13 ends to +5V and ground 14 LCD 3(VO) pin to pot wiper 15 LCD 4(RS) pin to digital pin D7 16 LCD 5(RW) pin to ground 17 LCD 6(E) pin to digital pin D8 18 LCD 11(D4) pin to digital pin D9 19 LCD 12(D5) pin to digital pin D10 20 LCD 13(D6) pin to digital pin D11 21 LCD 14(D7) pin to digital pin D12 22 LCD 15(A) pin to vcc 23 LCD 16(K) pin to gnd 24 25 DHT22: 26 VCC: pin 1 to +5v 27 DATA: pin 2 to pin D2 nano 28 GND: pin 3 to ground 29 30 LED: 31 Nano pin D3 to led + 32 led - to 2000 ohm res 33 2000 res to ground 34 35 after download start the serial monitor 36 */ 37
The Circuit
arduino
1/* 2 3 The circuit: 4 5 Select - Arduino nano, board: select 6 - ATmega328P (old Bootloader), processor 7 5v to VCC 8 gnd to GND 9 10 11 LCD 16X2: 12 LCD 1(VSS) pin to ground 13 LCD 2(VDD) pin to vcc 14 10K potentiometer: 15 16 ends to +5V and ground 17 LCD 3(VO) pin to pot wiper 18 LCD 4(RS) pin 19 to digital pin D7 20 LCD 5(RW) pin to ground 21 LCD 6(E) pin to digital 22 pin D8 23 LCD 11(D4) pin to digital pin D9 24 LCD 12(D5) pin to digital pin 25 D10 26 LCD 13(D6) pin to digital pin D11 27 LCD 14(D7) pin to digital pin 28 D12 29 LCD 15(A) pin to vcc 30 LCD 16(K) pin to gnd 31 32 DHT22: 33 34 VCC: pin 1 to +5v 35 DATA: pin 2 to pin D2 nano 36 GND: pin 3 to ground 37 38 39 LED: 40 Nano pin D3 to led + 41 led - to 2000 ohm res 42 2000 res to ground 43 44 45 after download start the serial monitor 46 */ 47
Bob's Dew-point Temp display
arduino
1/* 2 RedTar4 3 Bobs_DewPoint_LCD_meter_DHT22_rev7 4 10/18/18 - 3/10/19 5 */ 6 7 // Library section 8#include <LiquidCrystal.h> // LCD library 9 LiquidCrystal lcd(7, 8, 9, 10, 11, 12); // (rs,e,d4,d5,d6,d7),initialize the LCD with the numbers of the interface pins 10#include <DHT.h> // DHT22 library, delete any "DHT.U" files from library,or it wont run 11 12 // Definition section 13#define DHTPIN 2 // what arduino pin we're connected to, arduino pin D2 14 DHT dht(DHTPIN, DHT22); // initialize DHT sensor and create sensor objects 15#define DHTTYPE DHT22 // create DHT 22 (AM2302), AM2321 object 16 17 // pin assignment section 18int alarmLed = 3; // assigns alarmLed int to arduino pin D3 19 20void setup() 21 { 22 // initilize and start systems 23 Serial.begin(9600); // sets up serial comm's to 9600 baud 24 dht.begin(); // initialize the DHT22 25 lcd.begin(16, 2); // initialize the LCD's number of columns and rows 26 27 // display and serial print initilization 28 Serial.println("DHTxx test!"); 29 lcd.setCursor(0, 1); lcd.print("DHTxx test!"); 30 delay(1500); 31 32 // output pin setup section 33 pinMode(alarmLed, OUTPUT); // assigns alarmLed (arduino pin 3) as an output 34 digitalWrite(alarmLed, LOW); // sets output alarmLed (arduino pin 3) low 35 36 } 37 38void loop() 39 { 40 // Reading temperature and humidity takes about 250 milliseconds 41 float H = dht.readHumidity(); // read humitity as %f 42 float C = dht.readTemperature(); // read temperature as Celsius (default) 43 float F = dht.readTemperature(true); // read temperature as Fahrenheit (if true) 44 45 // DHT22 data error check section 46 if (isnan(H) || isnan(C) || isnan(F)) 47 { 48 Serial.println("Failed to read from DHT sensor!"); 49 lcd.setCursor(0, 0); lcd.print(" "); 50 lcd.setCursor(0, 0); lcd.print(" Failed to read "); 51 lcd.setCursor(0, 1); lcd.print(" "); 52 lcd.setCursor(0, 1); lcd.print("DHT sensor Fail!"); 53 return; // returns to start of loop 54 } 55 56 // calculations and conversions section 57 float HiF = dht.computeHeatIndex(F, H); // read and compute heat index in Fahrenheit (the default) 58 float DewPoint = (C - (100 - H) / 5); // dewpoint calculation using Celsius value 59 float DP = (DewPoint * 9 / 5) + 32; // converts dewPoint calculation to fahrenheit 60 61 // alarm output section 62 if ((F - 2) <= DP) // if the F value - 2 is <= to the DP value then this statement is true 63 {digitalWrite(alarmLed, HIGH);} // since statement is true set alarmLed (arduino pin D3) high 64 else // if statement is not true then 65 {digitalWrite(alarmLed, LOW);} // set alarmLed (arduino pin D3) low 66 67 // serial monitor and debug section 68 Serial.print("Sample OK: "); // prints sample ok to serial monitor 69 Serial.print((int)C); Serial.print(" *C, "); // prints celsius value to serial monitor and returns cursor 70 Serial.print((int)F); Serial.print(" *F, "); // prints fahrenheit value to serial monitor and returns cursor 71 Serial.print((int)H); Serial.print(" %, "); // prints humidity value to serial monitor and returns cursor 72 Serial.print((int)DP); Serial.print(" DP, "); // prints dewpoint value to serial monitor and returns cursor to next line 73 Serial.print((int)HiF); Serial.print(" Heat index, "); // prints humidity value to serial monitor and returns cursor 74 Serial.print((int)DewPoint); Serial.println(" DewP, "); // prints dewpoint value to serial monitor and returns cursor to next line 75 76 // LCD print section 77 lcd.setCursor(0, 0); lcd.print("Tmp"); 78 lcd.setCursor(4, 0); lcd.print(F); 79 lcd.setCursor(6, 0); lcd.print((char)223); lcd.print("F"); // prints the degree's symbol 80 lcd.setCursor(8, 0); lcd.print("Dew"); 81 lcd.setCursor(12, 0); lcd.print(DP); 82 lcd.setCursor(14, 0); lcd.print((char)223); lcd.print("F"); // prints the degree's symbol 83 lcd.setCursor(0, 1); lcd.print("Hum "); 84 lcd.setCursor(4, 1); lcd.print(H); 85 lcd.setCursor(6, 1); lcd.print(" % "); 86 lcd.setCursor(8, 1); lcd.print("HId"); 87 lcd.setCursor(12, 1); lcd.print(HiF); 88 lcd.setCursor(14, 1); lcd.print((char)223); lcd.print("F"); // prints the degree's symbol 89 90 // The DHT22 sampling rate is .5HZ (.5 Sec), this delay sets program sample rate to match so no errors happen 91 delay(2000); 92 93 } 94
Comments
Only logged in users can leave comments
tomwyonkman
0 Followers
•0 Projects
Table of contents
Intro
9
0