{"id":106963,"date":"2021-10-21T13:42:34","date_gmt":"2021-10-21T13:42:34","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=106963"},"modified":"2021-11-02T15:03:04","modified_gmt":"2021-11-02T15:03:04","slug":"esp8266-nodemcu-door-status-telegram","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp8266-nodemcu-door-status-telegram\/","title":{"rendered":"ESP8266 NodeMCU Door Status Monitor with Telegram Notifications"},"content":{"rendered":"\n<p>In this project,&nbsp;you&#8217;re going to monitor the status of a&nbsp;door using an&nbsp;ESP8266 NodeMCU board and a magnetic reed switch. You&#8217;ll receive a message in your Telegram account whenever the door changes state: opened or closed. As long as you have access to the internet on your smartphone, you&#8217;ll be notified no matter where you are.&nbsp;The ESP8266 board will be programmed using Arduino IDE.<\/p>\n\n\n\n<div class=\"wp-block-image\"><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\/2021\/09\/ESP8266-Door-status-monitor-Telegram-thumbnail.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 NodeMCU Door Status Monitor with Telegram Notifications Arduino IDE\" class=\"wp-image-106965\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/ESP8266-Door-status-monitor-Telegram-thumbnail.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/ESP8266-Door-status-monitor-Telegram-thumbnail.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/ESP8266-Door-status-monitor-Telegram-thumbnail.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/ESP8266-Door-status-monitor-Telegram-thumbnail.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\n<p>We have a similar tutorial that sends emails instead of Telegram messages:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/randomnerdtutorials.com\/door-status-monitor-using-the-esp8266\/\">ESP8266 NodeMCU Door Status Monitor with Email Notifications (IFTTT)<\/a><\/li><\/ul>\n\n\n\n<p>Read the ESP32 Guide: <a href=\"https:\/\/randomnerdtutorials.com\/esp32-door-status-telegram\/\">Door Status Monitor with Telegram Notifications<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Project Overview<\/h2>\n\n\n\n<p>In this project, we&#8217;ll create a Telegram Bot that will send messages to your Telegram account whenever a door changes state. To detect the change, we&#8217;ll use a magnetic contact switch. <\/p>\n\n\n\n<p>A magnetic contact switch is basically a reed switch encased in a plastic shell so that you can easily apply it to a door, a window, or a drawer to detect if it is open or closed.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/reed-switch-door-status-monitor-sensor.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"magnetic contact switch reed switch\" class=\"wp-image-106893\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/reed-switch-door-status-monitor-sensor.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/reed-switch-door-status-monitor-sensor.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\n<p>The electrical circuit is closed when a magnet is near the switch\u2014door closed. When the magnet is far away from the switch\u2014door open\u2014the circuit is open. See the figure below.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/i2.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/02\/magnetic_reed_switch_howitworks.png?resize=665%2C374&amp;quality=100&amp;strip=all&amp;ssl=1\" alt=\"magnetic reed switch how i tworks\" class=\"wp-image-17317\"\/><\/figure><\/div>\n\n\n\n<p>We can connect the reed switch to an ESP8266 GPIO to detect changes in its state.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introducing Telegram<\/h2>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/telegram.org\/\" target=\"_blank\">Telegram<\/a> Messenger is a cloud-based instant messaging and voice over IP service. You can easily install it on your smartphone (Android and iPhone) or computer (PC, Mac, and Linux). It is free and without any ads. Telegram allows you to create bots that you can interact with.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/telegram-logo.png?resize=150%2C150&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Telegram logo\" class=\"wp-image-106943\"\/><\/figure><\/div>\n\n\n\n<p>&#8220;<em>Bots are third-party applications that run inside Telegram. Users can interact with bots by sending them messages, commands, and&nbsp;inline requests. You control your bots using HTTPS requests to Telegram Bot API<\/em>&#8220;.<\/p>\n\n\n\n<p>The ESP8266 will interact with the Telegram bot to send messages to your Telegram account. Whenever the door changes state, you&#8217;ll receive a notification on your smartphone (as long as you have access to the internet).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"telegram-bot\">Creating a Telegram Bot<\/h2>\n\n\n\n<p>Go to Google Play or App Store, download, and install <strong>Telegram<\/strong>.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"354\" height=\"269\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Install-Telegram.png?resize=354%2C269&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Install and Download Telegram\" class=\"wp-image-97821\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Install-Telegram.png?w=354&amp;quality=100&amp;strip=all&amp;ssl=1 354w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Install-Telegram.png?resize=300%2C228&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 354px) 100vw, 354px\" \/><\/figure><\/div>\n\n\n\n<p>Open Telegram and follow the next steps to create a Telegram Bot. First, search for &#8220;<strong>botfather<\/strong>&#8221; and click the BotFather as shown below. Or open this link <a href=\"http:\/\/t.me\/botfather\" target=\"_blank\" rel=\"noreferrer noopener\">t.me\/botfather<\/a> on your smartphone.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"362\" height=\"198\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Telegram-Botfather.png?resize=362%2C198&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"botfather\" class=\"wp-image-97822\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Telegram-Botfather.png?w=362&amp;quality=100&amp;strip=all&amp;ssl=1 362w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Telegram-Botfather.png?resize=300%2C164&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 362px) 100vw, 362px\" \/><\/figure><\/div>\n\n\n\n<p>The following window should open, and you&#8217;ll be prompted to click the <strong>start<\/strong> button.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"352\" height=\"708\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/start-bot-father-telegram.png?resize=352%2C708&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Telegram Start BotFather to Create a new Bot\" class=\"wp-image-97824\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/start-bot-father-telegram.png?w=352&amp;quality=100&amp;strip=all&amp;ssl=1 352w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/start-bot-father-telegram.png?resize=149%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 149w\" sizes=\"(max-width: 352px) 100vw, 352px\" \/><\/figure><\/div>\n\n\n\n<p>Type <strong>\/newbot<\/strong> and follow the instructions to create your bot. Give it a name and username. Mine is called <span class=\"rnthl rntliteral\">Door Sensor<\/span>, and the username is <span class=\"rnthl rntliteral\">ESPDoorSensorBot<\/span>.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"354\" height=\"396\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Create-bot-Telegram-Botfather_f.png?resize=354%2C396&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Telegram BotFather Create a New Bot\" class=\"wp-image-97826\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Create-bot-Telegram-Botfather_f.png?w=354&amp;quality=100&amp;strip=all&amp;ssl=1 354w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Create-bot-Telegram-Botfather_f.png?resize=268%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 268w\" sizes=\"(max-width: 354px) 100vw, 354px\" \/><\/figure><\/div>\n\n\n\n<p>If your bot is successfully created, you&#8217;ll receive a message with a link to access the bot and the <strong>bot token<\/strong>. Save the bot token because you&#8217;ll need it so that the ESP8266 can interact with the bot.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"356\" height=\"537\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Bot-Token-Telegram-Bot-Father.png?resize=356%2C537&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Telegram BotFather Get Bot Token\" class=\"wp-image-97827\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Bot-Token-Telegram-Bot-Father.png?w=356&amp;quality=100&amp;strip=all&amp;ssl=1 356w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Bot-Token-Telegram-Bot-Father.png?resize=199%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 199w\" sizes=\"(max-width: 356px) 100vw, 356px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Sending a Message to the Bot<\/h2>\n\n\n\n<p class=\"rntbox rntcred\">This step is very important. Don&#8217;t miss it. Otherwise, the project will not work.<\/p>\n\n\n\n<p>You must send a message to your Telegram Bot from your Telegram account before it can send you messages.<\/p>\n\n\n\n<p><strong>1)<\/strong> Go back to the chats tab, and in the search field, type the username of your bot.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"607\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/Search-for-your-bot.png?resize=300%2C607&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Telegram searching for ESP32 bot\" class=\"wp-image-106944\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/Search-for-your-bot.png?w=300&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/Search-for-your-bot.png?resize=148%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 148w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/figure><\/div>\n\n\n\n<p><strong>2)<\/strong> Select your bot to start a conversation.<\/p>\n\n\n\n<p><strong>3)<\/strong> Click on the Start link.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"610\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/start-bot-conversation.jpg?resize=300%2C610&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Star conversation with Telegram Bot\" class=\"wp-image-106945\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/start-bot-conversation.jpg?w=300&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/start-bot-conversation.jpg?resize=148%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 148w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/figure><\/div>\n\n\n\n<p>And that&#8217;s it! You can proceed to the next section.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"user-id\">Get Your Telegram User ID<\/h2>\n\n\n\n<p>To send a message to your Telegram account, the bot needs to know your user ID.<\/p>\n\n\n\n<p>In your Telegram account, search for &#8220;<strong>myidbot<\/strong>&#8221; or open this link <a href=\"http:\/\/t.me\/myidbot\" target=\"_blank\" rel=\"noreferrer noopener\">t.me\/myidbot<\/a> on your smartphone.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"348\" height=\"173\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Telegram-ID-Bot.png?resize=348%2C173&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Telegram Get Chat ID with IDBot\" class=\"wp-image-97830\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Telegram-ID-Bot.png?w=348&amp;quality=100&amp;strip=all&amp;ssl=1 348w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Telegram-ID-Bot.png?resize=300%2C149&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 348px) 100vw, 348px\" \/><\/figure><\/div>\n\n\n\n<p>Start a conversation with that bot and type <strong>\/getid<\/strong>. You will get a reply back with your user ID. Save that <strong>user ID<\/strong>, because you&#8217;ll need it later in this tutorial.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"354\" height=\"500\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Telegram-Get-Chat-ID.png?resize=354%2C500&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Telegram Get Chat ID with IDBot getid\" class=\"wp-image-97836\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Telegram-Get-Chat-ID.png?w=354&amp;quality=100&amp;strip=all&amp;ssl=1 354w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Telegram-Get-Chat-ID.png?resize=212%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 212w\" sizes=\"(max-width: 354px) 100vw, 354px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Preparing Arduino IDE<\/h2>\n\n\n\n<p>We&#8217;ll program the&nbsp;<a href=\"https:\/\/makeradvisor.com\/best-esp8266-wi-fi-development-board\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP8266<\/a> board using Arduino IDE, so make sure you have it installed in your Arduino IDE.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/randomnerdtutorials.com\/how-to-install-esp8266-board-arduino-ide\/\">Installing ESP8266 Board in Arduino IDE (Windows, Mac OS X, Linux)<\/a><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Universal Telegram Bot Library<\/h3>\n\n\n\n<p>To interact with the Telegram bot, we&#8217;ll use the <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/witnessmenow\/Universal-Arduino-Telegram-Bot\" target=\"_blank\">Universal Telegram Bot Library<\/a> created by Brian Lough that provides an easy interface for the Telegram Bot API.<\/p>\n\n\n\n<p>Follow the next steps to install the latest release of the library.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/witnessmenow\/Universal-Arduino-Telegram-Bot\/archive\/master.zip\" target=\"_blank\">Click here to download the Universal Arduino Telegram Bot library<\/a>.<\/li><li>Go to <strong>Sketch <\/strong>&gt; <strong>Include Library<\/strong> &gt; <strong>Add.ZIP Library..<\/strong>.<\/li><li>Add the library you&#8217;ve just downloaded.<\/li><\/ol>\n\n\n\n<p><strong>Important: <\/strong> don&#8217;t install the library through the Arduino Library Manager because it might install a deprecated version.<\/p>\n\n\n\n<p>For all the details about the library, take a look at the <a href=\"https:\/\/github.com\/witnessmenow\/Universal-Arduino-Telegram-Bot\" target=\"_blank\" rel=\"noreferrer noopener\">Universal Arduino Telegram Bot Library GitHub page<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">ArduinoJson Library<\/h3>\n\n\n\n<p>You also have to install the <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/bblanchon\/ArduinoJson\" target=\"_blank\">ArduinoJson<\/a> library. Follow the next steps to install the library.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Go to <strong>Skech <\/strong>&gt; <strong>Include Library<\/strong> &gt; <strong>Manage Libraries<\/strong>.<\/li><li>Search for &#8220;ArduinoJson&#8221;.<\/li><li>Install the library.<\/li><\/ol>\n\n\n\n<p>We&#8217;re using ArduinoJson library version 6.15.2.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"786\" height=\"443\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Install-ArduinoJson-Library.png?resize=786%2C443&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Install in Arduino IDE the ArduinoJSON library\" class=\"wp-image-97837\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Install-ArduinoJson-Library.png?w=786&amp;quality=100&amp;strip=all&amp;ssl=1 786w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Install-ArduinoJson-Library.png?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/06\/Install-ArduinoJson-Library.png?resize=768%2C433&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Parts Required<\/h2>\n\n\n\n<p>Here&#8217;s the hardware that you need to complete&nbsp;this project:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/makeradvisor.com\/tools\/esp8266-esp-12e-nodemcu-wi-fi-development-board\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP8266<\/a> &#8211; read <a href=\"https:\/\/makeradvisor.com\/best-esp8266-wi-fi-development-board\/\" target=\"_blank\" rel=\"noreferrer noopener\">Best ESP8266 Development Boards<\/a><\/li><li><a href=\"https:\/\/makeradvisor.com\/tools\/magnetic-reed-switch\/\" target=\"_blank\" rel=\"noreferrer noopener\">1\u00d7 Magnetic Reed Switch&nbsp;<\/a><\/li><li><a href=\"https:\/\/makeradvisor.com\/tools\/resistors-kits\/\" target=\"_blank\" rel=\"noreferrer noopener\">1\u00d7 10k\u03a9 resistor<\/a><\/li><li><a href=\"https:\/\/makeradvisor.com\/tools\/mb-102-solderless-breadboard-830-points\/\" target=\"_blank\" rel=\"noreferrer noopener\">1\u00d7 breadboard<\/a><\/li><li><a href=\"https:\/\/makeradvisor.com\/tools\/jumper-wires-kit-120-pieces\/\" target=\"_blank\" rel=\"noreferrer noopener\">Jumper wires<\/a><\/li><\/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 \u2013 ESP8266 with Reed Switch<\/h2>\n\n\n\n<p>We wired the reed switch to <span class=\"rnthl rntcgreen\">GPIO 4<\/span> (D2), but you can connect it to any suitable GPIO.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"558\" height=\"444\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/ESP8266-Reed-Switch-door-sensor-circuit.png?resize=558%2C444&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Schematic Wiring Diagram ESP8266 with Reed Switch\" class=\"wp-image-106876\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/ESP8266-Reed-Switch-door-sensor-circuit.png?w=558&amp;quality=100&amp;strip=all&amp;ssl=1 558w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/ESP8266-Reed-Switch-door-sensor-circuit.png?resize=300%2C239&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 558px) 100vw, 558px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Code<\/h2>\n\n\n\n<p>Copy the sketch below to your Arduino IDE. Replace the SSID, password, BOT token, and user ID with your 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\/esp8266-nodemcu-door-status-telegram\/\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;ESP8266WiFi.h&gt;\n#include &lt;WiFiClientSecure.h&gt;\n#include &lt;UniversalTelegramBot.h&gt;\n#include &lt;ArduinoJson.h&gt;\n\n\/\/ Set GPIOs for LED and reedswitch\nconst int reedSwitch = 4;\nconst int led = 2; \/\/optional\n\n\/\/ Detects whenever the door changed state\nbool changeState = false;\n\n\/\/ Holds reedswitch state (1=opened, 0=close)\nbool state;\nString doorState;\n\n\/\/ Auxiliary variables (it will only detect changes that are 1500 milliseconds apart)\nunsigned long previousMillis = 0; \nconst long interval = 1500;\n\nconst char* ssid = &quot;REPLACE_WITH_YOUR_SSID&quot;;\nconst char* password = &quot;REPLACE_WITH_YOUR_PASSWORD&quot;;\n\n\/\/ Initialize Telegram BOT\n#define BOTtoken &quot;XXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;  \/\/ your Bot Token (Get from Botfather)\n\n\/\/ Use @myidbot to find out the chat ID of an individual or a group\n\/\/ Also note that you need to click &quot;start&quot; on a bot before it can\n\/\/ message you\n#define CHAT_ID &quot;XXXXXXXXXX&quot;\n\nX509List cert(TELEGRAM_CERTIFICATE_ROOT);\nWiFiClientSecure client;\nUniversalTelegramBot bot(BOTtoken, client);\n\n\/\/ Runs whenever the reedswitch changes state\nICACHE_RAM_ATTR void changeDoorStatus() {\n  Serial.println(&quot;State changed&quot;);\n  changeState = true;\n}\n\nvoid setup() {\n  \/\/ Serial port for debugging purposes\n  Serial.begin(115200);\n  configTime(0, 0, &quot;pool.ntp.org&quot;);      \/\/ get UTC time via NTP\n  client.setTrustAnchors(&amp;cert); \/\/ Add root certificate for api.telegram.org\n  \n\n  \/\/ Read the current door state\n  pinMode(reedSwitch, INPUT_PULLUP);\n  state = digitalRead(reedSwitch);\n\n  \/\/ Set LED state to match door state\n  pinMode(led, OUTPUT);\n  digitalWrite(led, state);\n  \n  \/\/ Set the reedswitch pin as interrupt, assign interrupt function and set CHANGE mode\n  attachInterrupt(digitalPinToInterrupt(reedSwitch), changeDoorStatus, CHANGE);\n\n  \/\/ Connect to Wi-Fi\n  WiFi.mode(WIFI_STA);\n  WiFi.begin(ssid, password);\n    while (WiFi.status() != WL_CONNECTED) {\n      delay(500);\n      Serial.print(&quot;.&quot;);\n    }\n    Serial.println(&quot;&quot;);\n    Serial.println(&quot;WiFi connected&quot;);  \n\n    bot.sendMessage(CHAT_ID, &quot;Bot started up&quot;, &quot;&quot;);\n}\n\nvoid loop() {\n  if (changeState){\n    unsigned long currentMillis = millis();\n    if(currentMillis - previousMillis &gt;= interval) {\n      previousMillis = currentMillis;\n      \/\/ If a state has occurred, invert the current door state   \n        state = !state;\n        if(state) {\n          doorState = &quot;closed&quot;;\n        }\n        else{\n          doorState = &quot;open&quot;;\n        }\n        digitalWrite(led, state);\n        changeState = false;\n        Serial.println(state);\n        Serial.println(doorState);\n        \n        \/\/Send notification\n        bot.sendMessage(CHAT_ID, &quot;The door is &quot; + doorState, &quot;&quot;);\n    }  \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\/ESP8266\/ESP8266_Telegram_Door.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 proceed to the <a href=\"#demonstration\">Demonstration <\/a>section.<\/p>\n\n\n\n<p>First, include the required libraries.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;ESP8266WiFi.h&gt;\n#include &lt;WiFiClientSecure.h&gt;\n#include &lt;UniversalTelegramBot.h&gt;\n#include &lt;ArduinoJson.h&gt;<\/code><\/pre>\n\n\n\n<p>Set the GPIOs for the reed switch and LED (the on-board LED is GPIO 2). We&#8217;ll light up the on-board LED when the door is open.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const int reedSwitch = 4;\nconst int led = 2; \/\/optional<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">changeState<\/span> boolean variable indicates whether the door has changed state.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>bool changeState = false;<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">state<\/span> variable will hold the reed switch state, and the <span class=\"rnthl rntliteral\">doorState<\/span>, as the name suggests, will hold the door state\u2014closed or opened.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>bool state;\nString doorState;<\/code><\/pre>\n\n\n\n<p>The following timer variables allow us to debounce the switch. Only changes that have occurred with at least 1500 milliseconds between them will be considered.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>unsigned long previousMillis = 0; \nconst long interval = 1500;<\/code><\/pre>\n\n\n\n<p>Insert your SSID and password in the following variables so that the ESP8266 can connect to the internet.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const char* ssid = \"REPLACE_WITH_YOUR_SSID\";\nconst char* password = \"REPLACE_WITH_YOUR_PASSWORD\";<\/code><\/pre>\n\n\n\n<p>Insert your Telegram Bot Token\u2014the one you&#8217;ve gotten in <a href=\"#telegram-bot\">this step<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define BOTtoken \"XXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"<\/code><\/pre>\n\n\n\n<p>Insert your chat ID\u2014the one you&#8217;ve gotten <a href=\"#user-id\">in this step<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define CHAT_ID \"XXXXXXXXXX\"<\/code><\/pre>\n\n\n\n<p>Create a new Wi-Fi client with <span class=\"rnthl rntliteral\">WiFiClientSecure<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>X509List cert(TELEGRAM_CERTIFICATE_ROOT);\nWiFiClientSecure client;<\/code><\/pre>\n\n\n\n<p>Create a&nbsp;bot&nbsp;with the token and client defined earlier.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>UniversalTelegramBot bot(BOTtoken, client);<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">changeDoorStatus()<\/span> function will run whenever a change is detected on the door state. This function simply changes the <span class=\"rnthl rntliteral\">changeState<\/span> variable to <span class=\"rnthl rntliteral\">true<\/span>. Then, in the <span class=\"rnthl rntliteral\">loop(),<\/span> we&#8217;ll handle what happens when the state changes (invert the previous door state and send a message to your Telegram account).<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>ICACHE_RAM_ATTR void changeDoorStatus() {\n  Serial.println(\"State changed\");\n  changeState = true;\n}<\/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>, initialize the Serial Monitor for debugging purposes:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.begin(115200);<\/code><\/pre>\n\n\n\n<p>Add a root certificate for api.telegram.org.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>client.setTrustAnchors(&amp;cert); \/\/ Add root certificate for api.telegram.org<\/code><\/pre>\n\n\n\n<p>Set the reed switch as an <span class=\"rnthl rntliteral\">INPUT<\/span>. And save the current state when the ESP8266 first starts.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>pinMode(reedSwitch, INPUT_PULLUP);\nstate = digitalRead(reedSwitch);<\/code><\/pre>\n\n\n\n<p>Set the LED as an <span class=\"rnthl rntliteral\">OUTPUT<\/span> and set its state to match the reed switch state (circuit closed and LED off; circuit opened and LED on).<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>pinMode(led, OUTPUT);\ndigitalWrite(led, state);<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>door closed \u2013&gt; the ESP8266 reads a HIGH signal \u2013&gt; turn off on-board LED (send a HIGH signal*)<\/li><li>door open \u2013&gt; the ESP8266 reads a LOW signal \u2013&gt; turn on on-board LED (send a LOW signal*)<\/li><\/ul>\n\n\n\n<p>* the ESP8266 on-board LED works with inverted logic\u2014send a HIGH signal to turn it off and a LOW signal to turn it on.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Setting an interrupt<\/h4>\n\n\n\n<p>Set the reed switch as an interrupt.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>attachInterrupt(digitalPinToInterrupt(reedSwitch), changeDoorStatus, CHANGE);<\/code><\/pre>\n\n\n\n<p>To set an interrupt in the Arduino IDE, you use the&nbsp;<span class=\"rnthl rntliteral\">attachInterrupt()<\/span>&nbsp;function, which accepts as arguments: the GPIO interrupt pin, the name of the function to be executed, and mode.<\/p>\n\n\n\n<p>The first argument is a GPIO interrupt. You should use&nbsp;<span class=\"rnthl rntliteral\">digitalPinToInterrupt(GPIO)<\/span>&nbsp;to set the actual GPIO as an interrupt pin.<\/p>\n\n\n\n<p>The second argument of the&nbsp;<span class=\"rnthl rntliteral\">attachInterrupt()<\/span>&nbsp;function is the name of the function that will be called every time the interrupt is triggered \u2013 the interrupt service routine (ISR). In this case, it is the <span class=\"rnthl rntliteral\">changeDoorStatus<\/span> function.<\/p>\n\n\n\n<p>The ISR function should be as simple as possible, so the processor gets back to the execution of the main program quickly.<\/p>\n\n\n\n<p>The third argument is the mode. We set it to <span class=\"rnthl rntliteral\">CHANGE<\/span> to trigger the interrupt whenever the pin changes value \u2013 for example, from HIGH to LOW and LOW to HIGH.<\/p>\n\n\n\n<p>To learn more about interrupts with the ESP8266, read the following tutorial:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/randomnerdtutorials.com\/interrupts-timers-esp8266-arduino-ide-nodemcu\/\">ESP8266 Interrupts and Timers using Arduino IDE<\/a><\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Initialize Wi-Fi<\/h4>\n\n\n\n<p>The following lines connect the ESP8266 to Wi-Fi.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WiFi.mode(WIFI_STA);\nWiFi.begin(ssid, password);\nwhile (WiFi.status() != WL_CONNECTED) {\n  delay(500);\n  Serial.print(\".\");\n}\nSerial.println(\"\");\nSerial.println(\"WiFi connected\");  <\/code><\/pre>\n\n\n\n<p>Send a message to your Telegram account informing you that the bot started.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>bot.sendMessage(CHAT_ID, \"Bot started up\", \"\");<\/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&#8217;ll read the <span class=\"rnthl rntliteral\">changeState<\/span> variable, and if a change has occurred, we&#8217;ll send a message to your Telegram account.<\/p>\n\n\n\n<p>First, check if a change occurred:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if (changeState){<\/code><\/pre>\n\n\n\n<p>Then, check if at least 1500 milliseconds have passed since the last state change.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if(currentMillis - previousMillis &gt;= interval) {<\/code><\/pre>\n\n\n\n<p>If that&#8217;s true, reset the timer and invert the current switch state:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>state = !state;<\/code><\/pre>\n\n\n\n<p>If the reed switch state is <span class=\"rnthl rntliteral\">1<\/span>(true), the door is closed. So, we change the <span class=\"rnthl rntliteral\">doorState<\/span> variable to <span class=\"rnthl rntliteral\">closed<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if(state) {\n  doorState = \"closed\";\n}<\/code><\/pre>\n\n\n\n<p>If it&#8217;s <span class=\"rnthl rntliteral\">0<\/span>(false), the door is opened. <\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>else{\n  doorState = \"open\";\n}<\/code><\/pre>\n\n\n\n<p>Set the LED state accordingly and print the door state in the Serial Monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>digitalWrite(led, state);\nchangeState = false;\nSerial.println(state);\nSerial.println(doorState);        <\/code><\/pre>\n\n\n\n<p>Finally, the following line sends a notification to your Telegram account with the current door state.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>bot.sendMessage(CHAT_ID, \"The door is \" + doorState, \"\");<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"demonstration\">Demonstration<\/h2>\n\n\n\n<p>After modifying the sketch to include your network credentials, bot token, and user ID, upload it to your ESP8266. Go to <strong>Tools <\/strong>&gt; <strong>Board <\/strong>and select your ESP8266 board. Then, go to <strong>Tools <\/strong>&gt; <strong>Port <\/strong>and select the COM port the ESP8266 is connected to.<\/p>\n\n\n\n<p>Open the Serial Monitor at a baud rate of 115200 to check if the changes are detected.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"601\" height=\"445\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/Door-Sensor-Monitoring-Serial-Monitor-ESP32.png?resize=601%2C445&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 NodeMCU Door Sensor Monitoring Serial Monitor.\" class=\"wp-image-106954\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/Door-Sensor-Monitoring-Serial-Monitor-ESP32.png?w=601&amp;quality=100&amp;strip=all&amp;ssl=1 601w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/Door-Sensor-Monitoring-Serial-Monitor-ESP32.png?resize=300%2C222&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 601px) 100vw, 601px\" \/><\/figure><\/div>\n\n\n\n<p>For prototyping\/testing, you can apply&nbsp;the magnetic reed switch to your door using Velcro.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"312\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/02\/esp8266-featured-image-e1456180240355.png?resize=600%2C312&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Testing ifttt with ESP8266 NodeMCU\" class=\"wp-image-18055\"\/><\/figure><\/div>\n\n\n\n<p>Now when someone&nbsp;opens\/closes your door, you receive a message in your Telegram account.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"611\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/ESP32-ESP8266-Door-Sensor-Telegram-Bot-Demonstration-f.jpg?resize=300%2C611&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 ESP8266 Door Sensor Telegram Bot Demonstration\" class=\"wp-image-106956\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/ESP32-ESP8266-Door-Sensor-Telegram-Bot-Demonstration-f.jpg?w=300&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/ESP32-ESP8266-Door-Sensor-Telegram-Bot-Demonstration-f.jpg?resize=147%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 147w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this tutorial, you&#8217;ve learned how to send notifications to your Telegram account when the reed switch changes state. This can be useful to detect if a door, window, or drawer was opened or closed.<\/p>\n\n\n\n<p>We have similar tutorials that you may like:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a style=\"font-size: inherit;\" href=\"https:\/\/randomnerdtutorials.com\/door-status-monitor-using-the-esp8266\/\">ESP8266 NodeMCU Door Status Monitor with Email Notifications (IFTTT)<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/telegram-esp8266-nodemcu-motion-detection-arduino\/\">Telegram: ESP8266 NodeMCU Motion Detection with Notifications (Arduino IDE)<\/a><\/li><\/ul>\n\n\n\n<p>Learn more about the ESP8266 with our resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/randomnerdtutorials.com\/home-automation-using-esp8266\/\">Home Automation Using ESP8266<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/build-web-servers-esp32-esp8266-ebook\/\">Build Web Servers with ESP32 and ESP8266 eBook (2nd Edition)<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp8266\/\">More ESP8266 Projects and Tutorials\u2026<\/a><\/li><\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this project,&nbsp;you&#8217;re going to monitor the status of a&nbsp;door using an&nbsp;ESP8266 NodeMCU board and a magnetic reed switch. You&#8217;ll receive a message in your Telegram account whenever the door &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP8266 NodeMCU Door Status Monitor with Telegram Notifications\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp8266-nodemcu-door-status-telegram\/#more-106963\" aria-label=\"Read more about ESP8266 NodeMCU Door Status Monitor with Telegram Notifications\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":106965,"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":[265,214,246,300,240,264],"tags":[],"class_list":["post-106963","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp8266-project","category-esp8266","category-esp8266-arduino-ide","category-0-esp8266","category-esp8266-projects","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/09\/ESP8266-Door-status-monitor-Telegram-thumbnail.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\/106963","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\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=106963"}],"version-history":[{"count":7,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/106963\/revisions"}],"predecessor-version":[{"id":107608,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/106963\/revisions\/107608"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/106965"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=106963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=106963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=106963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}