{"id":147991,"date":"2024-03-15T16:27:52","date_gmt":"2024-03-15T16:27:52","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=147991"},"modified":"2024-03-15T17:30:05","modified_gmt":"2024-03-15T17:30:05","slug":"esp32-send-messages-whatsapp-sim7000g","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp32-send-messages-whatsapp-sim7000g\/","title":{"rendered":"ESP32: Send Messages to WhatsApp using SIM Card &#8211; LILYGO T-SIM7000G"},"content":{"rendered":"\n<p>In this project, you&#8217;ll learn how to send messages to your WhatsApp account using an ESP32 from anywhere using a SIM card with a data plan. We&#8217;ll use the LILYGO T-SIM7000G ESP32 that combines the ESP32 chip, the SIM7000G module, a microSD card slot, a battery holder, and a charger on the same board.<\/p>\n\n\n\n<p>We&#8217;ll show you how to connect it to the internet using your SIM card data plan and make an HTTPS GET request to a free API called CallMeBot to send WhatsApp messages.<\/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\/2024\/02\/ESP32-Send-Messages-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Send Messages to WhatsApp using SIM Card LILYGO T-SIM7000G\" class=\"wp-image-148017\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/ESP32-Send-Messages-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/ESP32-Send-Messages-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/ESP32-Send-Messages-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/ESP32-Send-Messages-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.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<div class=\"wp-block-group rntbox rntclgray is-vertical is-layout-flex wp-container-core-group-is-layout-8cf370e7 wp-block-group-is-layout-flex\">\n<p><strong>Compatibility<\/strong><\/p>\n\n\n\n<p>This board supports 2G, LTE CAT-M1, and NB-IoT protocols. You can go to the following links to check if any of these protocols are supported in your country:<\/p>\n\n\n\n<p><a href=\"https:\/\/1nce.com\/en-eu\/1nce-connect\/our-coverage\/2g-network\" target=\"_blank\" rel=\"noopener\" title=\"\">Check network protocols supported in your country;<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/iotcreators.com\/network\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Check NB-IoT providers in your country.<\/a><\/p>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Project Overview<\/h2>\n\n\n\n<p>Here&#8217;s a high-level overview of how the project works:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"900\" height=\"888\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/SIM7000G-callmebot-whatsapp-project-overview.png?resize=900%2C888&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Projects Overview Send Messages to WhatsApp using SIM Card LILYGO T-SIM7000G\" class=\"wp-image-148122\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/SIM7000G-callmebot-whatsapp-project-overview.png?w=900&amp;quality=100&amp;strip=all&amp;ssl=1 900w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/SIM7000G-callmebot-whatsapp-project-overview.png?resize=300%2C296&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/SIM7000G-callmebot-whatsapp-project-overview.png?resize=768%2C758&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 900px) 100vw, 900px\" \/><\/figure><\/div>\n\n\n<ol class=\"wp-block-list\">\n<li>You have a LILYGO T-SIM7000G ESP32 board that has a SIM card with a data plan that can be connected to the internet;<\/li>\n\n\n\n<li>When the LILYGO T-SIM7000G ESP32 first boots, it establishes an internet connection and makes an HTTPS GET request to the CallMeBot API;<\/li>\n\n\n\n<li>Then, the CallMeBot API sends the message content to your WhatsApp account;<\/li>\n\n\n\n<li>Finally, you receive the message in your WhatsApp.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"SIM7000G-ESP32-Intro\">Introducing the LILYGO T-SIM7000G ESP32<\/h2>\n\n\n\n<p>The LILYGO T-SIM7000G is an ESP32 development board with a SIM7000G chip. This adds GPS, GPRS, LTE CAT-M1, and NB-IoT protocols to your board. This means that with this board you can send SMS, <a href=\"https:\/\/randomnerdtutorials.com\/lilygo-t-sim7000g-esp32-gps-data\/\" title=\"\">get location and time using GPS<\/a>, and connect it to the internet using a SIM card data plan. You can find more information by <a href=\"https:\/\/randomnerdtutorials.com\/lilygo-t-sim7000g-esp32-lte-gprs-gps\/\">reading our in-depth guide<\/a>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<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\/2022\/08\/ESP32-TSIM7000G.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"LILYGO T-SIM7000G ESP32\" class=\"wp-image-114209\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/08\/ESP32-TSIM7000G.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/08\/ESP32-TSIM7000G.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><strong>Where to buy the LILYGO T-SIM7000G ESP32?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/t-sim7000g-esp32\/\" target=\"_blank\" rel=\"noreferrer noopener\">LILYGO T-SIM7000G ESP32 (LTE, GPRS, and GPS) \u2013 Maker Advisor<\/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<h3 class=\"wp-block-heading\" id=\"Preparing-the-LILYGO-T-SIM7000G-ESP32-Board\">Preparing the LILYGO T-SIM7000G ESP32 Board<\/h3>\n\n\n\n<div class=\"wp-block-group rntbox rntclgray is-vertical is-layout-flex wp-container-core-group-is-layout-8cf370e7 wp-block-group-is-layout-flex\">\n<p><strong>Compatibility<\/strong><\/p>\n\n\n\n<p>This board supports 2G, LTE CAT-M1, and NB-IoT protocols. You can go to the following links to check if any of these protocols are supported in your country:<\/p>\n\n\n\n<p><a href=\"https:\/\/1nce.com\/en-eu\/1nce-connect\/our-coverage\/2g-network\" target=\"_blank\" rel=\"noopener\" title=\"\">Check network protocols supported in your country;<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/iotcreators.com\/network\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Check NB-IoT providers in your country.<\/a><\/p>\n<\/div>\n\n\n\n<p>Before proceeding, you need to follow the next two steps:<\/p>\n\n\n\n<p>1. Insert a nano SIM card into your 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\/2022\/08\/nano-SIM-card-vodafone.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Nano SIM card vodafone\" class=\"wp-image-114211\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/08\/nano-SIM-card-vodafone.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/08\/nano-SIM-card-vodafone.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\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\/2024\/02\/SIM7000G-ESP32-SIM-Card-Connected.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"SIM Card Connected to LILYGO T-SIM7000G ESP32\" class=\"wp-image-147740\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/SIM7000G-ESP32-SIM-Card-Connected.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/SIM7000G-ESP32-SIM-Card-Connected.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>2. Connect the Full Band LTE antenna to the correct antenna port as illustrated in the following image:<\/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\/2024\/02\/SIM7000G-ESP32-Antenna.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Connect Band LTE Antenna LILYGO T-SIM7000G ESP32\" class=\"wp-image-147739\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/SIM7000G-ESP32-Antenna.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/SIM7000G-ESP32-Antenna.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<h3 class=\"wp-block-heading\" id=\"apn-details\">APN Details<\/h3>\n\n\n\n<p>To connect your SIM card to the internet, you need to have your phone plan provider&#8217;s <strong>APN details<\/strong>. You need the domain name, username, and password.<\/p>\n\n\n\n<p>In my case, I\u2019m using Vodafone Portugal. If you search for&nbsp;&#8220;GPRS APN settings&#8221;&nbsp;followed by your phone plan provider name, (in my case: \u201cGPRS APN <strong>Vodafone Portugal<\/strong>\u201d), you can usually find in a forum or their website all the information that you need.<\/p>\n\n\n\n<p>It might be a bit tricky to find the details if you don\u2019t use a well-known provider. So, you might need to contact them directly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introducing WhatsApp<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"200\" height=\"200\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/09\/Whatsapp-logo.png?resize=200%2C200&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"WhatsApp logo\" class=\"wp-image-116773\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/09\/Whatsapp-logo.png?w=200&amp;quality=100&amp;strip=all&amp;ssl=1 200w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/09\/Whatsapp-logo.png?resize=150%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 150w\" sizes=\"(max-width: 200px) 100vw, 200px\" \/><\/figure><\/div>\n\n\n<p>\u201cWhatsApp Messenger, or simply WhatsApp, is an internationally available American freeware, cross-platform centralized instant messaging and voice-over-IP service owned by Meta Platforms.\u201d It allows you to send messages using your phone\u2019s internet connection, so you can avoid SMS fees.<\/p>\n\n\n\n<p>WhatsApp is free and is available for Android and iOS. Install WhatsApp on your smartphone if you don\u2019t have it already.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">CallMeBot WhatsApp API<\/h3>\n\n\n\n<p>To send messages to your WhatsApp account with the ESP32, we\u2019ll use a free API service called CallMeBot service. You can learn more about CallMeBot at the following link:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.callmebot.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.callmebot.com\/<\/a><\/li>\n<\/ul>\n\n\n\n<p>Basically, it works as a gateway that allows you to send a message to yourself. This can be useful to send alert messages from the ESP32.<\/p>\n\n\n\n<p>All the information about how to send messages using the API, can be found <a href=\"https:\/\/www.callmebot.com\/blog\/free-api-whatsapp-messages\/\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Getting the CallMeBot API KEY<\/h3>\n\n\n\n<p>Before starting to use the API, you need to get the CallmeBot WhatsApp API key. Follow the next instructions.<\/p>\n\n\n\n<ol class=\"wp-block-list\" style=\"list-style-type:1\">\n<li>Add the phone number <strong>+<strong>34 621 331 709<\/strong><\/strong> to your Phone Contacts. (Name it as you wish) \u2014 please <a href=\"https:\/\/www.callmebot.com\/blog\/free-api-whatsapp-messages\/\" target=\"_blank\" rel=\"noopener\" title=\"\">double-check the number on the CallMeBot website<\/a>, because it sometimes changes.<\/li>\n\n\n\n<li>Send the following message: &#8220;<em>I allow callmebot to send me messages&#8221;<\/em> to the new Contact created (using WhatsApp of course);<\/li>\n\n\n\n<li>Wait until you receive the message &#8220;<em>API Activated for your phone number. Your APIKEY is XXXXXX<\/em>&#8221; from the bot.<\/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=\"350\" height=\"458\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/09\/Get-CallMeBot-API-Key.png?resize=350%2C458&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Get CallMeBot API key\" class=\"wp-image-116707\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/09\/Get-CallMeBot-API-Key.png?w=350&amp;quality=100&amp;strip=all&amp;ssl=1 350w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/09\/Get-CallMeBot-API-Key.png?resize=229%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 229w\" sizes=\"(max-width: 350px) 100vw, 350px\" \/><\/figure><\/div>\n\n\n<p><strong>Note:<\/strong> if you don&#8217;t receive the API key in 2 minutes, please try again after 24hs or double-check the <a href=\"https:\/\/www.callmebot.com\/blog\/free-api-whatsapp-messages\/\" target=\"_blank\" rel=\"noopener\" title=\"\">CallMeBot phone number here<\/a>. The WhatsApp message from the bot will contain the API key needed to send messages using the API<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">CallMeBot API<\/h3>\n\n\n\n<p>To send a message using the CallMeBot API you need to make a request to the following URL (but using your information):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">https:\/\/api.callmebot.com\/whatsapp.php?phone=<strong>[phone_number]<\/strong>&amp;text=<strong>[message]<\/strong>&amp;apikey=<strong>[your_apikey]<\/strong><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span class=\"rnthl rntliteral\">[phone_number]<\/span>: phone number associated with your WhatsApp account in international format;<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span class=\"rnthl rntliteral\">[message]<\/span>: the message to be sent, should be URL encoded. <\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span class=\"rnthl rntliteral\">[your_apikey]<\/span>: the API key you received during the activation process in the previous section.<\/li>\n<\/ul>\n\n\n\n<p>You can learn more by reading the official <a href=\"https:\/\/www.callmebot.com\/blog\/free-api-whatsapp-messages\/\" target=\"_blank\" rel=\"noopener\" title=\"\">documentation<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-libraries\">Libraries<\/h2>\n\n\n\n<p>The ESP32 communicates with the SIM7000G chip by sending AT commands via serial communication. You don&#8217;t need a library, you can simply establish a serial communication with the module and start sending AT commands. <\/p>\n\n\n\n<p>However, it might be more practical to use a library. For example, the <a href=\"https:\/\/github.com\/vshymanskyy\/TinyGSM\" target=\"_blank\" rel=\"noreferrer noopener\">TinyGSM<\/a> library knows which commands to send, and how to handle AT responses, and wraps that into the standard Arduino Client interface\u2014that&#8217;s the library we&#8217;ll use in this tutorial.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Installing the TinyGSM Library<\/h4>\n\n\n\n<p>Open your Arduino IDE and go to&nbsp;<strong>Sketch&nbsp;<\/strong>&gt;&nbsp;<strong>Include Library<\/strong>&nbsp;&gt;&nbsp;<strong>Manage Libraries<\/strong>. The Library Manager should open. Search for&nbsp;<strong>TinyGSM<\/strong>. Select the TinyGSM library by Volodymyr Shymanskyy.<\/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=\"278\" height=\"307\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Arduino-IDE-2-Install-TinyGSM-Library-using-Libraries-Manager-1.png?resize=278%2C307&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino IDE 2 Install TinyGSM Library using Libraries Manager\" class=\"wp-image-147738\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Arduino-IDE-2-Install-TinyGSM-Library-using-Libraries-Manager-1.png?w=278&amp;quality=100&amp;strip=all&amp;ssl=1 278w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Arduino-IDE-2-Install-TinyGSM-Library-using-Libraries-Manager-1.png?resize=272%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 272w\" sizes=\"(max-width: 278px) 100vw, 278px\" \/><\/figure><\/div>\n\n\n<h4 class=\"wp-block-heading\">Installing the ArduinoHttpClient Library<\/h4>\n\n\n\n<p>You also need to install the <strong>ArduinoHttpClient <\/strong>library to make HTTPS requests. Search for <strong>ArduinoHttpClient<\/strong> and install it.<\/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=\"281\" height=\"288\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Arduino-IDE-2-Install-ArduinoHttpClient-Library-using-Libraries-Manager.png?resize=281%2C288&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino IDE 2 Install ArduinoHttpClient Library using Libraries Manager\" class=\"wp-image-147737\"\/><\/figure><\/div>\n\n\n<p class=\"rntbox rntclgreen\">Learn more about HTTPS requests with the ESP32: <a href=\"https:\/\/randomnerdtutorials.com\/esp32-https-requests\/\">ESP32 HTTPS Requests (Arduino IDE)<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Installing the UrlEncode Library<\/h4>\n\n\n\n<p>Finally, install the <strong>UrlEncode<\/strong> library to encode your messages. Search for <strong>UrlEncode <\/strong>and install it.<\/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=\"274\" height=\"291\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Arduino-IDE-2-Install-URLEncode-Library-using-Libraries-Manager.png?resize=274%2C291&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino IDE 2 Install URLEncode Library using Libraries Manager\" class=\"wp-image-148000\"\/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"make-https-requests\">Sending Messages using SIM Card to WhatsApp &#8211; LILYGO T-SIM7000G ESP32 Code<\/h2>\n\n\n\n<p>The following example code sends a message to your WhatsApp account when the ESP32 first boots. This is a simple example to show you how to send messages. After understanding how it works, the idea is to incorporate it into your projects to send notifications or useful data.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Copy the following code to your Arduino IDE.<\/li>\n<\/ol>\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-send-messages-whatsapp-sim7000g\/\n  \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. Based on the library example: github.com\/vshymanskyy\/TinyGSM\/blob\/master\/examples\/HttpsClient\/HttpsClient.ino\n*\/\n\n\/\/ Select your modem\n#define TINY_GSM_MODEM_SIM7000SSL\n#define TINY_GSM_RX_BUFFER 1024 \/\/ Set RX buffer to 1Kb\n\n\/\/ Set serial for debug console (to the Serial Monitor, default speed 115200)\n#define SerialMon Serial\n#define SerialAT Serial1\n\n#include &lt;TinyGsmClient.h&gt;\n#include &lt;ArduinoHttpClient.h&gt;\n#include &lt;UrlEncode.h&gt;\n\n\/\/ Define the serial console for debug prints, if needed\n#define TINY_GSM_DEBUG SerialMon\n\/\/ #define LOGGING  \/\/ &lt;- Logging is for the HTTP library\n\n\/\/ Add a reception delay, if needed.\n\/\/ This may be needed for a fast processor at a slow baud rate.\n\/\/ #define TINY_GSM_YIELD() { delay(2); }\n\n\/\/ set GSM PIN, if any\n#define GSM_PIN &quot;&quot;\n\n\/\/ flag to force SSL client authentication, if needed\n\/\/ #define TINY_GSM_SSL_CLIENT_AUTHENTICATION\n\n\/\/ Set your APN Details \/ GPRS credentials\nconst char apn[]  = &quot;&quot;;\nconst char gprsUser[] = &quot;&quot;;\nconst char gprsPass[] = &quot;&quot;;\n\n\/\/ Server details\nconst char server[]   = &quot;api.callmebot.com&quot;;\nconst int  port       = 443;\n\n\/\/ The phone number should be in international format (including the + sign)\nString phone_number = &quot;REPLACE_WITH_YOUR_PHONE_NUMBER&quot;;\nString api_key = &quot;REPLACE_WITH_YOUR_API_KEY&quot;;\n\nTinyGsm        modem(SerialAT);\n\nTinyGsmClientSecure client(modem);\nHttpClient          http(client, server, port);\n\n\/\/ LilyGO T-SIM7000G Pinout\n#define UART_BAUD           115200\n#define PIN_DTR             25\n#define PIN_TX              27\n#define PIN_RX              26\n#define PWR_PIN             4\n\n#define SD_MISO             2\n#define SD_MOSI             15\n#define SD_SCLK             14\n#define SD_CS               13\n#define LED_PIN             12\n\nvoid modemPowerOn(){\n  pinMode(PWR_PIN, OUTPUT);\n  digitalWrite(PWR_PIN, LOW);\n  delay(1000);\n  digitalWrite(PWR_PIN, HIGH);\n}\n\nvoid modemPowerOff(){\n  pinMode(PWR_PIN, OUTPUT);\n  digitalWrite(PWR_PIN, LOW);\n  delay(1500);\n  digitalWrite(PWR_PIN, HIGH);\n}\n\nvoid modemRestart(){\n  modemPowerOff();\n  delay(1000);\n  modemPowerOn();\n}\n\nvoid setup() {\n  \/\/ Set Serial Monitor baud rate\n  SerialMon.begin(115200);\n  delay(10);\n\n  \/\/ Set LED OFF\n  pinMode(LED_PIN, OUTPUT);\n  digitalWrite(LED_PIN, HIGH);\n\n  modemPowerOn();\n\n  SerialMon.println(&quot;Wait...&quot;);\n\n  \/\/ Set GSM module baud rate and Pins\n  SerialAT.begin(UART_BAUD, SERIAL_8N1, PIN_RX, PIN_TX);\n  delay(6000);\n\n  \/\/ Restart takes quite some time\n  \/\/ To skip it, call init() instead of restart()\n  SerialMon.println(&quot;Initializing modem...&quot;);\n  modem.restart();\n  \/\/ modem.init();\n\n  String modemInfo = modem.getModemInfo();\n  SerialMon.print(&quot;Modem Info: &quot;);\n  SerialMon.println(modemInfo);\n\n  \/\/ Unlock your SIM card with a PIN if needed\n  if (GSM_PIN &amp;&amp; modem.getSimStatus() != 3) {\n    modem.simUnlock(GSM_PIN);\n  }\n\n  Serial.println(&quot;Make sure your LTE antenna has been connected to the SIM interface on the board.&quot;);\n  delay(10000);\n}\n\nvoid loop() {\n  modem.gprsConnect(apn, gprsUser, gprsPass);\n\n  SerialMon.print(&quot;Waiting for network...&quot;);\n  if (!modem.waitForNetwork()) {\n    SerialMon.println(&quot; fail&quot;);\n    delay(10000);\n    return;\n  }\n  SerialMon.println(&quot; success&quot;);\n\n  if (modem.isNetworkConnected()) {\n    SerialMon.println(&quot;Network connected&quot;);\n  }\n\n  String message = &quot;Hello from ESP32!&quot;;\n  String url_callmebot = &quot;\/whatsapp.php?phone=&quot; + phone_number + &quot;&amp;apikey=&quot; + api_key + &quot;&amp;text=&quot; + urlEncode(message);\n\n  SerialMon.print(F(&quot;Performing HTTPS GET request... &quot;));\n  http.connectionKeepAlive();  \/\/ Currently, this is needed for HTTPS\n\n  int err = http.get(url_callmebot);\n  if (err != 0) {\n    SerialMon.println(F(&quot;failed to connect&quot;));\n    delay(10000);\n    return;\n  }\n\n  int status = http.responseStatusCode();\n  SerialMon.print(F(&quot;Response status code: &quot;));\n  SerialMon.println(status);\n  if (!status) {\n    delay(10000);\n    return;\n  }\n\n  SerialMon.println(F(&quot;Response Headers:&quot;));\n  while (http.headerAvailable()) {\n    String headerName  = http.readHeaderName();\n    String headerValue = http.readHeaderValue();\n    SerialMon.println(&quot;    &quot; + headerName + &quot; : &quot; + headerValue);\n  }\n\n  int length = http.contentLength();\n  if (length &gt;= 0) {\n    SerialMon.print(F(&quot;Content length is: &quot;));\n    SerialMon.println(length);\n  }\n  if (http.isResponseChunked()) {\n    SerialMon.println(F(&quot;The response is chunked&quot;));\n  }\n\n  String body = http.responseBody();\n  SerialMon.println(F(&quot;Response:&quot;));\n  SerialMon.println(body);\n\n  SerialMon.print(F(&quot;Body length is: &quot;));\n  SerialMon.println(body.length());\n\n  \/\/ Shutdown\n  http.stop();\n  SerialMon.println(F(&quot;Server disconnected&quot;));\n\n  modem.gprsDisconnect();\n  SerialMon.println(F(&quot;GPRS disconnected&quot;));\n\n  \/\/ Do nothing forevermore\n  while (true) {\n    delay(1000);\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\/LILYGO_T-SIM7000G\/Send_Whatsapp_Message.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<ol start=\"2\"><li>Insert your SIM card pin, if you have it. In my case, I disabled the pin. <\/li><\/ol>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define GSM_PIN \"\"<\/code><\/pre>\n\n\n\n<ol start=\"3\"><li>Insert your apn details on the following lines:<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Set your APN Details \/ GPRS credentials\nconst char apn&#091;]  = \"\";\nconst char gprsUser&#091;] = \"\";\nconst char gprsPass&#091;] = \"\";<\/code><\/pre>\n\n\n\n<p>For example, in my case:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const char apn&#091;]  = \"net2.vodafone.pt\";\nconst char gprsUser&#091;] = \"vodafone\";\nconst char gprsPass&#091;] = \"vodafone\";<\/code><\/pre>\n\n\n\n<ol start=\"4\"><li>Replace with your phone number and API key. The phone number should be in international format (including the + sign).<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>String phone_number = \"REPLACE_WITH_YOUR_PHONE_NUMBER\";\nString api_key = \"REPLACE_WITH_YOUR_API_KEY\";<\/code><\/pre>\n\n\n\n<ol start=\"5\"><li>Go to <strong>Tools <\/strong>&gt; <strong>Board <\/strong>and select <strong>ESP32 Dev Module<\/strong>.<\/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=\"670\" height=\"479\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Arduino-IDE-2-Select-ESP32-Dev-Module-Board-and-COM-Port.png?resize=670%2C479&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino IDE 2 Select ESP32 Dev Module Board and COM Port\" class=\"wp-image-147733\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Arduino-IDE-2-Select-ESP32-Dev-Module-Board-and-COM-Port.png?w=670&amp;quality=100&amp;strip=all&amp;ssl=1 670w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Arduino-IDE-2-Select-ESP32-Dev-Module-Board-and-COM-Port.png?resize=300%2C214&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 670px) 100vw, 670px\" \/><\/figure><\/div>\n\n\n<ol start=\"6\"><li>Finally, upload the code to your board.<\/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=\"41\" height=\"37\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Arduino-2-Compile-and-Upload-Sketch-button.png?resize=41%2C37&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino IDE 2 Compile and Upload Sketch button\" class=\"wp-image-147731\"\/><\/figure><\/div>\n\n\n<p>Then, open the Serial Monitor at a baud rate of 115200. Press the on-board RST button to restart the 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=\"37\" height=\"32\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Arduino-2-Open-Serial-Monitor-Button.png?resize=37%2C32&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino IDE 2 Open Serial Monitor Button\" class=\"wp-image-147732\"\/><\/figure><\/div>\n\n\n<p>Wait until the board connects to the network (in my case, it may take up to 2 minutes). You should get something similar in your Serial Monitor\u2014see the picture below.<\/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=\"1074\" height=\"561\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-Arduino-IDE-2-Serial-Monitor-ESP32-Send-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?resize=1074%2C561&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Demonstration Arduino IDE 2 Serial Monitor ESP32 Send Message to WhatsApp Remotely LILYGO T-SIM7000G\" class=\"wp-image-147997\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-Arduino-IDE-2-Serial-Monitor-ESP32-Send-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?w=1074&amp;quality=100&amp;strip=all&amp;ssl=1 1074w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-Arduino-IDE-2-Serial-Monitor-ESP32-Send-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?resize=300%2C157&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-Arduino-IDE-2-Serial-Monitor-ESP32-Send-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?resize=1024%2C535&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-Arduino-IDE-2-Serial-Monitor-ESP32-Send-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?resize=768%2C401&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1074px) 100vw, 1074px\" \/><\/figure><\/div>\n\n\n<p>You can see that it identifies the SIM7000G module and connects to the network successfully.<\/p>\n\n\n\n<p>Finally, it establishes a connection with the CallMeBot API and should return the success response &#8220;<em>Text to send: Hello from ESP32! Message queued. You will receive it in a few seconds<\/em>&#8220;. If you see something similar in your Arduino IDE Serial Monitor, it means the code is running successfully.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How the Code Works<\/h2>\n\n\n\n<p>Let&#8217;s take a quick look at the parts of the code relevant to this example.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">SIM Module<\/h3>\n\n\n\n<p>First, you need to define the module you&#8217;re using. The library is compatible with many different modules. To use the SIM7000G, include the following line:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define TINY_GSM_MODEM_SIM7000SSL<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Libraries<\/h3>\n\n\n\n<p>Include the <span class=\"rnthl rntliteral\">TinyGSM<\/span>, <span class=\"rnthl rntliteral\">ArduinoHttpClient<\/span>, and <span class=\"rnthl rntliteral\">UrlEncode<\/span> libraries.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;TinyGsmClient.h&gt;\n#include &lt;ArduinoHttpClient.h&gt;\n#include &lt;UrlEncode.h&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">APN Details<\/h3>\n\n\n\n<p>Insert the SIM card pin and APN details (in our case, it&#8217;s the following APN, user and pass):<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ set GSM PIN, if any\n#define GSM_PIN \"\"\n\n\/\/ Set your APN Details \/ GPRS credentials\nconst char apn&#091;]  = \"net2.vodafone.pt\";\nconst char gprsUser&#091;] = \"vodafone\";\nconst char gprsPass&#091;] = \"vodafone\";<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Server Domain and Resource<\/h3>\n\n\n\n<p>Define the <span class=\"rnthl rntliteral\">server<\/span> (CallMeBot API endpoint) and <span class=\"rnthl rntliteral\">port<\/span> where you want to make the HTTPS GET request:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Server details\nconst char server&#091;]   = \"api.callmebot.com\";\nconst int  port       = 443;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Initialize TinyGSMClient<\/h3>\n\n\n\n<p>Create a <span class=\"rnthl rntliteral\">TinyGsmClient<\/span> instance:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>TinyGsm modem(SerialAT);\n\nTinyGsmClientSecure client(modem);\n\nHttpClient http(client, server, port);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">SIM7000G pinout<\/h3>\n\n\n\n<p>The following lines set the module baud rate and pinout:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define UART_BAUD   115200\n#define PIN_DTR     25\n#define PIN_TX      27\n#define PIN_RX      26\n#define PWR_PIN     4\n\n#define SD_MISO     2\n#define SD_MOSI     15\n#define SD_SCLK     14\n#define SD_CS       13\n#define LED_PIN     12<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Power the modem<\/h3>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span>, you need to include the following instructions to turn on the modem:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>pinMode(PWR_PIN, OUTPUT);\ndigitalWrite(PWR_PIN, HIGH);\ndelay(300);\ndigitalWrite(PWR_PIN, LOW);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Start Serial Communication<\/h3>\n\n\n\n<p>Start a serial communication with the modem:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>SerialAT.begin(UART_BAUD, SERIAL_8N1, PIN_RX, PIN_TX);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Restart and Initialize the Modem<\/h3>\n\n\n\n<p>Call the following function to restart the modem:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>SerialMon.println(\"Initializing modem...\");\nmodem.restart();<\/code><\/pre>\n\n\n\n<p>You can also use the <span class=\"rnthl rntliteral\">modem.init()<\/span>. The difference between <span class=\"rnthl rntliteral\">restart()<\/span> and <span class=\"rnthl rntliteral\">init()<\/span> according to documentation: &#8220;<span class=\"rnthl rntliteral\">restart()<\/span> generally takes longer than <span class=\"rnthl rntliteral\">init()<\/span> but ensures the module doesn&#8217;t have lingering connections&#8221;.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Get Modem Info<\/h3>\n\n\n\n<p>You can use the <span class=\"rnthl rntliteral\">getModemInfo()<\/span> to get information about the modem.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>String modemInfo = modem.getModemInfo();\nSerialMon.print(\"Modem Info: \");\nSerialMon.println(modemInfo);<\/code><\/pre>\n\n\n\n<p>If you&#8217;re using the same model, it will print in the Arduino IDE Serial monitor the following information (SIM7000G):<\/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=\"215\" height=\"23\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-print-modem-info-ESP32-Make-HTTPS-Requests-SIM-Card-LILYGO-T-SIM7000G.png?resize=215%2C23&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Demonstration print modem info ESP32 Make HTTPS Requests SIM Card LILYGO T-SIM7000G\" class=\"wp-image-147748\"\/><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\">Unlock and Connect GPRS<\/h3>\n\n\n\n<p>If your SIM card has a pin, the next command will use the pin and unlock the card:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if (GSM_PIN &amp;&amp; modem.getSimStatus() != 3) {\n  modem.simUnlock(GSM_PIN);\n}<\/code><\/pre>\n\n\n\n<p>Next, connect the GPRS using the APN details:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>modem.gprsConnect(apn, gprsUser, gprsPass);\n\nSerialMon.print(\"Waiting for network...\");\nif (!modem.waitForNetwork()) {\n  SerialMon.println(\" fail\");\n  delay(10000);\n  return;\n}\nSerialMon.println(\" success\");<\/code><\/pre>\n\n\n\n<p>To check if it is connected, you can use the <span class=\"rnthl rntliteral\">isNetworkConnected()<\/span> method:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if (modem.isNetworkConnected()) {\n  SerialMon.println(\"Network connected\");\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Configure the WhatsApp Message<\/h3>\n\n\n\n<p>You can customize the <span class=\"rnthl rntliteral\">String message<\/span> with your desired WhatsApp message. We&#8217;ll be using the sample text &#8220;Hello from ESP32!&#8221; and then, we&#8217;ll use the <span class=\"rnthl rntliteral\">urlEncode()<\/span> function to encode it.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>String message = \"Hello from ESP32!\";\nString url_callmebot = \"\/whatsapp.php?phone=\" + phone_number + \"&amp;apikey=\" + api_key + \"&amp;text=\" + urlEncode(message);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Perform the HTTPS GET Request<\/h3>\n\n\n\n<p>Making an HTTPS GET request is easy using the <span class=\"rnthl rntliteral\">ArduinoHttpClient<\/span> library, you just need to call <span class=\"rnthl rntliteral\">http.get(url_callmebot)<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>SerialMon.print(F(\"Performing HTTPS GET request... \"));\nhttp.connectionKeepAlive();  \/\/ Currently, this is needed for HTTPS\n\nint err = http.get(url_callmebot);\nif (err != 0) {\n  SerialMon.println(F(\"failed to connect\"));\n  delay(10000);\n  return;\n}<\/code><\/pre>\n\n\n\n<p>If the request is successful, it will print the <em>Response status code: 200<\/em> in your Serial Monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>int status = http.responseStatusCode();\nSerialMon.print(F(\"Response status code: \"));\nSerialMon.println(status);\nif (!status) {\n  delay(10000);\n  return;\n}<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"456\" height=\"26\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-Response-code-200-ESP32-Make-HTTPS-Requests-SIM-Card-LILYGO-T-SIM7000G.png?resize=456%2C26&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Demonstration Response code 200 ESP32 Make HTTPS Requests SIM Card LILYGO T-SIM7000G\" class=\"wp-image-147745\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-Response-code-200-ESP32-Make-HTTPS-Requests-SIM-Card-LILYGO-T-SIM7000G.png?w=456&amp;quality=100&amp;strip=all&amp;ssl=1 456w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-Response-code-200-ESP32-Make-HTTPS-Requests-SIM-Card-LILYGO-T-SIM7000G.png?resize=300%2C17&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 456px) 100vw, 456px\" \/><\/figure><\/div>\n\n\n<p>The following snippet is for debugging purposes, it prints the response header and content length.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>SerialMon.println(F(\"Response Headers:\"));\nwhile (http.headerAvailable()) {\n  String headerName  = http.readHeaderName();\n  String headerValue = http.readHeaderValue();\n  SerialMon.println(\"    \" + headerName + \" : \" + headerValue);\n}\n\nint length = http.contentLength();\nif (length &gt;= 0) {\n  SerialMon.print(F(\"Content length is: \"));\n  SerialMon.println(length);\n}\nif (http.isResponseChunked()) {\n  SerialMon.println(F(\"The response is chunked\"));\n}<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"485\" height=\"197\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-Arduino-IDE-2-Serial-Monitor-HTTPS-Response-Header-Remotely-LILYGO-T-SIM7000G.png?resize=485%2C197&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Demonstration Arduino IDE 2 Serial Monitor HTTPS Response Header Remotely LILYGO T-SIM7000G\" class=\"wp-image-147996\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-Arduino-IDE-2-Serial-Monitor-HTTPS-Response-Header-Remotely-LILYGO-T-SIM7000G.png?w=485&amp;quality=100&amp;strip=all&amp;ssl=1 485w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-Arduino-IDE-2-Serial-Monitor-HTTPS-Response-Header-Remotely-LILYGO-T-SIM7000G.png?resize=300%2C122&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 485px) 100vw, 485px\" \/><\/figure><\/div>\n\n\n<p>The response body is the actual response from CallMeBot.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>String body = http.responseBody();\nSerialMon.println(F(\"Response:\"));\nSerialMon.println(body);\n\nSerialMon.print(F(\"Body length is: \"));\nSerialMon.println(body.length());<\/code><\/pre>\n\n\n\n<p>The CallMeBot API should reply with the following success response.<\/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=\"991\" height=\"54\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Arduino-IDE-2-Serial-Monitor-ESP32-Send-Test-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?resize=991%2C54&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino IDE 2 Serial Monitor ESP32 Send Test Message to WhatsApp Remotely LILYGO T-SIM7000G\" class=\"wp-image-147995\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Arduino-IDE-2-Serial-Monitor-ESP32-Send-Test-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?w=991&amp;quality=100&amp;strip=all&amp;ssl=1 991w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Arduino-IDE-2-Serial-Monitor-ESP32-Send-Test-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?resize=300%2C16&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Arduino-IDE-2-Serial-Monitor-ESP32-Send-Test-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?resize=768%2C42&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 991px) 100vw, 991px\" \/><\/figure><\/div>\n\n\n<p>Finally, stop the http connection and disconnect the GPRS modem from the Internet.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>http.stop();\nSerialMon.println(F(\"Server disconnected\"));\n\nmodem.gprsDisconnect();\nSerialMon.println(F(\"GPRS disconnected\"));<\/code><\/pre>\n\n\n\n<p>That&#8217;s it, those are the most relevant code parts of this sketch.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Demonstration<\/h2>\n\n\n\n<p>After uploading your code, open the Serial Monitor at a baud rate of 115200 and press the board RST button. It should successfully connect to your network and send the message to WhatsApp.<\/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=\"1074\" height=\"561\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-Arduino-IDE-2-Serial-Monitor-ESP32-Send-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?resize=1074%2C561&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Demonstration Arduino IDE 2 Serial Monitor ESP32 Send Message to WhatsApp Remotely LILYGO T-SIM7000G\" class=\"wp-image-147997\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-Arduino-IDE-2-Serial-Monitor-ESP32-Send-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?w=1074&amp;quality=100&amp;strip=all&amp;ssl=1 1074w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-Arduino-IDE-2-Serial-Monitor-ESP32-Send-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?resize=300%2C157&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-Arduino-IDE-2-Serial-Monitor-ESP32-Send-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?resize=1024%2C535&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/Demonstration-Arduino-IDE-2-Serial-Monitor-ESP32-Send-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?resize=768%2C401&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1074px) 100vw, 1074px\" \/><\/figure><\/div>\n\n\n<p>Go to your WhatsApp account. After a few seconds, you should receive the ESP32 message.<\/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=\"509\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/ESP32-Send-Test-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?resize=750%2C509&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Send Test Message to WhatsApp Remotely LILYGO T-SIM7000G\" class=\"wp-image-147994\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/ESP32-Send-Test-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/ESP32-Send-Test-Message-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.png?resize=300%2C204&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this tutorial, you learned how to use the CallMeBot API with the ESP32 LILYGO T-SIM7000G to send messages to your WhatsApp account. This can be useful to send sensor readings regularly to your account, send a notification when motion is detected, send an alert message when a sensor reading is above or below a certain threshold, and many other applications.<\/p>\n\n\n\n<p>You may also like the following SIM7000G tutorials:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/lilygo-t-sim7000g-esp32-lte-gprs-gps\/\">Getting Started with LILYGO T-SIM7000G ESP32 (LTE, GPRS, and GPS)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/lilygo-t-sim7000g-esp32-gps-data\/\">LILYGO T-SIM7000G ESP32: Get GPS Data (Latitude, Longitude, Altitude, and more)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-https-requests-sim-card-sim7000g\/\">ESP32: Make HTTPS Requests using SIM Card \u2013 LILYGO T-SIM7000G<\/a><\/li>\n<\/ul>\n\n\n\n<p>Learn more about the ESP32 with our 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<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/build-web-servers-esp32-esp8266-ebook\/\">Build Web Servers with ESP32 and ESP8266<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/firebase-esp32-esp8266-ebook\/\">Firebase Web App with ESP32 and ESP8266<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp32\/\">Free ESP32 Projects and Tutorials<\/a><\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this project, you&#8217;ll learn how to send messages to your WhatsApp account using an ESP32 from anywhere using a SIM card with a data plan. We&#8217;ll use the LILYGO &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP32: Send Messages to WhatsApp using SIM Card &#8211; LILYGO T-SIM7000G\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp32-send-messages-whatsapp-sim7000g\/#more-147991\" aria-label=\"Read more about ESP32: Send Messages to WhatsApp using SIM Card &#8211; LILYGO T-SIM7000G\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":148017,"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-147991","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\/2024\/02\/ESP32-Send-Messages-to-WhatsApp-Remotely-LILYGO-T-SIM7000G.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\/147991","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=147991"}],"version-history":[{"count":14,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/147991\/revisions"}],"predecessor-version":[{"id":150456,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/147991\/revisions\/150456"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/148017"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=147991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=147991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=147991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}