{"id":99705,"date":"2020-10-20T13:07:27","date_gmt":"2020-10-20T13:07:27","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=99705"},"modified":"2020-10-20T13:07:30","modified_gmt":"2020-10-20T13:07:30","slug":"esp32-cloud-mqtt-broker-sim800l","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp32-cloud-mqtt-broker-sim800l\/","title":{"rendered":"Connect ESP32 to Cloud MQTT Broker (TTGO T-Call ESP32 SIM800L)"},"content":{"rendered":"\n<p>This guide shows how to connect the TTGO T-Call ESP32 SIM800L board to the Internet using a SIM card data plan and publish\/subscribe to a cloud MQTT broker without using Wi-Fi. The cloud MQTT Mosquitto broker will be installed on a Digital Ocean server. We&#8217;ll also use Node-RED to visualize the readings and control the outputs from anywhere. The 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\/2020\/10\/Connect-ESP32-to-Cloud-MQTT-Broker-TTGO-T-Call-ESP32-SIM800L.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Connect ESP32 to Cloud MQTT Broker TTGO T-Call ESP32 SIM800L\" class=\"wp-image-99827\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/Connect-ESP32-to-Cloud-MQTT-Broker-TTGO-T-Call-ESP32-SIM800L.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/Connect-ESP32-to-Cloud-MQTT-Broker-TTGO-T-Call-ESP32-SIM800L.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/Connect-ESP32-to-Cloud-MQTT-Broker-TTGO-T-Call-ESP32-SIM800L.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/Connect-ESP32-to-Cloud-MQTT-Broker-TTGO-T-Call-ESP32-SIM800L.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>With this setup, you can monitor and control your ESP32 from anywhere in the world, and the ESP32 doesn&#8217;t need to be connected to a wireless router because it connects to the internet using a SIM card data plan.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introducing the TTGO T-Call ESP32 SIM800L<\/h2>\n\n\n\n<p>The TTGO T-Call is an ESP32 development board that combines a SIM800L GSM\/GPRS module. <a aria-label=\" (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/ttgo-t-call-esp32-sim800\/\" target=\"_blank\">You can get if for approximately $11<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/09\/SIMCOM-SIM800L-ESP32.jpg?resize=750%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"TTGO T-Call ESP32 SIM800L GPS GPRS Board\" class=\"wp-image-88991\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/09\/SIMCOM-SIM800L-ESP32.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/09\/SIMCOM-SIM800L-ESP32.jpg?resize=300%2C168&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n\n<p>Besides Wi-Fi and Bluetooth, you can communicate with this ESP32 board using SMS or phone calls and you can connect it to the internet using your SIM card data plan. This is great for IoT projects that don\u2019t have access to a nearby router.<\/p>\n\n\n\n<p class=\"rntbox rntcred\"><strong>Important: <\/strong> the SIM800L works on 2G networks, so it will only work in your country, if 2G networks are available. Check if you have 2G network in your country, otherwise it won\u2019t work. <\/p>\n\n\n\n<p>To use the capabilities of this board you need to have a nano SIM card with data plan and a <a href=\"https:\/\/makeradvisor.com\/tools\/usb-c-data-charging-cable\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"USB-C cable (opens in a new tab)\">USB-C cable<\/a> to upload code to the board.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/09\/USB-C.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 SIM800L Board USB-C cable for charging and data\" class=\"wp-image-88989\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/09\/USB-C.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/09\/USB-C.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 package includes some header pins, a battery connector, and an external antenna that you should connect to your board. <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/09\/TTGO-T-Call-ESP32-Package.jpg?resize=750%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 SIM800L Board Package\" class=\"wp-image-88990\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/09\/TTGO-T-Call-ESP32-Package.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/09\/TTGO-T-Call-ESP32-Package.jpg?resize=300%2C168&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n\n<p>However, we had some issues with that antenna, so we decided to switch to another type of antenna and all the problems were solved. The following figure shows the new antenna.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"420\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/09\/ESP32-SIM800-another-antenna.jpg?resize=750%2C420&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 SIM800L Board alternative antenna\" class=\"wp-image-88992\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/09\/ESP32-SIM800-another-antenna.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/09\/ESP32-SIM800-another-antenna.jpg?resize=300%2C168&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Project Overview<\/h2>\n\n\n\n<p>The idea of this project is to connect your ESP32 to a Cloud MQTT broker to subscribe to an MQTT topic and publish sensor data to MQTT topics. The ESP32 doesn\u2019t need to have access to a router via Wi-Fi, because it connects to the internet using a SIM card data plan.<\/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=\"900\" height=\"1002\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/Connect-ESP32-Cloud-MQTT-Broker-TTGO-T-Call-ESP32-SIM800L-Project-Overview.png?resize=900%2C1002&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Connect ESP32 to Cloud MQTT Broker TTGO T-Call ESP32 SIM800L Project overview and how it works\" class=\"wp-image-99803\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/Connect-ESP32-Cloud-MQTT-Broker-TTGO-T-Call-ESP32-SIM800L-Project-Overview.png?w=900&amp;quality=100&amp;strip=all&amp;ssl=1 900w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/Connect-ESP32-Cloud-MQTT-Broker-TTGO-T-Call-ESP32-SIM800L-Project-Overview.png?resize=269%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 269w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/Connect-ESP32-Cloud-MQTT-Broker-TTGO-T-Call-ESP32-SIM800L-Project-Overview.png?resize=768%2C855&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 900px) 100vw, 900px\" \/><\/figure><\/div>\n\n\n\n<p><a href=\"https:\/\/randomnerdtutorials.com\/esp32-sim800l-publish-data-to-cloud\/\">In a previous project<\/a>, we created our own server with a database to plot sensor readings in charts that you can access from anywhere in the world.<\/p>\n\n\n\n<p>In this project, we\u2019ll publish sensor readings to a server via MQTT and we&#8217;ll use Mosquitto broker. You can publish your sensor readings to any other cloud broker.<\/p>\n\n\n\n<p>In summary, here\u2019s how the project works:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>The T-Call ESP32 SIM800L board is connected to the internet using a SIM card data plan. <\/li><li>The T-Call ESP32 SIM800L board publishes the sensor readings via MQTT and the readings are displayed in Node-RED Dashboard.<\/li><li>Through Node-RED Dashboard, you can press buttons to send on and off commands to control the ESP32 GPIOs.<\/li><\/ol>\n\n\n\n<p>We\u2019ll be using a <a href=\"https:\/\/randomnerdtutorials.com\/esp32-bme280-arduino-ide-pressure-temperature-humidity\/\">BME280 sensor<\/a>, but you can use any other sensor that best suits your needs. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Cloud MQTT Broker<\/h3>\n\n\n\n<p>You can search for a free cloud MQTT broker, however we&#8217;ll be using our own cloud MQTT broker. We recommend using <a href=\"https:\/\/randomnerdtutorials.com\/cloud-mqtt-mosquitto-broker-access-anywhere-digital-ocean\/\">Digital Ocean with MQTT Mosquitto Broker<\/a>, because it can handle all the project requirements. We&#8217;ll also use <a href=\"https:\/\/randomnerdtutorials.com\/access-node-red-dashboard-anywhere-digital-ocean\/\">Node-RED software<\/a> to visualize the readings in gauges and publish MQTT messages to the ESP32.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/randomnerdtutorials.com\/cloud-mqtt-mosquitto-broker-access-anywhere-digital-ocean\/\">Run Your Cloud MQTT Mosquitto Broker (access from anywhere using Digital Ocean)<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/access-node-red-dashboard-anywhere-digital-ocean\/\">Access Node-RED Dashboard from Anywhere (using Digital Ocean)<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. ESP32 add-on Arduino IDE<\/h3>\n\n\n\n<p>We&#8217;ll program the ESP32 using Arduino IDE. So, you need to have the ESP32 add-on installed in your Arduino IDE. Follow the next tutorial, if you haven&#8217;t already.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/randomnerdtutorials.com\/installing-the-esp32-board-in-arduino-ide-windows-instructions\/\">Installing the ESP32 Board in Arduino IDE (Windows, Mac OS X, Linux)<\/a><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. Preparing your Cloud MQTT Broker<\/h3>\n\n\n\n<p>In this project we&#8217;ll show you how to exchange data via MQTT using a cloud MQTT broker. <\/p>\n\n\n\n<p>We&#8217;ll be using our own cloud MQTT broker. However, if you find a free MQTT broker with all your desired features it will also work&#8230;<\/p>\n\n\n\n<p>If you want to follow this exact project, you should follow the next two tutorials to prepare your own server and Node-RED software.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/randomnerdtutorials.com\/cloud-mqtt-mosquitto-broker-access-anywhere-digital-ocean\/\">Run Your Cloud MQTT Mosquitto Broker (access from anywhere using Digital Ocean)<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/access-node-red-dashboard-anywhere-digital-ocean\/\">Access Node-RED Dashboard from Anywhere (using Digital Ocean)<\/a><\/li><\/ul>\n\n\n\n<p>The ESP32 is publishing temperature readings every 30 seconds on the <span class=\"rnthl rntliteral\"><strong>esp\/temperature<\/strong><\/span> and <span class=\"rnthl rntliteral\"><strong>esp\/humidity<\/strong><\/span> topics. It&#8217;s subscribed to these two topics <span class=\"rnthl rntliteral\"><strong>esp\/output1<\/strong><\/span> and <span class=\"rnthl rntliteral\"><strong>esp\/output2<\/strong><\/span> to update the state of the output LEDs.<\/p>\n\n\n\n<p>Having Node-RED running, go to your server IP address followed by :1880.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;cloud-mqtt-broker-ip-address:1880<\/code><\/pre>\n\n\n\n<p>Wire your nodes as shown below:<\/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=\"371\" height=\"291\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/ESP32-SIM800L-GPRS-GSM-Cloud-MQTT-Broker-Node-RED-Arduino.png?resize=371%2C291&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 SIM800L GPRS GSM Cloud MQTT Broker Node-RED Arduino\" class=\"wp-image-99790\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/ESP32-SIM800L-GPRS-GSM-Cloud-MQTT-Broker-Node-RED-Arduino.png?w=371&amp;quality=100&amp;strip=all&amp;ssl=1 371w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/ESP32-SIM800L-GPRS-GSM-Cloud-MQTT-Broker-Node-RED-Arduino.png?resize=300%2C235&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 371px) 100vw, 371px\" \/><\/figure><\/div>\n\n\n\n<p>Finally, deploy your flow (press the button on the upper right corner).<\/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=\"138\" height=\"40\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/06\/11_deploy_button.png?resize=138%2C40&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Deploy Node-RED button\" class=\"wp-image-40013\"\/><\/figure><\/div>\n\n\n\n<p>Alternatively, you can go to <strong>Menu <\/strong>&gt; <strong>Import <\/strong>and copy the following to your <strong>Clipboard<\/strong> to create your Node-RED flow.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">[{&quot;id&quot;:&quot;a2c394d8.1544e8&quot;,&quot;type&quot;:&quot;mqtt in&quot;,&quot;z&quot;:&quot;537cca59.c4a014&quot;,&quot;name&quot;:&quot;&quot;,&quot;topic&quot;:&quot;esp\/temperature&quot;,&quot;qos&quot;:&quot;2&quot;,&quot;datatype&quot;:&quot;auto&quot;,&quot;broker&quot;:&quot;18f874c0.4a464b&quot;,&quot;x&quot;:140,&quot;y&quot;:1020,&quot;wires&quot;:[[&quot;6907217e.f39bf&quot;]]},{&quot;id&quot;:&quot;b83c2ecf.8ab94&quot;,&quot;type&quot;:&quot;mqtt in&quot;,&quot;z&quot;:&quot;537cca59.c4a014&quot;,&quot;name&quot;:&quot;&quot;,&quot;topic&quot;:&quot;esp\/humidity&quot;,&quot;qos&quot;:&quot;2&quot;,&quot;datatype&quot;:&quot;auto&quot;,&quot;broker&quot;:&quot;18f874c0.4a464b&quot;,&quot;x&quot;:130,&quot;y&quot;:1100,&quot;wires&quot;:[[&quot;c92e354e.a27d48&quot;]]},{&quot;id&quot;:&quot;ee844c66.3eda2&quot;,&quot;type&quot;:&quot;mqtt out&quot;,&quot;z&quot;:&quot;537cca59.c4a014&quot;,&quot;name&quot;:&quot;&quot;,&quot;topic&quot;:&quot;esp\/output1&quot;,&quot;qos&quot;:&quot;1&quot;,&quot;retain&quot;:&quot;&quot;,&quot;broker&quot;:&quot;18f874c0.4a464b&quot;,&quot;x&quot;:330,&quot;y&quot;:1180,&quot;wires&quot;:[]},{&quot;id&quot;:&quot;54540fba.e5877&quot;,&quot;type&quot;:&quot;mqtt out&quot;,&quot;z&quot;:&quot;537cca59.c4a014&quot;,&quot;name&quot;:&quot;&quot;,&quot;topic&quot;:&quot;esp\/output2&quot;,&quot;qos&quot;:&quot;1&quot;,&quot;retain&quot;:&quot;&quot;,&quot;broker&quot;:&quot;18f874c0.4a464b&quot;,&quot;x&quot;:330,&quot;y&quot;:1260,&quot;wires&quot;:[]},{&quot;id&quot;:&quot;56080a9a.c7bba4&quot;,&quot;type&quot;:&quot;ui_switch&quot;,&quot;z&quot;:&quot;537cca59.c4a014&quot;,&quot;name&quot;:&quot;&quot;,&quot;label&quot;:&quot;Output 1&quot;,&quot;tooltip&quot;:&quot;&quot;,&quot;group&quot;:&quot;1539f836.ed9378&quot;,&quot;order&quot;:0,&quot;width&quot;:0,&quot;height&quot;:0,&quot;passthru&quot;:true,&quot;decouple&quot;:&quot;false&quot;,&quot;topic&quot;:&quot;&quot;,&quot;style&quot;:&quot;&quot;,&quot;onvalue&quot;:&quot;true&quot;,&quot;onvalueType&quot;:&quot;bool&quot;,&quot;onicon&quot;:&quot;&quot;,&quot;oncolor&quot;:&quot;&quot;,&quot;offvalue&quot;:&quot;false&quot;,&quot;offvalueType&quot;:&quot;bool&quot;,&quot;officon&quot;:&quot;&quot;,&quot;offcolor&quot;:&quot;&quot;,&quot;x&quot;:120,&quot;y&quot;:1180,&quot;wires&quot;:[[&quot;ee844c66.3eda2&quot;]]},{&quot;id&quot;:&quot;417bd6d1.1d1468&quot;,&quot;type&quot;:&quot;ui_switch&quot;,&quot;z&quot;:&quot;537cca59.c4a014&quot;,&quot;name&quot;:&quot;&quot;,&quot;label&quot;:&quot;Output 2&quot;,&quot;tooltip&quot;:&quot;&quot;,&quot;group&quot;:&quot;1539f836.ed9378&quot;,&quot;order&quot;:0,&quot;width&quot;:0,&quot;height&quot;:0,&quot;passthru&quot;:true,&quot;decouple&quot;:&quot;false&quot;,&quot;topic&quot;:&quot;&quot;,&quot;style&quot;:&quot;&quot;,&quot;onvalue&quot;:&quot;true&quot;,&quot;onvalueType&quot;:&quot;bool&quot;,&quot;onicon&quot;:&quot;&quot;,&quot;oncolor&quot;:&quot;&quot;,&quot;offvalue&quot;:&quot;false&quot;,&quot;offvalueType&quot;:&quot;bool&quot;,&quot;officon&quot;:&quot;&quot;,&quot;offcolor&quot;:&quot;&quot;,&quot;x&quot;:120,&quot;y&quot;:1260,&quot;wires&quot;:[[&quot;54540fba.e5877&quot;]]},{&quot;id&quot;:&quot;6907217e.f39bf&quot;,&quot;type&quot;:&quot;ui_gauge&quot;,&quot;z&quot;:&quot;537cca59.c4a014&quot;,&quot;name&quot;:&quot;&quot;,&quot;group&quot;:&quot;1539f836.ed9378&quot;,&quot;order&quot;:2,&quot;width&quot;:0,&quot;height&quot;:0,&quot;gtype&quot;:&quot;gage&quot;,&quot;title&quot;:&quot;Temperature&quot;,&quot;label&quot;:&quot;Celsius Degrees&quot;,&quot;format&quot;:&quot;{{value}}&quot;,&quot;min&quot;:&quot;-10&quot;,&quot;max&quot;:&quot;40&quot;,&quot;colors&quot;:[&quot;#00b500&quot;,&quot;#e6e600&quot;,&quot;#ca3838&quot;],&quot;seg1&quot;:&quot;&quot;,&quot;seg2&quot;:&quot;&quot;,&quot;x&quot;:350,&quot;y&quot;:1020,&quot;wires&quot;:[]},{&quot;id&quot;:&quot;c92e354e.a27d48&quot;,&quot;type&quot;:&quot;ui_gauge&quot;,&quot;z&quot;:&quot;537cca59.c4a014&quot;,&quot;name&quot;:&quot;&quot;,&quot;group&quot;:&quot;1539f836.ed9378&quot;,&quot;order&quot;:2,&quot;width&quot;:0,&quot;height&quot;:0,&quot;gtype&quot;:&quot;gage&quot;,&quot;title&quot;:&quot;Humidity&quot;,&quot;label&quot;:&quot;%&quot;,&quot;format&quot;:&quot;{{value}}&quot;,&quot;min&quot;:&quot;0&quot;,&quot;max&quot;:&quot;100&quot;,&quot;colors&quot;:[&quot;#93dae6&quot;,&quot;#0074cc&quot;,&quot;#002561&quot;],&quot;seg1&quot;:&quot;&quot;,&quot;seg2&quot;:&quot;&quot;,&quot;x&quot;:340,&quot;y&quot;:1100,&quot;wires&quot;:[]},{&quot;id&quot;:&quot;18f874c0.4a464b&quot;,&quot;type&quot;:&quot;mqtt-broker&quot;,&quot;z&quot;:&quot;&quot;,&quot;name&quot;:&quot;&quot;,&quot;broker&quot;:&quot;localhost&quot;,&quot;port&quot;:&quot;1883&quot;,&quot;clientid&quot;:&quot;&quot;,&quot;usetls&quot;:false,&quot;compatmode&quot;:false,&quot;keepalive&quot;:&quot;60&quot;,&quot;cleansession&quot;:true,&quot;birthTopic&quot;:&quot;&quot;,&quot;birthQos&quot;:&quot;0&quot;,&quot;birthPayload&quot;:&quot;&quot;,&quot;closeTopic&quot;:&quot;&quot;,&quot;closeQos&quot;:&quot;0&quot;,&quot;closePayload&quot;:&quot;&quot;,&quot;willTopic&quot;:&quot;&quot;,&quot;willQos&quot;:&quot;0&quot;,&quot;willPayload&quot;:&quot;&quot;},{&quot;id&quot;:&quot;1539f836.ed9378&quot;,&quot;type&quot;:&quot;ui_group&quot;,&quot;z&quot;:&quot;&quot;,&quot;name&quot;:&quot;Dashboard&quot;,&quot;tab&quot;:&quot;38becbd0.c13714&quot;,&quot;order&quot;:1,&quot;disp&quot;:true,&quot;width&quot;:&quot;6&quot;,&quot;collapse&quot;:false},{&quot;id&quot;:&quot;38becbd0.c13714&quot;,&quot;type&quot;:&quot;ui_tab&quot;,&quot;z&quot;:&quot;&quot;,&quot;name&quot;:&quot;Home&quot;,&quot;icon&quot;:&quot;dashboard&quot;,&quot;disabled&quot;:false,&quot;hidden&quot;:false}]\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP32\/ESP32_SIM800L_Cloud_MQTT_Broker_NodeRED.txt\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. SIM Card with data plan<\/h3>\n\n\n\n<p>To use the TTGO T-Call ESP32 SIM800L board, you need a nano SIM card with a data plan. We recommend using a SIM card with a prepaid or monthly plan, so that you know exactly how much you&#8217;ll spend.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"apn\">4. APN Details<\/h3>\n\n\n\n<p>To connect your SIM card to the internet, you need to have your phone plan provider APN details. 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 <strong>GPRS APN settings<\/strong> followed by your phone plan provider name, (in my case its: \u201c<strong>GPRS APN vodafone Portugal<\/strong>\u201d), you can usually find in a forum or in their website all the information that you need.<\/p>\n\n\n\n<p>I\u2019ve found <a rel=\"noreferrer noopener\" aria-label=\"this website (opens in a new tab)\" href=\"https:\/\/wiki.apnchanger.org\/Main_Page\" target=\"_blank\">this website<\/a> that can be very useful to find all the information 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 your provider directly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. Libraries<\/h3>\n\n\n\n<p>You need to install these libraries in your Arduino IDE to proceed with this project: <a aria-label=\"Adafruit_BME280 (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/adafruit\/Adafruit_BME280_Library\" target=\"_blank\">Adafruit_BME280<\/a>, <a aria-label=\"Adafruit_Sensor (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/adafruit\/Adafruit_Sensor\" target=\"_blank\">Adafruit_Sensor<\/a>, <a aria-label=\"TinyGSM (opens in a new tab)\" href=\"https:\/\/github.com\/vshymanskyy\/TinyGSM\" target=\"_blank\" rel=\"noreferrer noopener\">TinyGSM<\/a>, and <a href=\"https:\/\/github.com\/knolleary\/pubsubclient\" target=\"_blank\" rel=\"noreferrer noopener\">PubSubClient<\/a>. Follow the next instructions to install these libraries.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Installing the Adafruit BME280 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.<\/p>\n\n\n\n<p>Search for \u201c<strong>adafruit bme280<\/strong> \u201d on the Search box and install the library.<\/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\/2018\/08\/install-bme280.png?resize=786%2C443&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing BME280 library in Arduino IDE\" class=\"wp-image-70233\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/install-bme280.png?w=786&amp;quality=100&amp;strip=all&amp;ssl=1 786w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/install-bme280.png?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/install-bme280.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<h4 class=\"wp-block-heading\">Installing the Adafruit Sensor Library <\/h4>\n\n\n\n<p>To use the BME280 library, you also need to install the <a href=\"https:\/\/github.com\/adafruit\/Adafruit_Sensor\" target=\"_blank\" rel=\"noreferrer noopener\">Adafruit_Sensor library<\/a>. Follow the next steps to install the library in your Arduino IDE:<\/p>\n\n\n\n<p>Go to <strong>Sketch&nbsp;<\/strong>&gt;&nbsp;<strong>Include Library<\/strong>&nbsp;&gt;&nbsp;<strong>Manage Libraries<\/strong> and type \u201c<strong>Adafruit Unified Sensor<\/strong>\u201d in the search box. Scroll all the way down to find the library and install it.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/adafruit_unified_sensor_library.png?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing Adafruit Unified Sensor Driver library\" class=\"wp-image-84295\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/adafruit_unified_sensor_library.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/adafruit_unified_sensor_library.png?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<h4 class=\"wp-block-heading\">Installing the TinyGSM Library <\/h4>\n\n\n\n<p>In the Arduino IDE Library Manager search for <strong>TinyGSM<\/strong>. Select the TinyGSM library by Volodymyr Shymanskyy.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"786\" height=\"443\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/08\/Install-TinyGSM-Library-Arduino-IDE.png?resize=786%2C443&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing TinyGSM library\" class=\"wp-image-88782\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/08\/Install-TinyGSM-Library-Arduino-IDE.png?w=786&amp;quality=100&amp;strip=all&amp;ssl=1 786w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/08\/Install-TinyGSM-Library-Arduino-IDE.png?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/08\/Install-TinyGSM-Library-Arduino-IDE.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<h4 class=\"wp-block-heading\">Installing the PubSubClient Library <\/h4>\n\n\n\n<p>Search for <strong>PubSubClient<\/strong> and scroll down. Select the PubSubClient library by Nick O&#8217;Leary.<\/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=\"786\" height=\"443\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/PubSubClient-library-install-Arduino-IDE.png?resize=786%2C443&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing PubSubClient library in Arduino IDE\" class=\"wp-image-99801\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/PubSubClient-library-install-Arduino-IDE.png?w=786&amp;quality=100&amp;strip=all&amp;ssl=1 786w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/PubSubClient-library-install-Arduino-IDE.png?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/PubSubClient-library-install-Arduino-IDE.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<p>After installing the libraries, restart your Arduino IDE. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Parts Required<\/h2>\n\n\n\n<p>To build this project, you need the following parts:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a aria-label=\" (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/ttgo-t-call-esp32-sim800\/\" target=\"_blank\"><strong>TTGO T-Call ESP32 SIM800L<\/strong><\/a><\/li><li><a aria-label=\"USB-C cable\u2028 (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/usb-c-data-charging-cable\/\" target=\"_blank\">USB-C cable<\/a><\/li><li><a aria-label=\"Antenna  (opens in a new tab)\" href=\"https:\/\/rover.ebay.com\/rover\/1\/711-53200-19255-0\/1?ff3=2&amp;toolid=10044&amp;campid=5338179998&amp;customid=MakerAdvisorT&amp;lgeo=1&amp;vectorid=229466&amp;item=311649924872\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Antenna <\/a>(optional)<\/li><li><a aria-label=\" (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/bme280-sensor-module\/\" target=\"_blank\">BME280 sensor module<\/a> (<a href=\"https:\/\/randomnerdtutorials.com\/esp32-bme280-arduino-ide-pressure-temperature-humidity\/\">Guide for BME280 with ESP32<\/a>)<\/li><li><a href=\"https:\/\/makeradvisor.com\/tools\/3mm-5mm-leds-kit-storage-box\/\" target=\"_blank\" rel=\"noreferrer noopener\">2x LEDs<\/a><\/li><li><a href=\"https:\/\/makeradvisor.com\/tools\/resistors-kits\/\" target=\"_blank\" rel=\"noreferrer noopener\">2x 220 ohm resistors<\/a><\/li><li><a aria-label=\"Breadboard (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/mb-102-solderless-breadboard-830-points\/\" target=\"_blank\">Breadboard<\/a><\/li><li><a aria-label=\"Jumper wires (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/jumper-wires-kit-120-pieces\/\" target=\"_blank\">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 Diagram<\/h2>\n\n\n\n<p>Wire the BME280 sensor and two LEDs to the T-Call ESP32 SIM800L board as shown in the following schematic diagram.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/ESP32-SIM800L-2outputs-BME280-Cloud-MQTT-Broker-Wiring-schematic-diagram.jpg?resize=766%2C643&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"TTGO T-Call ESP32 SIM800L with BME280 sensor outputs wiring schematic diagram\" class=\"wp-image-99813\" width=\"766\" height=\"643\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/ESP32-SIM800L-2outputs-BME280-Cloud-MQTT-Broker-Wiring-schematic-diagram.jpg?w=766&amp;quality=100&amp;strip=all&amp;ssl=1 766w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/ESP32-SIM800L-2outputs-BME280-Cloud-MQTT-Broker-Wiring-schematic-diagram.jpg?resize=300%2C252&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 766px) 100vw, 766px\" \/><\/figure><\/div>\n\n\n\n<p>We&#8217;re connecting the BME280&#8217;s SDA pin to <span class=\"rnthl rntclgreen\">GPIO 18<\/span> and the SCL pin to <span class=\"rnthl rntcyellow\">GPIO 19<\/span>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Code<\/h2>\n\n\n\n<p>Copy the following code to your Arduino IDE but don&#8217;t upload it yet. First, you need to make some modifications to make it work.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*\n  Rui Santos\n  Complete project details at https:\/\/RandomNerdTutorials.com\/esp32-cloud-mqtt-broker-sim800l\/\n  \n  Permission is hereby granted, free of charge, to any person obtaining a copy\n  of this software and associated documentation files.\n  \n  The above copyright notice and this permission notice shall be included in all\n  copies or substantial portions of the Software.\n*\/\n\n\/\/ Select your modem:\n#define TINY_GSM_MODEM_SIM800 \/\/ Modem is SIM800L\n\n\/\/ Set serial for debug console (to the Serial Monitor, default speed 115200)\n#define SerialMon Serial\n\/\/ Set serial for AT commands\n#define SerialAT Serial1\n\n\/\/ Define the serial console for debug prints, if needed\n#define TINY_GSM_DEBUG SerialMon\n\n\/\/ set GSM PIN, if any\n#define GSM_PIN &quot;&quot;\n\n\/\/ Your GPRS credentials, if any\nconst char apn[] = &quot;&quot;; \/\/ APN (example: internet.vodafone.pt) use https:\/\/wiki.apnchanger.org\nconst char gprsUser[] = &quot;&quot;;\nconst char gprsPass[] = &quot;&quot;;\n\n\/\/ SIM card PIN (leave empty, if not defined)\nconst char simPIN[]   = &quot;&quot;; \n\n\/\/ MQTT details\nconst char* broker = &quot;XXX.XXX.XXX.XXX&quot;;                    \/\/ Public IP address or domain name\nconst char* mqttUsername = &quot;REPLACE_WITH_YOUR_MQTT_USER&quot;;  \/\/ MQTT username\nconst char* mqttPassword = &quot;REPLACE_WITH_YOUR_MQTT_PASS&quot;;  \/\/ MQTT password\n\nconst char* topicOutput1 = &quot;esp\/output1&quot;;\nconst char* topicOutput2 = &quot;esp\/output2&quot;;\nconst char* topicTemperature = &quot;esp\/temperature&quot;;\nconst char* topicHumidity = &quot;esp\/humidity&quot;;\n\n\/\/ Define the serial console for debug prints, if needed\n\/\/#define DUMP_AT_COMMANDS\n\n#include &lt;Wire.h&gt;\n#include &lt;TinyGsmClient.h&gt;\n\n#ifdef DUMP_AT_COMMANDS\n  #include &lt;StreamDebugger.h&gt;\n  StreamDebugger debugger(SerialAT, SerialMon);\n  TinyGsm modem(debugger);\n#else\n  TinyGsm modem(SerialAT);\n#endif\n\n#include &lt;PubSubClient.h&gt;\n#include &lt;Adafruit_Sensor.h&gt;\n#include &lt;Adafruit_BME280.h&gt;\n\nTinyGsmClient client(modem);\nPubSubClient mqtt(client);\n\n\/\/ TTGO T-Call pins\n#define MODEM_RST            5\n#define MODEM_PWKEY          4\n#define MODEM_POWER_ON       23\n#define MODEM_TX             27\n#define MODEM_RX             26\n#define I2C_SDA              21\n#define I2C_SCL              22\n\n\/\/ BME280 pins\n#define I2C_SDA_2            18\n#define I2C_SCL_2            19\n\n#define OUTPUT_1             2\n#define OUTPUT_2             15\n\nuint32_t lastReconnectAttempt = 0;\n\n\/\/ I2C for SIM800 (to keep it running when powered from battery)\nTwoWire I2CPower = TwoWire(0);\n\nTwoWire I2CBME = TwoWire(1);\nAdafruit_BME280 bme;\n\n#define IP5306_ADDR          0x75\n#define IP5306_REG_SYS_CTL0  0x00\n\nfloat temperature = 0;\nfloat humidity = 0;\nlong lastMsg = 0;\n\nbool setPowerBoostKeepOn(int en){\n  I2CPower.beginTransmission(IP5306_ADDR);\n  I2CPower.write(IP5306_REG_SYS_CTL0);\n  if (en) {\n    I2CPower.write(0x37); \/\/ Set bit1: 1 enable 0 disable boost keep on\n  } else {\n    I2CPower.write(0x35); \/\/ 0x37 is default reg value\n  }\n  return I2CPower.endTransmission() == 0;\n}\n\nvoid mqttCallback(char* topic, byte* message, unsigned int len) {\n  Serial.print(&quot;Message arrived on topic: &quot;);\n  Serial.print(topic);\n  Serial.print(&quot;. Message: &quot;);\n  String messageTemp;\n  \n  for (int i = 0; i &lt; len; i++) {\n    Serial.print((char)message[i]);\n    messageTemp += (char)message[i];\n  }\n  Serial.println();\n\n  \/\/ Feel free to add more if statements to control more GPIOs with MQTT\n\n  \/\/ If a message is received on the topic esp\/output1, you check if the message is either &quot;true&quot; or &quot;false&quot;. \n  \/\/ Changes the output state according to the message\n  if (String(topic) == &quot;esp\/output1&quot;) {\n    Serial.print(&quot;Changing output to &quot;);\n    if(messageTemp == &quot;true&quot;){\n      Serial.println(&quot;true&quot;);\n      digitalWrite(OUTPUT_1, HIGH);\n    }\n    else if(messageTemp == &quot;false&quot;){\n      Serial.println(&quot;false&quot;);\n      digitalWrite(OUTPUT_1, LOW);\n    }\n  }\n  else if (String(topic) == &quot;esp\/output2&quot;) {\n    Serial.print(&quot;Changing output to &quot;);\n    if(messageTemp == &quot;true&quot;){\n      Serial.println(&quot;true&quot;);\n      digitalWrite(OUTPUT_2, HIGH);\n    }\n    else if(messageTemp == &quot;false&quot;){\n      Serial.println(&quot;false&quot;);\n      digitalWrite(OUTPUT_2, LOW);\n    }\n  }\n}\n\nboolean mqttConnect() {\n  SerialMon.print(&quot;Connecting to &quot;);\n  SerialMon.print(broker);\n\n  \/\/ Connect to MQTT Broker without username and password\n  \/\/boolean status = mqtt.connect(&quot;GsmClientN&quot;);\n\n  \/\/ Or, if you want to authenticate MQTT:\n  boolean status = mqtt.connect(&quot;GsmClientN&quot;, mqttUsername, mqttPassword);\n\n  if (status == false) {\n    SerialMon.println(&quot; fail&quot;);\n    ESP.restart();\n    return false;\n  }\n  SerialMon.println(&quot; success&quot;);\n  mqtt.subscribe(topicOutput1);\n  mqtt.subscribe(topicOutput2);\n\n  return mqtt.connected();\n}\n\n\nvoid setup() {\n  \/\/ Set console baud rate\n  SerialMon.begin(115200);\n  delay(10);\n  \n  \/\/ Start I2C communication\n  I2CPower.begin(I2C_SDA, I2C_SCL, 400000);\n  I2CBME.begin(I2C_SDA_2, I2C_SCL_2, 400000);\n  \n  \/\/ Keep power when running from battery\n  bool isOk = setPowerBoostKeepOn(1);\n  SerialMon.println(String(&quot;IP5306 KeepOn &quot;) + (isOk ? &quot;OK&quot; : &quot;FAIL&quot;));\n\n  \/\/ Set modem reset, enable, power pins\n  pinMode(MODEM_PWKEY, OUTPUT);\n  pinMode(MODEM_RST, OUTPUT);\n  pinMode(MODEM_POWER_ON, OUTPUT);\n  digitalWrite(MODEM_PWKEY, LOW);\n  digitalWrite(MODEM_RST, HIGH);\n  digitalWrite(MODEM_POWER_ON, HIGH);\n  \n  pinMode(OUTPUT_1, OUTPUT);\n  pinMode(OUTPUT_2, OUTPUT);\n  \n  SerialMon.println(&quot;Wait...&quot;);\n\n  \/\/ Set GSM module baud rate and UART pins\n  SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_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  \/\/ You might need to change the BME280 I2C address, in our case it's 0x76\n  if (!bme.begin(0x76, &amp;I2CBME)) {\n    Serial.println(&quot;Could not find a valid BME280 sensor, check wiring!&quot;);\n    while (1);\n  }\n\n  SerialMon.print(&quot;Connecting to APN: &quot;);\n  SerialMon.print(apn);\n  if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {\n    SerialMon.println(&quot; fail&quot;);\n    ESP.restart();\n  }\n  else {\n    SerialMon.println(&quot; OK&quot;);\n  }\n  \n  if (modem.isGprsConnected()) {\n    SerialMon.println(&quot;GPRS connected&quot;);\n  }\n\n  \/\/ MQTT Broker setup\n  mqtt.setServer(broker, 1883);\n  mqtt.setCallback(mqttCallback);\n}\n\nvoid loop() {\n  if (!mqtt.connected()) {\n    SerialMon.println(&quot;=== MQTT NOT CONNECTED ===&quot;);\n    \/\/ Reconnect every 10 seconds\n    uint32_t t = millis();\n    if (t - lastReconnectAttempt &gt; 10000L) {\n      lastReconnectAttempt = t;\n      if (mqttConnect()) {\n        lastReconnectAttempt = 0;\n      }\n    }\n    delay(100);\n    return;\n  }\n\n  long now = millis();\n  if (now - lastMsg &gt; 30000) {\n    lastMsg = now;\n    \n    \/\/ Temperature in Celsius\n    temperature = bme.readTemperature();   \n    \/\/ Uncomment the next line to set temperature in Fahrenheit \n    \/\/ (and comment the previous temperature line)\n    \/\/temperature = 1.8 * bme.readTemperature() + 32; \/\/ Temperature in Fahrenheit\n    \n    \/\/ Convert the value to a char array\n    char tempString[8];\n    dtostrf(temperature, 1, 2, tempString);\n    Serial.print(&quot;Temperature: &quot;);\n    Serial.println(tempString);\n    mqtt.publish(topicTemperature, tempString);\n\n    humidity = bme.readHumidity();\n    \n    \/\/ Convert the value to a char array\n    char humString[8];\n    dtostrf(humidity, 1, 2, humString);\n    Serial.print(&quot;Humidity: &quot;);\n    Serial.println(humString);\n    mqtt.publish(topicHumidity, humString);\n  }\n\n  mqtt.loop();\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP32\/ESP32_SIM800L_Cloud_MQTT_Broker.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>Before uploading the code, you need to insert your APN details, SIM card PIN (if applicable) and your cloud MQTT server details.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How the Code Works<\/h2>\n\n\n\n<p>Insert your GPRS APN credentials in the following variables:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const char apn&#091;]      = \"\"; \/\/ APN (example: internet.vodafone.pt) use https:\/\/wiki.apnchanger.org\nconst char gprsUser&#091;] = \"\"; \/\/ GPRS User\nconst char gprsPass&#091;] = \"\"; \/\/ GPRS Password<\/code><\/pre>\n\n\n\n<p>In our case, the APN is <span class=\"rnthl rntliteral\">internet.vodafone.pt<\/span>. Yours should be different. We explained previously <a href=\"#apn\">how to get your APN details<\/a>. <\/p>\n\n\n\n<p>Enter your SIM card PIN if applicable:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const char simPIN&#091;] = \"\";<\/code><\/pre>\n\n\n\n<p>You also need to type the cloud MQTT server details in the following variables. It can be your own cloud MQTT domain or any other MQTT server that you want to use.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const char* broker = \"178.XXX.XXX.XXX\";  \/\/ Public IP address or domain name\nconst char* mqttUsername = \"REPLACE_WITH_YOUR_MQTT_USERNAME\";\nconst char* mqttPassword = \"REPLACE_WITH_YOUR_MQTT_PASSWORD\";<\/code><\/pre>\n\n\n\n<p>The ESP32 is subscribed to the <span class=\"rnthl rntliteral\">esp\/output1<\/span> and <span class=\"rnthl rntliteral\">esp\/output2<\/span> topics to update the outputs with the latest value:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const char* topicOutput1 = \"esp\/output1\";\nconst char* topicOutput2 = \"esp\/output2\";<\/code><\/pre>\n\n\n\n<p>The ESP32 publishes the temperature and humidity readings to these topics <span class=\"rnthl rntliteral\">esp\/temperature<\/span> and <span class=\"rnthl rntliteral\">esp\/humidity<\/span> every 30 seconds:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const char* topicTemperature = \"esp\/temperature\";\nconst char* topicHumidity = \"esp\/humidity\";<\/code><\/pre>\n\n\n\n<p>The code is heavily commented so that you understand the purpose of each line of code.<\/p>\n\n\n\n<p>The following lines define the pins used by the SIM800L module:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define MODEM_RST       5\n#define MODEM_PWKEY     4\n#define MODEM_POWER_ON  23\n#define MODEM_TX        27\n#define MODEM_RX        26\n#define I2C_SDA         21\n#define I2C_SCL         22<\/code><\/pre>\n\n\n\n<p>Define the BME280 I2C pins. In this example we&#8217;re using <span class=\"rnthl rntclgreen\">GPIO 18<\/span> and <span class=\"rnthl rntcyellow\">GPIO 19<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define I2C_SDA_2  18\n#define I2C_SCL_2  19<\/code><\/pre>\n\n\n\n<p>Define a serial communication for the Serial Monitor and another to communicate with the SIM800L module:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Set serial for debug console (to Serial Monitor, default speed 115200)\n#define SerialMon Serial\n\/\/ Set serial for AT commands (to SIM800 module)\n#define SerialAT Serial1<\/code><\/pre>\n\n\n\n<p>Configure the <span class=\"rnthl rntliteral\">TinyGSM<\/span> library to work with the SIM800L module.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define TINY_GSM_MODEM_SIM800<\/code><\/pre>\n\n\n\n<p>Include the following libraries to communicate with the SIM800L.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;Wire.h>\n#include &lt;TinyGsmClient.h><\/code><\/pre>\n\n\n\n<p>And the MQTT library and the BME280 sensor libraries:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;PubSubClient.h>\n#include &lt;Adafruit_Sensor.h>\n#include &lt;Adafruit_BME280.h><\/code><\/pre>\n\n\n\n<p>Instantiate an I2C communication for the SIM800L (battery power management IC).<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>TwoWire I2CPower = TwoWire(0);<\/code><\/pre>\n\n\n\n<p>And another I2C communication for the BME280 sensor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>TwoWire I2CBME = TwoWire(1);\nAdafruit_BME280 bme;<\/code><\/pre>\n\n\n\n<p>Initialize a <span class=\"rnthl rntliteral\">TinyGsmClient<\/span> for internet connection.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>TinyGsmClient client(modem);<\/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 at a baud rate of 115200:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>SerialMon.begin(115200);<\/code><\/pre>\n\n\n\n<p>Start the I2C communication for the SIM800L module and for the BME280 sensor module:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>I2CPower.begin(I2C_SDA, I2C_SCL, 400000);\nI2CBME.begin(I2C_SDA_2, I2C_SCL_2, 400000);<\/code><\/pre>\n\n\n\n<p>Setup the SIM800L pins in a proper state to operate:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>pinMode(MODEM_PWKEY, OUTPUT);\npinMode(MODEM_RST, OUTPUT);\npinMode(MODEM_POWER_ON, OUTPUT);\ndigitalWrite(MODEM_PWKEY, LOW);\ndigitalWrite(MODEM_RST, HIGH);\ndigitalWrite(MODEM_POWER_ON, HIGH);<\/code><\/pre>\n\n\n\n<p>Initialize a serial communication with the SIM800L module.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);<\/code><\/pre>\n\n\n\n<p>Initialize the SIM800L module and unlock the SIM card PIN if needed.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>SerialMon.println(\"Initializing modem...\");\nmodem.restart();\n\n\/\/ Unlock your SIM card with a PIN if needed\nif (strlen(simPIN) &amp;&amp; modem.getSimStatus() != 3 ) {\n  modem.simUnlock(simPIN);\n}<\/code><\/pre>\n\n\n\n<p>Initialize the BME280 sensor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if (!bme.begin(0x76, &amp;I2CBME)) {\n  Serial.println(\"Could not find a valid BME280 sensor, check wiring!\");\n  while (1);\n}<\/code><\/pre>\n\n\n\n<p>Finally, in the <span class=\"rnthl rntliteral\">setup()<\/span> is where we&#8217;ll actually connect to the internet. The following lines connect the module to the internet:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>SerialMon.print(\"Connecting to APN: \");\nSerialMon.print(apn);\nif (!modem.gprsConnect(apn, gprsUser, gprsPass)) {\n  SerialMon.println(\" fail\");\n  ESP.restart();\n}\nelse {\n  SerialMon.println(\" OK\");\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">mqttConnect()<\/h3>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">mqttConnect()<\/span> function is responsible to connect your board to the MQTT broker using username and password. It also subscribes the ESP32 to the <strong>esp\/output1<\/strong> and <strong>esp\/output2<\/strong> MQTT topics.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>boolean mqttConnect() {\n  SerialMon.print(\"Connecting to \");\n  SerialMon.print(broker);\n\n  \/\/ Connect to MQTT Broker without username and password\n  \/\/boolean status = mqtt.connect(\"GsmClientN\");\n\n  \/\/ Or, if you want to authenticate MQTT:\n  boolean status = mqtt.connect(\"GsmClientN\", mqttUsername, mqttPassword);\n\n  if (status == false) {\n    SerialMon.println(\" fail\");\n    ESP.restart();\n    return false;\n  }\n  SerialMon.println(\" success\");\n  mqtt.subscribe(topicOutput1);\n  mqtt.subscribe(topicOutput2);\n\n  return mqtt.connected();\n}<\/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>, there&#8217;s a <a href=\"https:\/\/randomnerdtutorials.com\/esp32-pir-motion-sensor-interrupts-timers\/\">timer<\/a> that publishes the temperature and humidity readings to your MQTT broker every 30 seconds.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>long now = millis();\nif (now - lastMsg > 30000) {\n  lastMsg = now;\n    \n  \/\/ Temperature in Celsius\n  temperature = bme.readTemperature();   \n  \/\/ Uncomment the next line to set temperature in Fahrenheit \n  \/\/ (and comment the previous temperature line)\n  \/\/temperature = 1.8 * bme.readTemperature() + 32; \/\/ Temperature in Fahrenheit\n    \n  \/\/ Convert the value to a char array\n  char tempString&#091;8];\n  dtostrf(temperature, 1, 2, tempString);\n  Serial.print(\"Temperature: \");\n  Serial.println(tempString);\n  mqtt.publish(topicTemperature, tempString);\n\n  humidity = bme.readHumidity();\n    \n  \/\/ Convert the value to a char array\n  char humString&#091;8];\n  dtostrf(humidity, 1, 2, humString);\n  Serial.print(\"Humidity: \");\n  Serial.println(humString);\n  mqtt.publish(topicHumidity, humString);\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">mqttCallback()<\/h3>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">mqttCallback()<\/span> function, the ESP32 receives the MQTT messages of the subscribed topics. Accordingly to the MQTT topic and message, it turns the outputs on or off:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void mqttCallback(char* topic, byte* message, unsigned int len) {\n  Serial.print(\"Message arrived on topic: \");\n  Serial.print(topic);\n  Serial.print(\". Message: \");\n  String messageTemp;\n  for (int i = 0; i &lt; len; i++) {\n    Serial.print((char)message&#091;i]);\n    messageTemp += (char)message&#091;i];\n  }\n  Serial.println();\n\n  \/\/ Feel free to add more if statements to control more GPIOs with MQTT\n\n  \/\/ If a message is received on the topic esp\/output1, you check if the message is either \"true\" or \"false\". \n  \/\/ Changes the output state according to the message\n  if (String(topic) == \"esp\/output1\") {\n    Serial.print(\"Changing output to \");\n    if(messageTemp == \"true\"){\n      Serial.println(\"true\");\n      digitalWrite(OUTPUT_1, HIGH);\n    }\n    else if(messageTemp == \"false\"){\n      Serial.println(\"false\");\n      digitalWrite(OUTPUT_1, LOW);\n    }\n  }\n  else if (String(topic) == \"esp\/output2\") {\n    Serial.print(\"Changing output to \");\n    if(messageTemp == \"true\"){\n      Serial.println(\"true\");\n      digitalWrite(OUTPUT_2, HIGH);\n    }\n    else if(messageTemp == \"false\"){\n      Serial.println(\"false\");\n      digitalWrite(OUTPUT_2, LOW);\n    }\n  }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Upload the Code<\/h2>\n\n\n\n<p>After inserting all the necessary details, you can upload the code to your board.<\/p>\n\n\n\n<p>To upload code to your board, go to <strong>Tools <\/strong>&gt; <strong>Board <\/strong>and select <strong>ESP32 Dev module<\/strong>. Go to <strong>Tools<\/strong> &gt; <strong>Port<\/strong> and select the COM port your board is connected to. Finally, press the upload button to upload the code to your board.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"34\" height=\"29\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/12\/arduino-ide-upload-button.png?resize=34%2C29&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Upload Code to Arduino IDE\" class=\"wp-image-65439\"\/><\/figure><\/div>\n\n\n\n<p class=\"rntbox rntclblue\"><strong>Note: <\/strong> at the moment, there isn&#8217;t a board for the T-Call ESP32 SIM800L, but we&#8217;ve selected the <strong>ESP32 Dev Module<\/strong> and it&#8217;s been working fine.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Demonstration<\/h2>\n\n\n\n<p>Open the Serial Monitor at baud rate of 115200 and press the board RST button. <\/p>\n\n\n\n<p>First, the module initializes and then it tries to connect to the internet. Please note that this can take some time (in some cases it took almost 1 minute to complete). <\/p>\n\n\n\n<p>After connecting to the internet, it will connect to your MQTT broker.<\/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=\"859\" height=\"643\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/ESP32-SIM800L-GPRS-GSM-Cloud-MQTT-Broker-Node-RED-Arduino-IDE-Serial-Monitor.png?resize=859%2C643&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 SIM800L connect to the internet using SIM card data plan demonstration Cloud MQTT broker\" class=\"wp-image-99791\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/ESP32-SIM800L-GPRS-GSM-Cloud-MQTT-Broker-Node-RED-Arduino-IDE-Serial-Monitor.png?w=859&amp;quality=100&amp;strip=all&amp;ssl=1 859w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/ESP32-SIM800L-GPRS-GSM-Cloud-MQTT-Broker-Node-RED-Arduino-IDE-Serial-Monitor.png?resize=300%2C225&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/ESP32-SIM800L-GPRS-GSM-Cloud-MQTT-Broker-Node-RED-Arduino-IDE-Serial-Monitor.png?resize=768%2C575&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 859px) 100vw, 859px\" \/><\/figure><\/div>\n\n\n\n<p>In this example, it publishes new sensor readings every 30 seconds, but for testing purposes you can use a shorter period of time.<\/p>\n\n\n\n<p>Then, open a browser and type your server domain on the <strong>\/ui<\/strong> URL. You should see the charts with the latest sensor readings and the toggle switches to control the outputs.<\/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=\"726\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/ESP32-SIM800L-GPRS-GSM-Cloud-MQTT-Broker-Node-RED-Dashboard-Demonstration.png?resize=601%2C726&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 SIM800L GPRS GSM Cloud MQTT Broker Node-RED Dashboard demonstration\" class=\"wp-image-99792\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/ESP32-SIM800L-GPRS-GSM-Cloud-MQTT-Broker-Node-RED-Dashboard-Demonstration.png?w=601&amp;quality=100&amp;strip=all&amp;ssl=1 601w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/ESP32-SIM800L-GPRS-GSM-Cloud-MQTT-Broker-Node-RED-Dashboard-Demonstration.png?resize=248%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 248w\" sizes=\"(max-width: 601px) 100vw, 601px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<p>If at this point, you can\u2019t make your module connect to the internet, it can be caused by one of the following reasons:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The APN credentials might not be correct;<\/li><li>The antenna might not be working properly. In our case, we had to replace the antenna;<\/li><li>You might need to go outside to get a better signal coverage;<\/li><li>Or you might not be supplying enough current to the module. If you\u2019re connecting the module to your computer using a USB hub without external power supply, it might not provide enough current to operate.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>We hope you liked this project. In our opinion, the <a aria-label=\"T-Call SIM800 ESP32 board (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/ttgo-t-call-esp32-sim800\/\" target=\"_blank\">T-Call SIM800 ESP32 board<\/a> can be very useful for IoT projects that don\u2019t have access to a nearby router via Wi-Fi. You can connect your board to the internet quite easily using a SIM card data plan.<\/p>\n\n\n\n<p>You may also like the following projects:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/makeradvisor.com\/ttgo-t-call-esp32-with-sim800l-gsm-gprs\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">$11 TTGO T-Call ESP32 with SIM800L GSM\/GPRS (in-depth review)<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-mysql-database-php\/\">ESP32\/ESP8266 Insert Data into MySQL Database using PHP and Arduino IDE<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-plot-chart-web-server\/\">ESP32\/ESP8266 Plot Sensor Readings in Real Time Charts \u2013 Web Server<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-web-server-with-bme280-mini-weather-station\/\">ESP32 Web Server with BME280 \u2013 Advanced Weather Station<\/a><\/li><\/ul>\n\n\n\n<p>Learn more about the ESP32 with our resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/randomnerdtutorials.com\/learn-esp32-with-arduino-ide\/\">Learn ESP32 with Arduino IDE (Course)<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/micropython-programming-with-esp32-and-esp8266\/\">MicroPython Programming with ESP32 and ESP8266 (eBook)<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp32\/\">More ESP32 Projects and Tutorials<\/a><\/li><\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide shows how to connect the TTGO T-Call ESP32 SIM800L board to the Internet using a SIM card data plan and publish\/subscribe to a cloud MQTT broker without using &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Connect ESP32 to Cloud MQTT Broker (TTGO T-Call ESP32 SIM800L)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp32-cloud-mqtt-broker-sim800l\/#more-99705\" aria-label=\"Read more about Connect ESP32 to Cloud MQTT Broker (TTGO T-Call ESP32 SIM800L)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":99827,"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":[276,281,277,299,264],"tags":[],"class_list":["post-99705","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32","category-esp32-project","category-esp32-arduino-ide","category-0-esp32","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/10\/Connect-ESP32-to-Cloud-MQTT-Broker-TTGO-T-Call-ESP32-SIM800L.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\/99705","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=99705"}],"version-history":[{"count":0,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/99705\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/99827"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=99705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=99705"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=99705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}