{"id":1618,"date":"2021-01-14T10:20:30","date_gmt":"2021-01-14T09:20:30","guid":{"rendered":"https:\/\/pa3csg.nl\/?page_id=1618"},"modified":"2021-01-14T10:20:30","modified_gmt":"2021-01-14T09:20:30","slug":"arduino-dewpoint-calculator-with-lcd","status":"publish","type":"page","link":"https:\/\/pa3csg.nl\/?page_id=1618","title":{"rendered":"Arduino Dewpoint Calculator with LCD"},"content":{"rendered":"\n<p>To put my 23cm amplifier remote at the base of the tower I needed some kind of heating to prevent condensation.  A dewpoint calculation was easily found on the web. Temperature and humidity measured by a DHT22<\/p>\n\n\n\n<p>I added LCD readout and some switching for a solid state relay. Some of these relays require some current so you might have to add a driver relay \/ transistor.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"359\" src=\"https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5556-1024x359.jpg\" alt=\"\" class=\"wp-image-1619\" srcset=\"https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5556-1024x359.jpg 1024w, https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5556-300x105.jpg 300w, https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5556-600x210.jpg 600w, https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5556-1536x538.jpg 1536w, https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5556-2048x717.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>The complete unit.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"621\" src=\"https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5557-1024x621.jpg\" alt=\"\" class=\"wp-image-1620\" srcset=\"https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5557-1024x621.jpg 1024w, https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5557-300x182.jpg 300w, https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5557-600x364.jpg 600w, https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5557-1536x932.jpg 1536w, https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5557-2048x1242.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>The iner live&#8230;&#8230;nothing special.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"486\" src=\"https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5558-1024x486.jpg\" alt=\"\" class=\"wp-image-1621\" srcset=\"https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5558-1024x486.jpg 1024w, https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5558-300x142.jpg 300w, https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5558-600x285.jpg 600w, https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5558-1536x729.jpg 1536w, https:\/\/pa3csg.nl\/wp-content\/uploads\/2021\/01\/DSC_5558-2048x972.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>Two 35W heating elements on a aluminium cooling block<\/figcaption><\/figure>\n\n\n\n<p>The code follows below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\n\/\/ John Main added dewpoint code from : http:\/\/playground.arduino.cc\/main\/DHT11Lib\n\/\/ Also added DegC output for Heat Index.\n\/\/ dewPoint function NOAA\n\/\/ reference (1) : http:\/\/wahiduddin.net\/calc\/density_algorithms.htm\n\/\/ reference (2) : http:\/\/www.colorado.edu\/geography\/weather_station\/Geog_site\/about.htm\n\/\/\n\/\/ januari 2021 Geert Stams, PA3CSG added LCD display and switching of a solid state relay to heat, preventing condensation.\n\/\/ Pin 11 switches the led on\n\/\/ Pin 12 drives the solid state realy\n\/\/\n\/\/******************************************************************************************************************************\n\/\/******************************************************************************************************************************\n\n\ndouble dewPoint(double celsius, double humidity)\n{\n  \/\/ (1) Saturation Vapor Pressure = ESGG(T)\n  double RATIO = 373.15 \/ (273.15 + celsius);\n  double RHS = -7.90298 * (RATIO - 1);\n  RHS += 5.02808 * log10(RATIO);\n  RHS += -1.3816e-7 * (pow(10, (11.344 * (1 - 1 \/ RATIO ))) - 1) ;\n  RHS += 8.1328e-3 * (pow(10, (-3.49149 * (RATIO - 1))) - 1) ;\n  RHS += log10(1013.246);\n\n  \/\/ factor -3 is to adjust units - Vapor Pressure SVP * humidity\n  double VP = pow(10, RHS - 3) * humidity;\n\n  \/\/ (2) DEWPOINT = F(Vapor Pressure)\n  double T = log(VP \/ 0.61078); \/\/ temp var\n  return (241.88 * T) \/ (17.558 - T);\n}\n\n\/\/ Example testing sketch for various DHT humidity\/temperature sensors\n\/\/ Written by ladyada, public domain\n\n#include \"DHT.h\"\n#include &lt;Wire.h> \/\/ Library for I2C communication\n#include &lt;Wire.h>  \/\/ Comes with Arduino IDE\n#include &lt;LiquidCrystal_I2C.h>\nLiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  \/\/ Set the LCD I2C address\n\n\n#define DHTPIN 2 \/\/ what pin we're connected to\n\n\/\/ Uncomment whatever type you're using!\n\/\/#define DHTTYPE DHT11 \/\/ DHT 11\n#define DHTTYPE DHT22 \/\/ DHT 22 (AM2302)\n\/\/#define DHTTYPE DHT21 \/\/ DHT 21 (AM2301)\n\n\/\/ Connect pin 1 (on the left) of the sensor to +5V\n\/\/ NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1\n\/\/ to 3.3V instead of 5V!\n\/\/ Connect pin 2 of the sensor to whatever your DHTPIN is\n\/\/ Connect pin 4 (on the right) of the sensor to GROUND\n\/\/ Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor\n\n\/\/ Initialize DHT sensor for normal 16mhz Arduino\nDHT dht(DHTPIN, DHTTYPE);\n\/\/ NOTE: For working with a faster chip, like an Arduino Due or Teensy, you\n\/\/ might need to increase the threshold for cycle counts considered a 1 or 0.\n\/\/ You can do this by passing a 3rd parameter for this threshold. It's a bit\n\/\/ of fiddling to find the right value, but in general the faster the CPU the\n\/\/ higher the value. The default for a 16mhz AVR is a value of 6. For an\n\/\/ Arduino Due that runs at 84mhz a value of 30 works.\n\/\/ Example to initialize DHT sensor for Arduino Due:\n\/\/DHT dht(DHTPIN, DHTTYPE, 30);\n\nfloat DP = 0;\nint Heatpin = 12;\nint Ledpin = 11;\n\nvoid setup() {\n  Serial.begin(9600);\n  Serial.println(\"DHTxx test!\");\n\n  dht.begin();\n  lcd.begin(16,2);   \/\/ initialize the lcd for 16 chars 2 lines, turn on backlight\n  \n}\n\nvoid loop() {\n  \/\/ Wait a few seconds between measurements.\n  delay(5000);\n  \n  \/\/ Reading temperature or humidity takes about 250 milliseconds!\n  \/\/ Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)\n  float h = dht.readHumidity();\n  \/\/ Read temperature as Celsius\n  float t = dht.readTemperature();\n  \/\/ Read temperature as Fahrenheit\n  float f = dht.readTemperature(true);\n\n \n  \/\/ Check if any reads failed and exit early (to try again).\n  if (isnan(h) || isnan(t) || isnan(f)) {\n    Serial.println(\"Failed to read from DHT sensor!\");\n    return;\n  }\n\n  \/\/ Compute heat index\n  \/\/ Must send in temp in Fahrenheit!\n  float hi = dht.computeHeatIndex(f, h);\n  float hiDegC = dht.convertFtoC(hi);\n\n  Serial.print(\"Humidity: \");\n  Serial.print(h);\n  Serial.print(\" %\\t\");\n  Serial.print(\"Temperature: \");\n  Serial.print(t);\n  Serial.print(\" *C \");\n  Serial.print(f);\n  Serial.print(\" *F\\t\");\n  Serial.print(\"Heat index: \");\n  Serial.print(hiDegC);\n  Serial.print(\" *C \");\n  Serial.print(hi);\n  Serial.print(\" *F \");\n  Serial.print(\"Dew Point (*C): \");\n  Serial.println(dewPoint(t, h));\n\n  DP=(dewPoint(t, h));\n  lcd.setCursor(0,0); \n  lcd.print(\"                \");\n  lcd.setCursor(0,0); \n  lcd.print(\"T=\");\n  lcd.setCursor(2,0);\n  lcd.print(t,0);\n  lcd.setCursor(5,0);\n  lcd.print(\"H=\");\n  lcd.setCursor(7,0);\n  lcd.print(h,0);\n  lcd.setCursor(10,0);\n  lcd.print(\"DP=\");\n  lcd.setCursor(13,0);\n  lcd.print(DP, 0);\n\n  if (t - DP &lt;= 5)\/\/ Your temp has to be >3 degrees above the dewpoint\n  {\n    digitalWrite (Heatpin, HIGH);\n    digitalWrite (Ledpin, HIGH);\n    lcd.setCursor(0,1);\n  lcd.print(\"HEATER ON \");\n  }\n    else\n    {\n      digitalWrite (Heatpin, LOW);\n      digitalWrite (Ledpin, LOW);\n       lcd.setCursor(0,1);\n  lcd.print(\"HEATER OFF\");\n  }\n  \n}<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>To put my 23cm amplifier remote at the base of the tower I needed some kind of heating to prevent condensation. A dewpoint calculation was <a class=\"mh-excerpt-more\" href=\"https:\/\/pa3csg.nl\/?page_id=1618\" title=\"Arduino Dewpoint Calculator with LCD\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":1619,"parent":0,"menu_order":9,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"categories":[29],"tags":[],"_links":{"self":[{"href":"https:\/\/pa3csg.nl\/index.php?rest_route=\/wp\/v2\/pages\/1618"}],"collection":[{"href":"https:\/\/pa3csg.nl\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/pa3csg.nl\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/pa3csg.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pa3csg.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1618"}],"version-history":[{"count":1,"href":"https:\/\/pa3csg.nl\/index.php?rest_route=\/wp\/v2\/pages\/1618\/revisions"}],"predecessor-version":[{"id":1622,"href":"https:\/\/pa3csg.nl\/index.php?rest_route=\/wp\/v2\/pages\/1618\/revisions\/1622"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pa3csg.nl\/index.php?rest_route=\/wp\/v2\/media\/1619"}],"wp:attachment":[{"href":"https:\/\/pa3csg.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pa3csg.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pa3csg.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}