{"id":93817,"date":"2025-04-12T06:51:38","date_gmt":"2025-04-12T06:51:38","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=93817"},"modified":"2025-04-12T17:51:53","modified_gmt":"2025-04-12T17:51:53","slug":"esp32-email-alert-temperature-threshold","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp32-email-alert-temperature-threshold\/","title":{"rendered":"ESP32 Email Alert Based on Temperature Threshold (change values on web server)"},"content":{"rendered":"\n<p>Learn how to send an email alert with the ESP32 based on a temperature threshold. The ESP32 also hosts a Web Server that shows the latest sensor readings and <a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-input-data-html-form\/\">input fields<\/a> to change the threshold value, email&#8217;s recipient, and the option to arm or disarm the system.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Email-Alert-Based-on-Temperature-Threshold-web-server.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Email Alert Based on Temperature Threshold change values on web server\" class=\"wp-image-93905\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Email-Alert-Based-on-Temperature-Threshold-web-server.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Email-Alert-Based-on-Temperature-Threshold-web-server.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Email-Alert-Based-on-Temperature-Threshold-web-server.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Email-Alert-Based-on-Temperature-Threshold-web-server.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntclgray\"><em>Updated 12 April 2025<\/em><\/p>\n\n\n\n<p>We&#8217;ll <a href=\"https:\/\/randomnerdtutorials.com\/esp32-ds18b20-temperature-arduino-ide\/\">read the temperature using a DS18B20 sensor<\/a> and <a href=\"https:\/\/randomnerdtutorials.com\/esp32-send-email-smtp-server-arduino-ide\/\">send emails using an SMTP Server<\/a>. The <a href=\"https:\/\/randomnerdtutorials.com\/installing-the-esp32-board-in-arduino-ide-windows-instructions\/\">ESP32 will be programmed using Arduino IDE<\/a>.<\/p>\n\n\n\n<p>To better understand how this project works, we recommend taking a look at the following tutorials:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-send-email-smtp-server-arduino-ide\/\">ESP32 Send Emails using an SMTP Server: HTML, Text and Attachments (Arduino IDE)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-input-data-html-form\/\">Input Data on HTML Form ESP32\/ESP8266 Web Server (Arduino IDE)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-thermostat-web-server\/\">ESP32\/ESP8266 Thermostat Web Server \u2013 Control Output Based on Temperature<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Watch the Video Demonstration<\/h2>\n\n\n\n<p>To see how the project works, you can watch the following video demonstration:<\/p>\n\n\n<p style=\"text-align:center\"><iframe width=\"720\" height=\"405\" src=\"https:\/\/www.youtube.com\/embed\/MEePOUVaZmI?rel=0\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Project Overview<\/h2>\n\n\n\n<p>The following image shows a high-level overview of the project we&#8217;ll build. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"861\" height=\"502\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Email-notification-with-temperature-threshold.png?resize=861%2C502&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Project Overview ESP32 Send Email with SMTP Server based on temperature threshold\" class=\"wp-image-93903\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Email-notification-with-temperature-threshold.png?w=861&amp;quality=100&amp;strip=all&amp;ssl=1 861w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Email-notification-with-temperature-threshold.png?resize=300%2C175&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Email-notification-with-temperature-threshold.png?resize=768%2C448&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 861px) 100vw, 861px\" \/><\/figure><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>The ESP32 hosts a web server that shows the latest temperature readings from a DS18B20 temperature sensor.<\/li>\n\n\n\n<li>There&#8217;s an input field to set up a threshold. When the temperature goes above or below the threshold value, you&#8217;ll receive an email.<\/li>\n\n\n\n<li>You can also set up the recipient&#8217;s email address on the web page.<\/li>\n\n\n\n<li>The system can be activated or deactivated through the web server. If you choose to deactivate the system, you won&#8217;t receive email notifications when the temperature crosses the threshold value.<\/li>\n<\/ul>\n\n\n\n<p>The following image shows an overview of the web server page.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"595\" height=\"394\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Web-Server-Set-Temperature-Threshold-Email.png?resize=595%2C394&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Temperature Threshold Email Notification Web Server\" class=\"wp-image-93889\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Web-Server-Set-Temperature-Threshold-Email.png?w=595&amp;quality=100&amp;strip=all&amp;ssl=1 595w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Web-Server-Set-Temperature-Threshold-Email.png?resize=300%2C199&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 595px) 100vw, 595px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>Make sure you check each of the following prerequisites before proceeding with this project.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. ESP32 add-on Arduino IDE<\/h3>\n\n\n\n<p>We\u2019ll program the ESP32 using Arduino IDE. So, you need to have the ESP32 add-on installed in your Arduino IDE. Follow the next tutorial, if you haven\u2019t already.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/installing-esp32-arduino-ide-2-0\/\" title=\"\">Installing the ESP32 Board in Arduino IDE (Windows, Mac OS X, Linux)<\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. ESP Mail Client Library<\/h3>\n\n\n\n<p>To send emails with the\u00a0<a aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/esp32-dev-board-wi-fi-bluetooth\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP32<\/a>, we\u2019ll we\u2019ll use the <a href=\"https:\/\/github.com\/mobizt\/ESP-Mail-Client\" target=\"_blank\" rel=\"noreferrer noopener\">ESP-Mail-Client library<\/a>. Follow the next steps to install the library.<\/p>\n\n\n\n<p>Go to <strong>Sketch <\/strong>&gt; <strong>Include Library<\/strong> &gt; <strong>Manage Libraries<\/strong> and search for <strong>ESP Mail Client<\/strong>. Install the <em>ESP Mail Client library by Mobizt<\/em>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"835\" height=\"586\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/install-esp-mail-client.png?resize=835%2C586&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Install ESP Mail Client Library Arduino IDE\" class=\"wp-image-159016\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/install-esp-mail-client.png?w=835&amp;quality=100&amp;strip=all&amp;ssl=1 835w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/install-esp-mail-client.png?resize=300%2C211&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/install-esp-mail-client.png?resize=768%2C539&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 835px) 100vw, 835px\" \/><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\">3. Create a Sender Email (New Account)<\/h3>\n\n\n\n<p>We recommend creating a new email account to send the emails to your main personal email address.\u00a0<strong>Do not use your main personal email to send emails via ESP32<\/strong>. If something goes wrong in your code or if by mistake you make too many requests, you can be banned or have your account temporarily disabled.<\/p>\n\n\n\n<p>Create a new email account for sending emails with the ESP32. If you want to use a Gmail account,\u00a0<a href=\"https:\/\/www.google.com\/gmail\/about\/\" target=\"_blank\" rel=\"noreferrer noopener\">go to this link<\/a>\u00a0to create a new one.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"940\" height=\"602\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/GMAIL-create-a-new-account.png?resize=940%2C602&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Gmail Create a new account\" class=\"wp-image-93593\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/GMAIL-create-a-new-account.png?w=940&amp;quality=100&amp;strip=all&amp;ssl=1 940w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/GMAIL-create-a-new-account.png?resize=300%2C192&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/GMAIL-create-a-new-account.png?resize=768%2C492&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\">Create an App Password<\/h3>\n\n\n\n<p>You need to create an app password so that the ESP32 is able to send emails using your Gmail account. An App Password is a 16-digit passcode that gives a less secure app or device permission to access your Google Account. <a href=\"https:\/\/support.google.com\/accounts\/answer\/185833\" target=\"_blank\" rel=\"noreferrer noopener\">Learn more about sign-in with app passwords here<\/a>.<\/p>\n\n\n\n<p>An app password can only be used with accounts that have <strong><a href=\"https:\/\/support.google.com\/accounts\/answer\/185839\">2-step verification turned on<\/a><\/strong>. <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open your&nbsp;<a href=\"https:\/\/myaccount.google.com\/\">Google Account<\/a>.<\/li>\n\n\n\n<li>In the navigation panel, select&nbsp;<strong>Security<\/strong>.<\/li>\n\n\n\n<li>Under \u201cSigning in to Google,\u201d select&nbsp;<strong>2-Step Verification<\/strong>&nbsp;&gt; <strong>Get started<\/strong>.<\/li>\n\n\n\n<li>Follow the on-screen steps.<\/li>\n<\/ol>\n\n\n\n<p>After enabling 2-step verification, you can create an app password.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open your&nbsp;<a href=\"https:\/\/myaccount.google.com\/\">Google Account<\/a>.<\/li>\n\n\n\n<li>In the search panel, search for&nbsp;<strong>App Passwords<\/strong>.<\/li>\n\n\n\n<li>Open the&nbsp;<strong>App Passwords<\/strong>&nbsp;menu.<\/li>\n<\/ol>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"491\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/app-password-menu.png?resize=750%2C491&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Google account create app password to send email with esp32\" class=\"wp-image-159018\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/app-password-menu.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/app-password-menu.png?resize=300%2C196&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<ol start=\"4\"><li>Give a name to the app password, for example ESP. Then, click on Create. It will pop-up a window with a password that you\u2019ll use with the ESP32 or ESP8266 to send emails. Save that password (even though it says you won\u2019t need to remember it) because you\u2019ll need it later.<\/li><\/ol>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"664\" height=\"587\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/create-app-password.png?resize=664%2C587&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Create app password to use with the ESP\" class=\"wp-image-159019\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/create-app-password.png?w=664&amp;quality=100&amp;strip=all&amp;ssl=1 664w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/create-app-password.png?resize=300%2C265&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 664px) 100vw, 664px\" \/><\/figure><\/div>\n\n\n<p>It will pop-up a window with a password that you\u2019ll use with the ESP32 to send emails. Save that password (even though it says you won\u2019t need to remember it) because you\u2019ll need it later.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"544\" height=\"453\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/generated-app-password.png?resize=544%2C453&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Generated app password Google Account\" class=\"wp-image-159020\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/generated-app-password.png?w=544&amp;quality=100&amp;strip=all&amp;ssl=1 544w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/generated-app-password.png?resize=300%2C250&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 544px) 100vw, 544px\" \/><\/figure><\/div>\n\n\n<p>Now, you should have an app password that you&#8217;ll use on the ESP32 code to send the emails.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"652\" height=\"282\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/app-password-created.png?resize=652%2C282&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Gmail app password created for ESP32 send emails\" class=\"wp-image-159021\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/app-password-created.png?w=652&amp;quality=100&amp;strip=all&amp;ssl=1 652w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/app-password-created.png?resize=300%2C130&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 652px) 100vw, 652px\" \/><\/figure><\/div>\n\n\n<p>If you&#8217;re using another email provider, check how to create an app password. You should be able to find the instructions with a quick google search &#8220;<strong>your_email_provider<\/strong> + create app password&#8221;.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. SMTP Server Settings<\/h3>\n\n\n\n<p>Before proceeding you need to know the SMTP server settings of the sender email. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Gmail SMTP Server Settings<\/h4>\n\n\n\n<p>If you\u2019re using a Gmail account, these are the SMTP Server details:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>SMTP Server:&nbsp;<strong>smtp.gmail.com<\/strong><\/li>\n\n\n\n<li>SMTP username: Complete Gmail address<\/li>\n\n\n\n<li>SMTP password: Your Gmail password<\/li>\n\n\n\n<li>SMTP port (TLS):&nbsp;<strong>587<\/strong><\/li>\n\n\n\n<li>SMTP port (SSL):&nbsp;<strong>465<\/strong><\/li>\n\n\n\n<li>SMTP TLS\/SSL required:&nbsp;<strong>yes<\/strong><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Outlook SMTP Server Settings<\/h4>\n\n\n\n<p>For Outlook accounts, these are the SMTP Server settings:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>SMTP Server:&nbsp;<strong>smtp.office365.com<\/strong><\/li>\n\n\n\n<li>SMTP Username: Complete Outlook email address<\/li>\n\n\n\n<li>SMTP Password: Your Outlook password<\/li>\n\n\n\n<li>SMTP Port:&nbsp;<strong>587<\/strong><\/li>\n\n\n\n<li>SMTP TLS\/SSL Required:&nbsp;<strong>Yes<\/strong><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Live or Hotmail SMTP Server Settings<\/h4>\n\n\n\n<p>For Live or Hotmail accounts, these are the SMTP Server settings:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>SMTP Server:&nbsp;<strong>smtp.live.com<\/strong><\/li>\n\n\n\n<li>SMTP Username: Complete Live\/Hotmail email address<\/li>\n\n\n\n<li>SMTP Password: Your Windows Live Hotmail password<\/li>\n\n\n\n<li>SMTP Port:&nbsp;<strong>587<\/strong><\/li>\n\n\n\n<li>SMTP TLS\/SSL Required:&nbsp;<strong>Yes<\/strong><\/li>\n<\/ul>\n\n\n\n<p>If you\u2019re using another email provider, you need to search for its SMTP Server settings.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. Async Web Server and DS18B20 Libraries<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">AsyncWebServer Libraries<\/h4>\n\n\n\n<p>In this project, we&#8217;ll build an asynchronous web server using the following libraries:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/github.com\/ESP32Async\/ESPAsyncWebServer\" title=\"\">ESPAsyncWebServer\u00a0by ESP32Async<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/ESP32Async\/AsyncTCP\" title=\"\">AsyncTCP by ESP32Async<\/a><\/li>\n<\/ul>\n\n\n\n<p>You can install these libraries in the Arduino Library Manager. Open the Library Manager by clicking the Library icon at the left sidebar.<\/p>\n\n\n\n<p>Search for <span class=\"rnthl rntliteral\">ESPAsyncWebServer<\/span> and install the <strong>ESPAsyncWebServer by ESP32Async<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"666\" height=\"586\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/Install-ESPAsyncWebServer-Library-ArduinoIDE-2-f.png?resize=666%2C586&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing ESPAsyncWebServer ESP32 Arduino IDE\" class=\"wp-image-167890\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/Install-ESPAsyncWebServer-Library-ArduinoIDE-2-f.png?w=666&amp;quality=100&amp;strip=all&amp;ssl=1 666w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/Install-ESPAsyncWebServer-Library-ArduinoIDE-2-f.png?resize=300%2C264&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 666px) 100vw, 666px\" \/><\/figure><\/div>\n\n\n<p>Then, install the AsyncTCP library. Search for <span class=\"rnthl rntliteral\">AsyncTCP<\/span> and install the <strong>AsyncTCP by ESP32Async<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"722\" height=\"586\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/Install-AsyncTCP-Library-ArduinoIDE.png?resize=722%2C586&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing AsyncTCP ESP32 Arduino IDE\" class=\"wp-image-167886\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/Install-AsyncTCP-Library-ArduinoIDE.png?w=722&amp;quality=100&amp;strip=all&amp;ssl=1 722w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/Install-AsyncTCP-Library-ArduinoIDE.png?resize=300%2C243&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 722px) 100vw, 722px\" \/><\/figure><\/div>\n\n\n<h4 class=\"wp-block-heading\">DS18B20 Libraries<\/h4>\n\n\n\n<p>For the DS18B20, we&#8217;ll use the following libraries.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a aria-label=\"Dallas Temperature library (opens in a new tab)\" href=\"https:\/\/github.com\/milesburton\/Arduino-Temperature-Control-Library\" target=\"_blank\" rel=\"noreferrer noopener\">Dallas Temperature<\/a> (<a href=\"https:\/\/randomnerdtutorials.com\/esp32-ds18b20-temperature-arduino-ide\/\">DS18B20 Guide<\/a>) <\/li>\n\n\n\n<li><a aria-label=\"One Wire library by Paul Stoffregen\u2028 (opens in a new tab)\" href=\"https:\/\/github.com\/PaulStoffregen\/OneWire\" target=\"_blank\" rel=\"noreferrer noopener\">One Wire by Paul Stoffregen<\/a> (<a href=\"https:\/\/randomnerdtutorials.com\/esp32-ds18b20-temperature-arduino-ide\/\">DS18B20 Guide<\/a>) *in the Arduino IDE, it is as &#8220;OneWire by Jim Studt, Tom Pollard, &#8230;&#8221;<\/li>\n<\/ul>\n\n\n\n<p>You can install them in the Arduino Library Manager. Go to <strong>Sketch <\/strong>> <strong>Include Library<\/strong> > <strong>Manage Libraries<\/strong>. The Library Manager should open. Then, search for the libraries&#8217; names and install them.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6. Parts Required<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/07\/ESP32-DS18B20.jpg?resize=750%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 with DS18B20 temperature sensor read\" class=\"wp-image-86678\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/07\/ESP32-DS18B20.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/07\/ESP32-DS18B20.jpg?resize=300%2C168&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>To follow this tutorial you need the following parts:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/esp32-dev-board-wi-fi-bluetooth\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP32<\/a><span style=\"font-size: inherit; background-color: initial;\">&nbsp;(read&nbsp;<\/span><a style=\"font-size: inherit; background-color: initial;\" href=\"https:\/\/makeradvisor.com\/tools\/esp32-dev-board-wi-fi-bluetooth\/\" target=\"_blank\" rel=\"noreferrer noopener\">Best ESP32 development boards<\/a><span style=\"font-size: inherit; background-color: initial;\">)<\/span><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/ds18b20-temperature-sensor-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">DS18B20 temperature sensor<\/a> (<a aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/ds18b20-digital-temperature-sensor\/\" target=\"_blank\" rel=\"noreferrer noopener\">waterproof version<\/a>) &#8211; <a href=\"https:\/\/randomnerdtutorials.com\/esp32-ds18b20-temperature-arduino-ide\/\">complete Guide<\/a><\/li>\n\n\n\n<li><a aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/ds18b20-temperature-sensor-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">4.7k Ohm resistor<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/jumper-wires-kit-120-pieces\/\" target=\"_blank\" rel=\"noreferrer noopener\">Jumper wires<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/mb-102-solderless-breadboard-830-points\/\" target=\"_blank\" rel=\"noreferrer noopener\">Breadboard<\/a><\/li>\n<\/ul>\n\n\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Schematic Diagram<\/h2>\n\n\n\n<p>Wire the DS18B20 temperature sensor to the ESP32 as shown in the following schematic diagram, with the data pin connected to <span class=\"rnthl rntcblue\">GPIO 4<\/span><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/06\/ds18b20_esp32_single_normal.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"816\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/06\/ds18b20_esp32_single_normal.png?resize=750%2C816&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Wiring Schematic diagram with DS18B20 temperature sensor to ESP32 board\" class=\"wp-image-86565\" style=\"width:470px;height:511px\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/06\/ds18b20_esp32_single_normal.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/06\/ds18b20_esp32_single_normal.png?resize=276%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 276w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/a><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">ESP32 Code &#8211; Email Web Server<\/h2>\n\n\n\n<p>Copy the following code to your Arduino IDE, but don&#8217;t upload it yet. You need to make some changes to make it work for you. You need to insert the sender&#8217;s email address, the recipient&#8217;s email address, your default threshold input, and your network credentials.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\n  Rui Santos &amp; Sara Santos - Random Nerd Tutorials\n  Complete project details at https:\/\/RandomNerdTutorials.com\/esp32-email-alert-temperature-threshold\/\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.\n  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n*********\/\n\n#include &lt;WiFi.h&gt;\n#include &lt;AsyncTCP.h&gt;\n#include &lt;ESPAsyncWebServer.h&gt;\n#include &lt;OneWire.h&gt;\n#include &lt;DallasTemperature.h&gt;\n#include &lt;ESP_Mail_Client.h&gt;\n\n\/\/ REPLACE WITH YOUR NETWORK CREDENTIALS\nconst char* ssid = &quot;REPLACE_WITH_YOUR_SSID&quot;;\nconst char* password = &quot;REPLACE_WITH_YOUR_PASSWORD&quot;;\n\n\/\/ To send Emails using Gmail on port 465 (SSL), you need to create an app password: https:\/\/support.google.com\/accounts\/answer\/185833\n#define emailSenderAccount    &quot;example_sender_account@gmail.com&quot;\n#define emailSenderPassword   &quot;email_sender_app_password&quot;\n#define smtpServer            &quot;smtp.gmail.com&quot;\n#define smtpServerPort        465\n#define emailSubject          &quot;[ALERT] ESP32 Temperature&quot;\n\n\/\/ Default Recipient Email Address\nString inputMessage = &quot;your_email_recipient@gmail.com&quot;;\nString enableEmailChecked = &quot;checked&quot;;\nString inputMessage2 = &quot;true&quot;;\n\/\/ Default Threshold Temperature Value\nString inputMessage3 = &quot;25.0&quot;;\nString lastTemperature;\n\n\/\/ HTML web page to handle 3 input fields (email_input, enable_email_input, threshold_input)\nconst char index_html[] PROGMEM = R&quot;rawliteral(\n&lt;!DOCTYPE HTML&gt;&lt;html&gt;&lt;head&gt;\n  &lt;title&gt;Email Notification with Temperature&lt;\/title&gt;\n  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;\n  &lt;\/head&gt;&lt;body&gt;\n  &lt;h2&gt;DS18B20 Temperature&lt;\/h2&gt; \n  &lt;h3&gt;%TEMPERATURE% C&lt;\/h3&gt;\n  &lt;h2&gt;ESP Email Notification&lt;\/h2&gt;\n  &lt;form action=&quot;\/get&quot;&gt;\n    Email Address &lt;input type=&quot;email&quot; name=&quot;email_input&quot; value=&quot;%EMAIL_INPUT%&quot; required&gt;&lt;br&gt;\n    Enable Email Notification &lt;input type=&quot;checkbox&quot; name=&quot;enable_email_input&quot; value=&quot;true&quot; %ENABLE_EMAIL%&gt;&lt;br&gt;\n    Temperature Threshold &lt;input type=&quot;number&quot; step=&quot;0.1&quot; name=&quot;threshold_input&quot; value=&quot;%THRESHOLD%&quot; required&gt;&lt;br&gt;\n    &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;\n  &lt;\/form&gt;\n&lt;\/body&gt;&lt;\/html&gt;)rawliteral&quot;;\n\nvoid notFound(AsyncWebServerRequest *request) {\n  request-&gt;send(404, &quot;text\/plain&quot;, &quot;Not found&quot;);\n}\n\nAsyncWebServer server(80);\n\n\/\/ Replaces placeholder with DS18B20 values\nString processor(const String&amp; var){\n  if(var == &quot;TEMPERATURE&quot;){\n    return lastTemperature;\n  }\n  else if(var == &quot;EMAIL_INPUT&quot;){\n    return inputMessage;\n  }\n  else if(var == &quot;ENABLE_EMAIL&quot;){\n    return enableEmailChecked;\n  }\n  else if(var == &quot;THRESHOLD&quot;){\n    return inputMessage3;\n  }\n  return String();\n}\n\n\/\/ Flag variable to keep track if email notification was sent or not\nbool emailSent = false;\n\nconst char* PARAM_INPUT_1 = &quot;email_input&quot;;\nconst char* PARAM_INPUT_2 = &quot;enable_email_input&quot;;\nconst char* PARAM_INPUT_3 = &quot;threshold_input&quot;;\n\n\/\/ Interval between sensor readings\nunsigned long previousMillis = 0;     \nconst long interval = 5000;    \n\n\/\/ GPIO where the DS18B20 is connected to\nconst int oneWireBus = 4;     \n\/\/ Setup a oneWire instance to communicate with any OneWire devices\nOneWire oneWire(oneWireBus);\n\/\/ Pass our oneWire reference to Dallas Temperature sensor \nDallasTemperature sensors(&amp;oneWire);\n\n\/\/ SMTP session object\nSMTPSession smtp;\n\nvoid setup() {\n  Serial.begin(115200);\n  WiFi.mode(WIFI_STA);\n  WiFi.begin(ssid, password);\n  if (WiFi.waitForConnectResult() != WL_CONNECTED) {\n    Serial.println(&quot;WiFi Failed!&quot;);\n    return;\n  }\n  Serial.println();\n  Serial.print(&quot;ESP IP Address: http:\/\/&quot;);\n  Serial.println(WiFi.localIP());\n  \n  \/\/ Start the DS18B20 sensor\n  sensors.begin();\n\n  \/\/ Send web page to client\n  server.on(&quot;\/&quot;, HTTP_GET, [](AsyncWebServerRequest *request){\n    request-&gt;send(200, &quot;text\/html&quot;, index_html, processor);\n  });\n\n  \/\/ Receive an HTTP GET request at &lt;ESP_IP&gt;\/get?email_input=&lt;inputMessage&gt;&amp;enable_email_input=&lt;inputMessage2&gt;&amp;threshold_input=&lt;inputMessage3&gt;\n  server.on(&quot;\/get&quot;, HTTP_GET, [] (AsyncWebServerRequest *request) {\n    if (request-&gt;hasParam(PARAM_INPUT_1)) {\n      inputMessage = request-&gt;getParam(PARAM_INPUT_1)-&gt;value();\n      if (request-&gt;hasParam(PARAM_INPUT_2)) {\n        inputMessage2 = request-&gt;getParam(PARAM_INPUT_2)-&gt;value();\n        enableEmailChecked = &quot;checked&quot;;\n      }\n      else {\n        inputMessage2 = &quot;false&quot;;\n        enableEmailChecked = &quot;&quot;;\n      }\n      if (request-&gt;hasParam(PARAM_INPUT_3)) {\n        inputMessage3 = request-&gt;getParam(PARAM_INPUT_3)-&gt;value();\n      }\n    }\n    else {\n      inputMessage = &quot;No message sent&quot;;\n    }\n    Serial.println(inputMessage);\n    Serial.println(inputMessage2);\n    Serial.println(inputMessage3);\n    request-&gt;send(200, &quot;text\/html&quot;, &quot;HTTP GET request sent to your ESP.&lt;br&gt;&lt;a href=\\&quot;\/\\&quot;&gt;Return to Home Page&lt;\/a&gt;&quot;);\n  });\n  server.onNotFound(notFound);\n  server.begin();\n\n  \/\/ Initialize ESP-Mail-Client\n  MailClient.networkReconnect(true);\n}\n\nvoid loop() {\n  unsigned long currentMillis = millis();\n  if (currentMillis - previousMillis &gt;= interval) {\n    previousMillis = currentMillis;\n    sensors.requestTemperatures();\n    \/\/ Temperature in Celsius degrees \n    float temperature = sensors.getTempCByIndex(0);\n    Serial.print(temperature);\n    Serial.println(&quot; *C&quot;);\n    \n    lastTemperature = String(temperature);\n    \n    \/\/ Check if temperature is above threshold and if it needs to send the Email alert\n    if(temperature &gt; inputMessage3.toFloat() &amp;&amp; inputMessage2 == &quot;true&quot; &amp;&amp; !emailSent){\n      String emailMessage = String(&quot;Temperature above threshold. Current temperature: &quot;) + \n                            String(temperature) + String(&quot;C&quot;);\n      if(sendEmailNotification(emailMessage)) {\n        Serial.println(emailMessage);\n        emailSent = true;\n      }\n      else {\n        Serial.println(&quot;Email failed to send&quot;);\n      }    \n    }\n    \/\/ Check if temperature is below threshold and if it needs to send the Email alert\n    else if((temperature &lt; inputMessage3.toFloat()) &amp;&amp; inputMessage2 == &quot;true&quot; &amp;&amp; emailSent) {\n      String emailMessage = String(&quot;Temperature below threshold. Current temperature: &quot;) + \n                            String(temperature) + String(&quot; C&quot;);\n      if(sendEmailNotification(emailMessage)) {\n        Serial.println(emailMessage);\n        emailSent = false;\n      }\n      else {\n        Serial.println(&quot;Email failed to send&quot;);\n      }\n    }\n  }\n}\n\nbool sendEmailNotification(String emailMessage) {\n  \/\/ Configure the session\n  ESP_Mail_Session session;\n  session.server.host_name = smtpServer;\n  session.server.port = smtpServerPort;\n  session.login.email = emailSenderAccount;\n  session.login.password = emailSenderPassword;\n  session.login.user_domain = &quot;&quot;;\n\n  \/\/ Configure the message\n  SMTP_Message message;\n  message.sender.name = &quot;ESP32&quot;;\n  message.sender.email = emailSenderAccount;\n  message.subject = emailSubject;\n  message.addRecipient(&quot;Recipient&quot;, inputMessage);\n  message.text.content = emailMessage.c_str();\n  message.text.charSet = &quot;utf-8&quot;;\n  message.text.transfer_encoding = Content_Transfer_Encoding::enc_7bit;\n  message.priority = esp_mail_smtp_priority::esp_mail_smtp_priority_high;\n  \/\/ Set the callback function\n  smtp.callback(smtpCallback);\n\n  \/\/ Connect to the server and send the email\n  if (!smtp.connect(&amp;session)) {\n    Serial.println(&quot;Failed to connect to SMTP server: &quot; + smtp.errorReason());\n    return false;\n  }\n\n  if (!MailClient.sendMail(&amp;smtp, &amp;message)) {\n    Serial.println(&quot;Error sending Email: &quot; + smtp.errorReason());\n    smtp.closeSession();\n    return false;\n  }\n\n  smtp.closeSession();\n  return true;\n}\n\n\/\/ Callback function for email sending status\nvoid smtpCallback(SMTP_Status status) {\n  Serial.println(status.info());\n  if (status.success()) {\n    Serial.println(&quot;Email sent successfully&quot;);\n    Serial.println(&quot;----------------&quot;);\n  }\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP32\/ESP32_Email\/ESP32_Email_Threshold_Web_Server.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How the Code Works<\/h2>\n\n\n\n<p>Continue reading to learn how the code works, or skip to the demonstration section.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Libraries<\/h3>\n\n\n\n<p>Start by importing the required libraries. The <span class=\"rnthl rntliteral\">WiFi<\/span>, <span class=\"rnthl rntliteral\">AsyncTCP<\/span> and <span class=\"rnthl rntliteral\">ESPAsyncWebServer<\/span> are required to build the web server. The <span class=\"rnthl rntliteral\">OneWire<\/span> and <span class=\"rnthl rntliteral\">DallasTemperature<\/span> are required to interface with the DS18B20 and the <span class=\"rnthl rntliteral\">ESP_Mail_Client<\/span> is required to send emails with the ESP32 via SMTP server.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;WiFi.h>\n#include &lt;AsyncTCP.h>\n#include &lt;ESPAsyncWebServer.h>\n#include &lt;OneWire.h>\n#include &lt;DallasTemperature.h>\n#include &lt;ESP_Mail_Client.h><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Network Credentials<\/h3>\n\n\n\n<p>Insert your network credentials in the following lines:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ REPLACE WITH YOUR NETWORK CREDENTIALS\nconst char* ssid = \"REPLACE_WITH_YOUR_SSID\";\nconst char* password = \"REPLACE_WITH_YOUR_PASSWORD\";<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Email Settings<\/h3>\n\n\n\n<p>Insert the sender email &#8211; this is the email that will be used to send emails by the ESP32.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define emailSenderAccount \"example_sender_account@gmail.com\"<\/code><\/pre>\n\n\n\n<p>Type the email sender&#8217;s app password (this is the APP PASSWORD you defined previously\u2014it is not the password for the email):<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define emailSenderPassword   \"email_sender_app_password\"<\/code><\/pre>\n\n\n\n<p>In the next lines, insert the email sender&#8217;s SMTP server settings. We&#8217;re using a Gmail account. If you&#8217;re using another email provider you need to insert the right server settings.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define smtpServer      \"smtp.gmail.com\"\n#define smtpServerPort  465<\/code><\/pre>\n\n\n\n<p>Insert the email subject on the following line:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define emailSubject \"&#091;ALERT] ESP32 Temperature\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Auxiliary Variables<\/h3>\n\n\n\n<p>Next, we have some auxiliary variables to save the values submitted through the form. The inputMessage variable holds the recipient&#8217;s email. You can insert the default recipient&#8217;s email. You can change the recipient&#8217;s email later on the form.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>String inputMessage = \"your_email_recipient@gmail.com\";<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">enableEmailChecked<\/span> variable will tell us whether the checkbox to send an email is checked or not.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>String enableEmailChecked = \"checked\";<\/code><\/pre>\n\n\n\n<p>In case it&#8217;s checked, the value saved on the <span class=\"rnthl rntliteral\">inputMessage2<\/span> should be set to <span class=\"rnthl rntliteral\">true<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>String inputMessage2 = \"true\";<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">inputMessage3<\/span> holds the temperature threshold value. By default, it is set to 25.0\u00baC, but you can set it to any other default value that makes for your project. You can also change it later in the HTML form.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>String inputMessage3 = \"25.0\";<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">lastTemperature<\/span> variable saves the last temperature value to compare with the current value.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>String lastTemperature;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">HTML Text<\/h3>\n\n\n\n<p>Then, we have some basic HTML text to build a page with three input fields: the recipient&#8217;s email, a checkbox to enable or disable email notifications and the temperature threshold input field. The web page also displays the latest temperature reading from the DS18B20 temperature sensor.<\/p>\n\n\n\n<p>The following lines display the temperature:<\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>&lt;h2&gt;DS18B20 Temperature&lt;\/h2&gt; \n&lt;h3&gt;%TEMPERATURE% &amp;deg;C&lt;\/h3&gt;<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">%TEMPERATURE%<\/span> is placeholder that will be replaced by the actual temperature value when the ESP32 serves the page.<\/p>\n\n\n\n<p>Then, we have a form with three input fields and a &#8220;Submit&#8221; button. When the user types some data and clicks the \u201cSubmit\u201d button, those values are sent to the ESP32 to update the variables.<\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>&lt;form action=\"\/get\"&gt;\n  Email Address &lt;input type=\"email\" name=\"email_input\" value=\"%EMAIL_INPUT%\" required&gt;&lt;br&gt;\n  Enable Email Notification &lt;input type=\"checkbox\" name=\"enable_email_input\" value=\"true\" %ENABLE_EMAIL%&gt;&lt;br&gt;\n  Temperature Threshold &lt;input type=\"number\" step=\"0.1\" name=\"threshold_input\" value=\"%THRESHOLD%\" required&gt;&lt;br&gt;\n  &lt;input type=\"submit\" value=\"Submit\"&gt;\n&lt;\/form&gt;<\/code><\/pre>\n\n\n\n<p>The first input field is of type <span class=\"rnthl rntliteral\">email<\/span>, the second input field is a <span class=\"rnthl rntliteral\">checkbox<\/span> and the last input field is of type <span class=\"rnthl rntliteral\">number<\/span>. To learn more about input fields, we recommend taking a look at following resources of the w3schools website:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a aria-label=\"HTML <Input> Tag\u2028 (opens in a new tab)&#8221; href=&#8221;https:\/\/www.w3schools.com\/tags\/tag_input.asp&#8221; target=&#8221;_blank&#8221; rel=&#8221;noreferrer noopener nofollow&#8221;>HTML Input Tag<\/a><\/li>\n\n\n\n<li><a aria-label=\"HTML Input Types (opens in a new tab)\" href=\"https:\/\/www.w3schools.com\/html\/html_form_input_types.asp\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">HTML Input Types<\/a><\/li>\n<\/ul>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">action<\/span> attribute of the form specifies where to send the data inserted on the form after pressing submit. In this case, it makes an HTTP GET request to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/get?email_input=value&amp;enable_email_input=value&amp;threshold_input=value<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">value<\/span> refers to the text you enter in each of the input fields. To learn more about handling input fields with the ESP32, read: <a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-input-data-html-form\/\">Input Data on HTML Form ESP32 Web Server using Arduino IDE<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">processor()<\/h3>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">processor()<\/span> function replaces all placeholders in the HTML text with the actual values.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span class=\"rnthl rntliteral\">%TEMPERATURE%<\/span> \u00bb <span class=\"rnthl rntliteral\">lastTemperature<\/span><\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">%EMAIL_INPUT%<\/span> \u00bb <span class=\"rnthl rntliteral\">inputMessage<\/span><\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">%ENABLE_EMAIL%<\/span> \u00bb <span class=\"rnthl rntliteral\">enableEmailChecked<\/span><\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">%THRESHOLD%<\/span> \u00bb <span class=\"rnthl rntliteral\">inputMessage3<\/span><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>String processor(const String&amp; var){\n  \/\/Serial.println(var);\n  if(var == \"TEMPERATURE\"){\n    return lastTemperature;\n  }\n  else if(var == \"EMAIL_INPUT\"){\n    return inputMessage;\n  }\n  else if(var == \"ENABLE_EMAIL\"){\n    return enableEmailChecked;\n  }\n  else if(var == \"THRESHOLD\"){\n    return inputMessage3;\n  }\n  return String();\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Input Field Parameters<\/h3>\n\n\n\n<p>The following variables will be used to check whether we&#8217;ve received an HTTP GET request from those input fields and save the values into variables accordingly.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const char* PARAM_INPUT_1 = \"email_input\";\nconst char* PARAM_INPUT_2 = \"enable_email_input\";\nconst char* PARAM_INPUT_3 = \"threshold_input\";<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">DS18B20 Temperature Sensor Init<\/h3>\n\n\n\n<p>Initialize the DS18B20 temperature sensor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ GPIO where the DS18B20 is connected to\nconst int oneWireBus = 4;\n\/\/ Setup a oneWire instance to communicate with any OneWire devices\nOneWire oneWire(oneWireBus);\n\/\/ Pass our oneWire reference to Dallas Temperature sensor \nDallasTemperature sensors(&amp;oneWire);<\/code><\/pre>\n\n\n\n<p>To learn more about interfacing the DS18B20 temperature sensor with the ESP32, read: <a href=\"https:\/\/randomnerdtutorials.com\/esp32-ds18b20-temperature-arduino-ide\/\">ESP32 DS18B20 Temperature Sensor with Arduino IDE<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">SMTPSession Object<\/h3>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">smtpSession<\/span> object contains configurations and data to be sent via email. These configurations are set later on the <span class=\"rnthl rntliteral\">sendEmailNotification()<\/span> function.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>SMTPSession smtp;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">setup()<\/h3>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span>, connect to Wi-Fi in station mode and print the ESP32 IP address:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.begin(115200);\nWiFi.mode(WIFI_STA);\nWiFi.begin(ssid, password);\nif (WiFi.waitForConnectResult() != WL_CONNECTED) {\n  Serial.println(\"WiFi Failed!\");\n  return;\n}\nSerial.println();\nSerial.print(\"ESP IP Address: http:\/\/\");\nSerial.println(WiFi.localIP());<\/code><\/pre>\n\n\n\n<p>Initialize the DS18B20 temperature sensor:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>sensors.begin();<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Handle Web Server<\/h3>\n\n\n\n<p>Then, define what happens when the ESP32 receives HTTP requests. When we get a request on the root \/ url, send the HTML text with the processor (so that the placeholders are replaced with the latest values).<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>server.on(\"\/\", HTTP_GET, &#091;](AsyncWebServerRequest *request){\n  request-&gt;send_P(200, \"text\/html\", index_html, processor);\n});<\/code><\/pre>\n\n\n\n<p>When a form is submitted, the ESP32 receives a request on the following URL:<\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>&lt;ESP_IP&gt;\/get?email_input=&lt;inputMessage&gt;&amp;enable_email_input=&lt;inputMessage2&gt;&amp;threshold_input=&lt;inputMessage3&gt;<\/code><\/pre>\n\n\n\n<p>So, we check whether the request contains input parameters, and save those parameters into variables:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>server.on(\"\/get\", HTTP_GET, &#091;] (AsyncWebServerRequest *request) {\n  \/\/ GET email_input value on &lt;ESP_IP&gt;\/get?email_input=&lt;inputMessage&gt;\n  if (request-&gt;hasParam(PARAM_INPUT_1)) {\n    inputMessage = request-&gt;getParam(PARAM_INPUT_1)-&gt;value();\n    \/\/ GET enable_email_input value on &lt;ESP_IP&gt;\/get?enable_email_input=&lt;inputMessage2&gt;\n    if (request-&gt;hasParam(PARAM_INPUT_2)) {\n      inputMessage2 = request-&gt;getParam(PARAM_INPUT_2)-&gt;value();\n      enableEmailChecked = \"checked\";\n    }\n    else {\n      inputMessage2 = \"false\";\n      enableEmailChecked = \"\";\n    }\n    \/\/ GET threshold_input value on &lt;ESP_IP&gt;\/get?threshold_input=&lt;inputMessage3&gt;\n    if (request-&gt;hasParam(PARAM_INPUT_3)) {\n      inputMessage3 = request-&gt;getParam(PARAM_INPUT_3)-&gt;value();\n    }\n  }\n  else {\n    inputMessage = \"No message sent\";\n  }<\/code><\/pre>\n\n\n\n<p>This is the part of the code where the variables will be replaced with the values submitted on the form. The <span class=\"rnthl rntliteral\">inputMessage<\/span> variable saves the recipient&#8217;s email address, the <span class=\"rnthl rntliteral\">inputMessage2<\/span> saves whether the email notification system is enabled or not and the <span class=\"rnthl rntliteral\">inputMessage3<\/span> saves the temperature threshold.<\/p>\n\n\n\n<p>After submitting the values on the form, it displays a new page saying the request was successfully sent to the ESP32 with a link to return to the homepage.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>request-&gt;send(200, \"text\/html\", \"HTTP GET request sent to your ESP.&lt;br&gt;&lt;a href=\\\"\/\\\"&gt;Return to Home Page&lt;\/a&gt;\");\n});<\/code><\/pre>\n\n\n\n<p>Finally, start the server:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>server.begin();<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">loop()<\/h3>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">loop()<\/span>, we use <a href=\"https:\/\/randomnerdtutorials.com\/esp32-pir-motion-sensor-interrupts-timers\/\">timers<\/a> to get new temperature readings every 5 seconds.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>unsigned long currentMillis = millis();\nif (currentMillis - previousMillis &gt;= interval) {\n  previousMillis = currentMillis;\n  sensors.requestTemperatures();\n  \/\/ Temperature in Celsius degrees \n  float temperature = sensors.getTempCByIndex(0);\n  Serial.print(temperature);\n  Serial.println(\" *C\");\n    \n  \/\/ Temperature in Fahrenheit degrees\n  \/*float temperature = sensors.getTempFByIndex(0);\n  SerialMon.print(temperature);\n  SerialMon.println(\" *F\");*\/\n    \n  lastTemperature = String(temperature);<\/code><\/pre>\n\n\n\n<p>After getting a new temperature reading, we check whether it is above or below the threshold and send an email if necessary.<\/p>\n\n\n\n<p>You&#8217;ll send an email alert if all these conditions are met:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The current temperature is above the threshold;<\/li>\n\n\n\n<li>Email notifications are enabled (the checkbox is ticked on the web page);<\/li>\n\n\n\n<li>If an email hasn&#8217;t been sent yet.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if(temperature &gt; inputMessage3.toFloat() &amp;&amp; inputMessage2 == \"true\" &amp;&amp; !emailSent){\n  String emailMessage = String(\"Temperature above threshold. Current temperature: \") + \n                        String(temperature) + String(\"C\");\n  if(sendEmailNotification(emailMessage)) {\n    Serial.println(emailMessage);\n    emailSent = true;\n  }\n  else {\n    Serial.println(\"Email failed to send\");\n  }    \n}<\/code><\/pre>\n\n\n\n<p>The email contains a message saying the temperature is above the threshold and the current temperature.<\/p>\n\n\n\n<p>Then, if the temperature goes below the threshold, send another email.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>else if((temperature &lt; inputMessage3.toFloat()) &amp;&amp; inputMessage2 == \"true\" &amp;&amp; emailSent) {\n  String emailMessage = String(\"Temperature below threshold. Current temperature: \") \n                        + String(temperature) + String(\" C\");\n  if(sendEmailNotification(emailMessage)) {\n    Serial.println(emailMessage);\n    emailSent = false;\n  }\n  else {\n    Serial.println(\"Email failed to send\");\n  }\n}<\/code><\/pre>\n\n\n\n<p>To send emails, we&#8217;ve created the <span class=\"rnthl rntliteral\">sendEmailNotification()<\/span> function that contains all the details to send the email. This function returns <span class=\"rnthl rntliteral\">true<\/span> if the email was successfully sent, or <span class=\"rnthl rntliteral\">false<\/span> if it failed.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>bool sendEmailNotification(String emailMessage) {\n  \/\/ Configure the session\n  ESP_Mail_Session session;\n  session.server.host_name = smtpServer;\n  session.server.port = smtpServerPort;\n  session.login.email = emailSenderAccount;\n  session.login.password = emailSenderPassword;\n  session.login.user_domain = \"\";\n\n  \/\/ Configure the message\n  SMTP_Message message;\n  message.sender.name = \"ESP32\";\n  message.sender.email = emailSenderAccount;\n  message.subject = emailSubject;\n  message.addRecipient(\"Recipient\", inputMessage);\n  message.text.content = emailMessage.c_str();\n  message.text.charSet = \"utf-8\";\n  message.text.transfer_encoding = Content_Transfer_Encoding::enc_7bit;\n  message.priority = esp_mail_smtp_priority::esp_mail_smtp_priority_high;\n  \/\/ Set the callback function\n  smtp.callback(smtpCallback);\n\n  \/\/ Connect to the server and send the email\n  if (!smtp.connect(&amp;session)) {\n    Serial.println(\"Failed to connect to SMTP server: \" + smtp.errorReason());\n    return false;\n  }\n\n  if (!MailClient.sendMail(&amp;smtp, &amp;message)) {\n    Serial.println(\"Error sending Email: \" + smtp.errorReason());\n    smtp.closeSession();\n    return false;\n  }\n\n  smtp.closeSession();\n  return true;\n}<\/code><\/pre>\n\n\n\n<p>To learn more about sending emails via SMTP Server with the ESP32, read: <a href=\"https:\/\/randomnerdtutorials.com\/esp32-send-email-smtp-server-arduino-ide\/\">ESP32 Send Emails using an SMTP Server<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Demonstration<\/h2>\n\n\n\n<p>Upload the code to your ESP32 board (with the DS18B20 wired to your ESP32 board).<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Web-Server-Set-Temperature-Threshold-Receive-Email-Alert-1.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Web Server Temperature Threshold Triggered Received Email Alert\" class=\"wp-image-93900\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Web-Server-Set-Temperature-Threshold-Receive-Email-Alert-1.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Web-Server-Set-Temperature-Threshold-Receive-Email-Alert-1.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>Open the Serial Monitor at a baud rate of 115200 and press the on-board RST button. The ESP32 will print its IP address and it will start displaying new temperature values every 5 seconds.<\/p>\n\n\n\n<p>Open a browser and type the ESP32 IP address. A similar web page should load with the default values (defined in your code):<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"595\" height=\"394\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Web-Server-Set-Temperature-Threshold-Email.png?resize=595%2C394&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Email Notification Web Server Values temperature, email recipient, threshold \" class=\"wp-image-93889\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Web-Server-Set-Temperature-Threshold-Email.png?w=595&amp;quality=100&amp;strip=all&amp;ssl=1 595w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Web-Server-Set-Temperature-Threshold-Email.png?resize=300%2C199&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 595px) 100vw, 595px\" \/><\/figure><\/div>\n\n\n<p>If the email notifications are enabled (checkbox checked) and if the temperature goes above the threshold, you&#8217;ll receive an email notification.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"781\" height=\"358\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-send-email-temperature-threshold.png?resize=781%2C358&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Send Email Notifications when temperature above threshold- Serial Monitor\" class=\"wp-image-168888\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-send-email-temperature-threshold.png?w=781&amp;quality=100&amp;strip=all&amp;ssl=1 781w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-send-email-temperature-threshold.png?resize=300%2C138&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-send-email-temperature-threshold.png?resize=768%2C352&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 781px) 100vw, 781px\" \/><\/figure><\/div>\n\n\n<p>After that, when the temperature goes below the threshold, you&#8217;ll receive another email.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"641\" height=\"320\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Email-Alert-Notification-Temperature-Reached-above-below-threshold.png?resize=641%2C320&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Email Alert Notification Temperature Reached above below threshold\" class=\"wp-image-93897\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Email-Alert-Notification-Temperature-Reached-above-below-threshold.png?w=641&amp;quality=100&amp;strip=all&amp;ssl=1 641w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Email-Alert-Notification-Temperature-Reached-above-below-threshold.png?resize=300%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 641px) 100vw, 641px\" \/><\/figure><\/div>\n\n\n<p>You can use the web page input fields to set up a different recipient&#8217;s email address, enable or disable email notifications, and change the threshold value. For any changes to take effect, you just need to press the &#8220;Submit&#8221; button.<\/p>\n\n\n\n<p>At the same time, you should get the new input fields in the Serial Monitor.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this project, you&#8217;ve learned how to set a threshold value and send an email notification when the temperature crosses that value. We hope you&#8217;ve found this project interesting. Now, feel free to modify it to meet your own needs. For, example, when the temperature crosses the threshold, you may also want to trigger an output to <a href=\"https:\/\/randomnerdtutorials.com\/esp32-relay-module-ac-web-server\/\">control a relay<\/a>.<\/p>\n\n\n\n<p>In this project, we&#8217;ve used raw HTML text, to make the project easier to follow. We suggest adding some CSS to style your web page to make it look nicer.<\/p>\n\n\n\n<p>Instead of using a DS18B20, you might consider using a different temperature sensor: <a href=\"https:\/\/randomnerdtutorials.com\/dht11-vs-dht22-vs-lm35-vs-ds18b20-vs-bme280-vs-bmp180\/\">DHT vs LM35 vs DS18B20 vs BME280 vs BMP180<\/a>.<\/p>\n\n\n\n<p>If you want to learn more about the ESP32, try our projects and resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/learn-esp32-with-arduino-ide\/\">Learn ESP32 with Arduino IDE (eBook)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/build-web-servers-esp32-esp8266-ebook\/\" title=\"\">Build Web Servers with ESP32 and ESP8266<\/a><\/li>\n\n\n\n<li><strong><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp32\/\">All our ESP32 Projects and Guides<\/a><\/strong><\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to send an email alert with the ESP32 based on a temperature threshold. The ESP32 also hosts a Web Server that shows the latest sensor readings and input &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP32 Email Alert Based on Temperature Threshold (change values on web server)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp32-email-alert-temperature-threshold\/#more-93817\" aria-label=\"Read more about ESP32 Email Alert Based on Temperature Threshold (change values on web server)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":93905,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[281,276,277,299,264],"tags":[],"class_list":["post-93817","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32-project","category-esp32","category-esp32-arduino-ide","category-0-esp32","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP32-Email-Alert-Based-on-Temperature-Threshold-web-server.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/93817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=93817"}],"version-history":[{"count":4,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/93817\/revisions"}],"predecessor-version":[{"id":168889,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/93817\/revisions\/168889"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/93905"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=93817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=93817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=93817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}