{"id":167043,"date":"2025-02-13T13:33:54","date_gmt":"2025-02-13T13:33:54","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=167043"},"modified":"2025-03-24T11:47:01","modified_gmt":"2025-03-24T11:47:01","slug":"lilygo-ttgo-t-a7670g-a7670e-a7670sa-esp32","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/lilygo-ttgo-t-a7670g-a7670e-a7670sa-esp32\/","title":{"rendered":"Getting Started with LILYGO TTGO T-A7670G ESP32 (4G, GPRS, and GPS)"},"content":{"rendered":"\n<p>Get started with the ESP32 and the T-A7670G 4G\/GPS\/GPRS module. Throughout this guide, we&#8217;ll use the LILYGO TTGO T-A7670G ESP32 board that combines the ESP32 chip, the A7670G (or A7670E, A7670SA) module, SIM card slot, microSD card, GPS, battery, and charger on the same board. Besides Wi-Fi and Bluetooth, you can communicate with this ESP32 board using SMS. You can also connect it to the internet using your SIM card data plan and get GPS location.<\/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\/2025\/01\/Getting-Started-ESP32-LILYGO.TTGO-T-A7670G-4G-GPRS-GPS.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Getting Started with LILYGO TTGO T-A7670G ESP32 4G GPRS and GPS\" class=\"wp-image-167128\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/Getting-Started-ESP32-LILYGO.TTGO-T-A7670G-4G-GPRS-GPS.jpg?w=1920&amp;quality=100&amp;strip=all&amp;ssl=1 1920w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/Getting-Started-ESP32-LILYGO.TTGO-T-A7670G-4G-GPRS-GPS.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/Getting-Started-ESP32-LILYGO.TTGO-T-A7670G-4G-GPRS-GPS.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/Getting-Started-ESP32-LILYGO.TTGO-T-A7670G-4G-GPRS-GPS.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/Getting-Started-ESP32-LILYGO.TTGO-T-A7670G-4G-GPRS-GPS.jpg?resize=1536%2C864&amp;quality=100&amp;strip=all&amp;ssl=1 1536w\" 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>You must select the correct board version for your region.<\/p>\n\n\n\n<p>&#8211;  A7670<strong>G<\/strong> =Global (<em>we recommend this version with GPS<\/em>)<\/p>\n\n\n\n<p>&#8211; A7670<strong>E<\/strong> = Europe \/ Southeast Asia \/ South America<\/p>\n\n\n\n<p>&#8211; A7670<strong>SA<\/strong> = South America \/ New Zealand \/ Australia<\/p>\n\n\n\n<p>&#8211; <a href=\"https:\/\/makeradvisor.com\/tools\/lilygo-ttgo-t-a7670g-esp32-4g\/\" target=\"_blank\" rel=\"noopener\" title=\"\">You can buy your LILYGO TTGO T-A7670G board here<\/a><\/p>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>This tutorial focuses on programming the ESP32 using the Arduino core. Before proceeding, you should have the ESP32 Arduino core installed in your Arduino IDE. Follow the next tutorial to install the ESP32 on the Arduino IDE, if you haven\u2019t already.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/installing-esp32-arduino-ide-2-0\/\">Installing the ESP32 Board in Arduino IDE (Windows, Mac OS X, and Linux instructions)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Introducing the LILYGO TTGO T-A7670G ESP32 (with GPS)<\/h2>\n\n\n\n<p>The LILYGO TTGO T-A7670G is an ESP32 development board with a A7670G \/ A7670E \/ A7670SA module. This adds LTE-FDD, GSM, and GPRS to your board. This means that with this board you can send SMS, and connect it to the internet using a SIM card data plan. If you buy the option with GPS, you can get location and time. You can find more information on the <a href=\"https:\/\/github.com\/Xinyuan-LilyGO\/LilyGO-T-A76XX\" target=\"_blank\" rel=\"noopener\" title=\"\">official LilyGO-T-A76XX GitHub repository<\/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\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-overview.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 LILYGO TTGO T-A7670G Dev Board overview\" class=\"wp-image-167081\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-overview.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-overview.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>Besides the A7670G module, the board also comes with some interesting features like a battery holder for an 18650 battery, a battery charging circuit where you can connect solar panels to recharge the battery, and a microSD card slot that can be useful for data logging projects or to save configuration settings.<\/p>\n\n\n\n<p>Here&#8217;s a summary of the LILYGO TTGO T-A7670G ESP32 (with GPS) board features:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Supply voltage: 3.3V DC or 5V DC<\/li>\n\n\n\n<li>ESP32 chip (WROVER-B Module) (240MHz dual-core processor)<\/li>\n\n\n\n<li>Flash memory: 4MB<\/li>\n\n\n\n<li>PSRAM: 8MB<\/li>\n\n\n\n<li>Built-in Wi-Fi<\/li>\n\n\n\n<li>Built-in Bluetooth<\/li>\n\n\n\n<li>USB to serial converter: CP2104 or CH9102 (drivers)<\/li>\n\n\n\n<li>Built-in SIMCOM A7670G module<\/li>\n\n\n\n<li>Built-in nano SIM card slot<\/li>\n\n\n\n<li>Built-in SIM antenna slot<\/li>\n\n\n\n<li>Available with or without GPS<\/li>\n\n\n\n<li>Built-in Li-ion\/Li-Po battery charging circuit:\n<ul class=\"wp-block-list\">\n<li>Solar energy charging interface for 4.4-6V solar panel<\/li>\n\n\n\n<li>Built-in 1x 18650 battery holder<\/li>\n\n\n\n<li>Built-in solar panel connector 2p JST-PH<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Built-in Micro SD card slot<\/li>\n\n\n\n<li>On\/off battery switch<\/li>\n\n\n\n<li>Reset and Boot buttons<\/li>\n\n\n\n<li>Status LEDs<\/li>\n<\/ul>\n\n\n\n<p>Here&#8217;s a quick overview of the board:<\/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=\"868\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-Overview-highlights.jpg?resize=900%2C868&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 LILYGO TTGO T A7670G Dev Board Overview highlights\" class=\"wp-image-167084\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-Overview-highlights.jpg?w=900&amp;quality=100&amp;strip=all&amp;ssl=1 900w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-Overview-highlights.jpg?resize=300%2C289&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-Overview-highlights.jpg?resize=768%2C741&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 900px) 100vw, 900px\" \/><\/figure><\/div>\n\n\n<p>To use the capabilities of this board you need to have a nano SIM card with a data plan and a&nbsp;<a href=\"https:\/\/makeradvisor.com\/tools\/usb-c-data-charging-cable\/\" target=\"_blank\" rel=\"noreferrer noopener\">USB-C cable<\/a>&nbsp;to upload code to the board. The package comes with an external antenna for LTE connection.<\/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\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-with-4G-full-band-LTE-antenna.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 LILYGO TTGO T-A7670G Dev Board with 4G full band LTE antenna\" class=\"wp-image-167075\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-with-4G-full-band-LTE-antenna.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-with-4G-full-band-LTE-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<p>If you buy the <a href=\"https:\/\/makeradvisor.com\/tools\/lilygo-ttgo-t-a7670g-esp32-4g\/\" target=\"_blank\" rel=\"noopener\" title=\"\">LILYGO TTGO T-A7670G<\/a> board with GPS, it will also come with a GPS antenna that you can connect to the board as follows:<\/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\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-with-GPS-connected-antenna.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 LILYGO TTGO T-A7670G Dev Board with GPS connected antenna\" class=\"wp-image-167076\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-with-GPS-connected-antenna.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-with-GPS-connected-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<p>You can also connect a microSD card:<\/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\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-MicroSD-Card-Battery-Holder.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 LILYGO TTGO T-A7670G Dev Board MicroSD Card Battery Holder\" class=\"wp-image-167080\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-MicroSD-Card-Battery-Holder.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-MicroSD-Card-Battery-Holder.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<h4 class=\"wp-block-heading\">Where to buy LILYGO TTGO T-A7670G ESP32?<\/h4>\n\n\n\n<p>Check the following link:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/lilygo-ttgo-t-a7670g-esp32-4g\/\" target=\"_blank\" rel=\"noopener\" title=\"\"><strong>LILYGO TTGO T-A7670G ESP32 (4G, GPRS, and with GPS) &#8211; Maker Advisor<\/strong><\/a><\/li>\n<\/ul>\n\n\n\n<p>You must select the correct board version for your region.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A7670<strong>G<\/strong> =Global (<em>we recommend this version with GPS<\/em>)<\/li>\n\n\n\n<li>A7670<strong>E<\/strong> = Europe \/ Southeast Asia \/ South America<\/li>\n\n\n\n<li>A7670<strong>SA<\/strong> = South America \/ New Zealand \/ Australia<\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/lilygo-ttgo-t-a7670g-esp32-4g\/\" target=\"_blank\" rel=\"noopener\" title=\"\">You can buy your LILYGO\u00ae TTGO T-A7670G board here<\/a><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"535\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-A7670E-A7670SA-Comparison.jpg?resize=800%2C535&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 LILYGO TTGO T A7670G A7670E A7670SA Comparison\" class=\"wp-image-167082\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-A7670E-A7670SA-Comparison.jpg?w=800&amp;quality=100&amp;strip=all&amp;ssl=1 800w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-A7670E-A7670SA-Comparison.jpg?resize=300%2C201&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-A7670E-A7670SA-Comparison.jpg?resize=768%2C514&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">LILYGO TTGO T-A7670G ESP32 Pinout<\/h2>\n\n\n\n<p>The following picture show the pinout of the T-A7670G ESP32 board.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1187\" height=\"1186\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-Pinout.jpg?resize=1187%2C1186&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 LILYGO TTGO T-A7670G Dev Board Pinout\" class=\"wp-image-167083\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-Pinout.jpg?w=1187&amp;quality=100&amp;strip=all&amp;ssl=1 1187w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-Pinout.jpg?resize=300%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-Pinout.jpg?resize=1024%2C1024&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-Pinout.jpg?resize=150%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-Pinout.jpg?resize=768%2C767&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1187px) 100vw, 1187px\" \/><figcaption class=\"wp-element-caption\"><a href=\"https:\/\/cdn.shopify.com\/s\/files\/1\/0617\/7190\/7253\/files\/T-A7670G_600x600.jpg\" target=\"_blank\" rel=\"noreferrer noopener\">Image source<\/a><\/figcaption><\/figure><\/div>\n\n\n<p>The following table shows the connections between the ESP32 and the T-A7670G chip:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>T-A7670G<\/strong><\/td><td><strong>ESP32<\/strong><\/td><\/tr><tr><td>TX<\/td><td><span class=\"rnthl rntcgray\">GPIO 26<\/span><\/td><\/tr><tr><td>RX<\/td><td><span class=\"rnthl rntcgray\">GPIO 27<\/span><\/td><\/tr><tr><td>POWER<\/td><td><span class=\"rnthl rntcred\">GPIO 4<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>To communicate with the microSD card, you need <a href=\"https:\/\/randomnerdtutorials.com\/esp32-spi-communication-arduino\/\" title=\"\">SPI communication protocol<\/a>. These are the GPIOs used:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>MicroSD Card (TF card)<\/strong><\/td><td><strong>ESP32<\/strong><\/td><\/tr><tr><td>MOSI<\/td><td><span class=\"rnthl rntcgray\">GPIO 15<\/span><\/td><\/tr><tr><td>SCLK<\/td><td><span class=\"rnthl rntcpurple\">GPIO 14<\/span><\/td><\/tr><tr><td>CS<\/td><td><span class=\"rnthl rntcgray\">GPIO 13<\/span><\/td><\/tr><tr><td>MISO<\/td><td><span class=\"rnthl rntcpurple\">GPIO 2<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">AT Commands<\/h2>\n\n\n\n<p>AT commands are used to control modems, as is the case of the T-7670G. In the case of the ESP32, you send the AT commands via <a href=\"https:\/\/randomnerdtutorials.com\/esp32-uart-communication-serial-arduino\/\" title=\"\">serial communication protocol<\/a>. Then, the modem responds back also via serial communication.<\/p>\n\n\n\n<p>There are four types of AT commands: test; read; set; execution. You can find the complete list of AT commands for the T-7670G at the following link:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/github.com\/Xinyuan-LilyGO\/LilyGO-T-A76XX\/blob\/main\/datasheet\/A76XX\/A76XX_Series_AT_Command_Manual_V1.09.pdf\" target=\"_blank\" rel=\"noopener\" title=\"\">A7670G \/ A7670E \/ A7670SA \/ A76XX AT Commands<\/a><\/li>\n<\/ul>\n\n\n\n<p>Here are some AT commands:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check communication with the module: <strong>AT<\/strong><\/li>\n\n\n\n<li>Check if SIM card is ready: <strong>AT+CPIN?<\/strong><\/li>\n\n\n\n<li>Check the registration status of the device: <strong>AT+CGREG?<\/strong><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Libraries<\/h2>\n\n\n\n<p>As we explained previously, the ESP32 communicates with the T-7670G 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 TinyGSM library knows which commands to send, and how to handle AT responses, and wraps that into the standard Arduino Client interface.<\/p>\n\n\n\n<p class=\"rntbox rntclgray\"><strong>IMPORTANT:<\/strong> for this tutorial we won&#8217;t use the official TinyGSM library by vshymanskyy. We&#8217;ll be using the TinyGSM-fork by lewisxhe. If you already have the TinyGSM by vshymanskyy library installed, you must remove it to use this new fork.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Installing the TinyGSM-fork Library<\/h4>\n\n\n\n<p>The <a href=\"https:\/\/github.com\/lewisxhe\/TinyGSM-fork\" target=\"_blank\" rel=\"noopener\" title=\"\">TinyGSM-fork by lewisxhe<\/a> library is not available to install through the Arduino Library Manager, so you need to copy the library files to the Arduino installation Libraries folder. Alternatively, in your Arduino IDE, you can go to <strong>Sketch <\/strong>&gt; <strong>Include Library<\/strong> &gt; <strong>Add .zip Library<\/strong> and select the library that can be downloaded below.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/github.com\/lewisxhe\/TinyGSM-fork\/archive\/refs\/heads\/master.zip\" target=\"_blank\" rel=\"noopener\" title=\"\">Click here to download TinyGSM-fork (.zip folder)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Preparing the LILYGO T-7670G ESP32 Board<\/h2>\n\n\n\n<p>This board only supports nano SIM cards. You need a SIM card for 4G and GPRS. To use 4G and GPRS you need&nbsp;a SIM card with some data plan. This can be expensive in some countries, so it might be cost-prohibitive depending on how much you can get a data plan for in your country.<\/p>\n\n\n\n<p>Where we live (Portugal), we can get a SIM card with a data plan, calls, and SMS (enough for ESP32 projects) for approximately $10. We recommend using a SIM card with a prepaid or monthly plan so that you know exactly how much you\u2019ll spend. There are also companies specializing in SIM cards for IoT projects.<\/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\n<p>Before plugging your board to the computer, you need to follow the next steps:<\/p>\n\n\n\n<p><strong>1)<\/strong> Insert a nano SIM card;<\/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=\"423\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-board-with-SIM-Card-inserted.jpg?resize=750%2C423&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 LILYGO TTGO T-A7670G board with SIM Card inserted\" class=\"wp-image-167077\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-board-with-SIM-Card-inserted.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-board-with-SIM-Card-inserted.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>2) <\/strong>Connect the Full Band LTE antenna to the connection;<\/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\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-connected-LTE-band-atenna.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 LILYGO TTGO T-A7670G Dev Board connected LTE band antenna\" class=\"wp-image-167078\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-connected-LTE-band-atenna.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Dev-Board-connected-LTE-band-atenna.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>3)<\/strong> In order to program your board, you must power it using the USB Type-C cable;<\/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\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Board-connected-USB-Type-C-cable.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 LILYGO TTGO T-A7670G Board connected USB Type C cable\" class=\"wp-image-167079\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Board-connected-USB-Type-C-cable.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Board-connected-USB-Type-C-cable.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>4)<\/strong> Finally, if you don&#8217;t see the COM port appearing on your computer, you need to install the CH9102 USB bridge driver: <a href=\"https:\/\/www.wch-ic.com\/downloads\/CH343SER_ZIP.html\" target=\"_blank\" rel=\"noopener\" title=\"\">Windows<\/a> or <a href=\"https:\/\/www.wch-ic.com\/downloads\/CH34XSER_MAC_ZIP.html\" target=\"_blank\" rel=\"noopener\" title=\"\">Mac OS<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">APN Details<\/h2>\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;GPRS APN settings&nbsp;followed by your phone plan provider name, (in my case its: \u201cGPRS APN Vodafone<strong> 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>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\">Programming the LILYGO TTGO T-A7670G ESP32<\/h2>\n\n\n\n<p>This first sketch that you&#8217;ll run on your board is good to check all the connections. It will start the modem, connect to the APN network, and make an HTTPS GET request to a website.<\/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\/lilygo-ttgo-t-a7670g-a7670e-a7670sa-esp32\/\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.  \n  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n*\/\n\/\/ set SIM card pin, if any\n#define SIM_PIN &quot;&quot;\n\n\/\/ It depends on the operator whether you need to set up an APN or not. \n\/\/ With some operators if you do not set up an APN, the connection will be rejected when registering for the network.\n#define NETWORK_APN &quot;REPLACE_WITH_YOUR_NETWORK_APN&quot;\n\n\/\/ If the status code 715 is returned, you might need to update your SIMCOM firmware please see here: https:\/\/github.com\/Xinyuan-LilyGO\/LilyGO-T-A76XX\/issues\/117\n\/\/ How to update the firmware: https:\/\/github.com\/Xinyuan-LilyGO\/LilyGO-T-A76XX\/blob\/main\/docs\/update_fw.md\n\/\/ Some websites block the ESP32 connection, so it might return an error.\n\/\/ The githubusercontent.com URL defined below has been tested and it returns the proper HTTPS GET request\nconst char *request_url[] = {\n  &quot;https:\/\/gist.githubusercontent.com\/RuiSantosdotme\/7db8537cef1c84277c268c76a58d07ff\/raw\/d3fe4cd6eff1ed43e6dbd1883ab7eba8414e2406\/gistfile1.txt&quot;\n};\n\n#define TINY_GSM_RX_BUFFER 1024 \/\/ Set RX buffer to 1Kb\n\n#define LILYGO_T_A7670\n\n#if defined(LILYGO_T_A7670)\n  #define MODEM_BAUDRATE                      (115200)\n  #define MODEM_DTR_PIN                       (25)\n  #define MODEM_TX_PIN                        (26)\n  #define MODEM_RX_PIN                        (27)\n  \/\/ The modem boot pin needs to follow the startup sequence.\n  #define BOARD_PWRKEY_PIN                    (4)\n  #define BOARD_ADC_PIN                       (35)\n  \/\/ The modem power switch must be set to HIGH for the modem to supply power.\n  #define BOARD_POWERON_PIN                   (12)\n  #define MODEM_RING_PIN                      (33)\n  #define MODEM_RESET_PIN                     (5)\n  #define BOARD_MISO_PIN                      (2)\n  #define BOARD_MOSI_PIN                      (15)\n  #define BOARD_SCK_PIN                       (14)\n  #define BOARD_SD_CS_PIN                     (13)\n  #define BOARD_BAT_ADC_PIN                   (35)\n  #define MODEM_RESET_LEVEL                   HIGH\n  #define SerialAT                            Serial1\n  #define MODEM_GPS_ENABLE_GPIO               (-1)\n  #define MODEM_GPS_ENABLE_LEVEL              (-1)\n  #ifndef TINY_GSM_MODEM_A7670\n    #define TINY_GSM_MODEM_A7670\n  #endif\n#endif\n\n\/\/ YOU MUST USE THE TinyGSM-fork LIBRARY BY lewisxhe - https:\/\/github.com\/lewisxhe\/TinyGSM-fork\n\/\/ If you already have the vshymanskyy\/TinyGSM library installed, you must remove it and use the TinyGSM-fork version by lewisxhe mentioned above\n#include &lt;TinyGsmClient.h&gt;\n\n\/\/ See all AT commands, if wanted\n\/\/#define DUMP_AT_COMMANDS\n#ifdef DUMP_AT_COMMANDS  \/\/ if enabled it requires the streamDebugger lib\n  #include &lt;StreamDebugger.h&gt;\n  StreamDebugger debugger(SerialAT, Serial);\n  TinyGsm modem(debugger);\n#else\n  TinyGsm modem(SerialAT);\n#endif\n\nvoid HTTPSGetRequest() {\n  for (int i = 0; i &lt; sizeof(request_url) \/ sizeof(request_url[0]); ++i) {\n    int retry = 3;\n    while (retry--) {\n      Serial.print(&quot;Request URL : &quot;);\n      Serial.println(request_url[i]);\n\n      \/\/ Set GET URT\n      if (!modem.https_set_url(request_url[i])) {\n        Serial.print(&quot;Failed to request : &quot;); Serial.println(request_url[i]);\n        \/\/ Debug\n        \/\/ modem.sendAT(&quot;+CSSLCFG=\\&quot;enableSNI\\&quot;,0,1&quot;);\n        \/\/ modem.waitResponse();\n        delay(3000);\n        continue;\n      }\n\n      \/\/ Send GET request\n      int httpCode = 0;\n      httpCode = modem.https_get();\n      if (httpCode != 200) {\n        Serial.print(&quot;HTTP get failed ! error code = &quot;);\n        Serial.println(httpCode);\n        delay(3000);\n        continue;\n      }\n\n      \/\/ Get HTTPS header information\n      String header = modem.https_header();\n      Serial.print(&quot;HTTP Header : &quot;);\n      Serial.println(header);\n      delay(1000);\n\n      \/\/ Get HTTPS response\n      String body = modem.https_body();\n      Serial.print(&quot;HTTP body : &quot;);\n      Serial.println(body);\n      delay(3000);\n      break;\n    }\n    Serial.println(&quot;-------------------------------------&quot;);\n  }\n}\n\nvoid setup() {\n  Serial.begin(115200);\n  Serial.println(&quot;Init...&quot;);\n  SerialAT.begin(115200, SERIAL_8N1, MODEM_RX_PIN, MODEM_TX_PIN);\n\n  pinMode(BOARD_POWERON_PIN, OUTPUT);\n  digitalWrite(BOARD_POWERON_PIN, HIGH);\n\n  \/\/ Set modem reset pin, reset modem\n  pinMode(MODEM_RESET_PIN, OUTPUT);\n  digitalWrite(MODEM_RESET_PIN, !MODEM_RESET_LEVEL); delay(100);\n  digitalWrite(MODEM_RESET_PIN, MODEM_RESET_LEVEL); delay(2600);\n  digitalWrite(MODEM_RESET_PIN, !MODEM_RESET_LEVEL);\n\n  pinMode(BOARD_PWRKEY_PIN, OUTPUT);\n  digitalWrite(BOARD_PWRKEY_PIN, LOW);\n  delay(100);\n  digitalWrite(BOARD_PWRKEY_PIN, HIGH);\n  delay(100);\n  digitalWrite(BOARD_PWRKEY_PIN, LOW);\n\n  \/\/ Check if the modem is online\n  Serial.println(&quot;Start modem...&quot;);\n\n  int retry = 0;\n  while (!modem.testAT(1000)) {\n    Serial.print(&quot;.&quot;);\n    if (retry++ &gt; 10) {\n      digitalWrite(BOARD_PWRKEY_PIN, LOW);\n      delay(100);\n      digitalWrite(BOARD_PWRKEY_PIN, HIGH);\n      delay(1000);\n      digitalWrite(BOARD_PWRKEY_PIN, LOW);\n      retry = 0;\n    }\n  }\n  Serial.println();\n\n  \/\/ Check if SIM card is online\n  SimStatus sim = SIM_ERROR;\n  while (sim != SIM_READY) {\n    sim = modem.getSimStatus();\n    switch (sim) {\n      case SIM_READY:\n        Serial.println(&quot;SIM card online&quot;);\n        break;\n      case SIM_LOCKED:\n        Serial.println(&quot;The SIM card is locked. Please unlock the SIM card first.&quot;);\n        modem.simUnlock(SIM_PIN);\n        break;\n      default:\n        break;\n    }\n    delay(1000);\n  }\n\n  if (!modem.setNetworkMode(MODEM_NETWORK_AUTO)) {\n    Serial.println(&quot;Set network mode failed!&quot;);\n  }\n  String mode = modem.getNetworkModes();\n  Serial.print(&quot;Current network mode : &quot;);\n  Serial.println(mode);\n\n#ifdef NETWORK_APN\n  Serial.printf(&quot;Set network apn : %s\\n&quot;, NETWORK_APN);\n  modem.sendAT(GF(&quot;+CGDCONT=1,\\&quot;IP\\&quot;,\\&quot;&quot;), NETWORK_APN, &quot;\\&quot;&quot;);\n  if (modem.waitResponse() != 1) {\n    Serial.println(&quot;Set network apn error !&quot;);\n  }\n#endif\n\n  \/\/ Check network registration status and network signal status\n  int16_t sq ;\n  Serial.print(&quot;Wait for the modem to register with the network.&quot;);\n  RegStatus status = REG_NO_RESULT;\n  while (status == REG_NO_RESULT || status == REG_SEARCHING || status == REG_UNREGISTERED) {\n    status = modem.getRegistrationStatus();\n    switch (status) {\n      case REG_UNREGISTERED:\n      case REG_SEARCHING:\n        sq = modem.getSignalQuality();\n        Serial.printf(&quot;[%lu] Signal Quality:%d\\n&quot;, millis() \/ 1000, sq);\n        delay(1000);\n        break;\n      case REG_DENIED:\n        Serial.println(&quot;Network registration was rejected, please check if the APN is correct&quot;);\n        return ;\n      case REG_OK_HOME:\n        Serial.println(&quot;Online registration successful&quot;);\n        break;\n      case REG_OK_ROAMING:\n        Serial.println(&quot;Network registration successful, currently in roaming mode&quot;);\n        break;\n      default:\n        Serial.printf(&quot;Registration Status:%d\\n&quot;, status);\n        delay(1000);\n        break;\n    }\n  }\n  Serial.println();\n\n  Serial.printf(&quot;Registration Status:%d\\n&quot;, status);\n  delay(1000);\n\n  String ueInfo;\n  if (modem.getSystemInformation(ueInfo)) {\n    Serial.print(&quot;Inquiring UE system information:&quot;);\n    Serial.println(ueInfo);\n  }\n\n  if (!modem.setNetworkActive()) {\n    Serial.println(&quot;Enable network failed!&quot;);\n  }\n  delay(5000);\n\n  String ipAddress = modem.getLocalIP();\n  Serial.print(&quot;Network IP:&quot;); Serial.println(ipAddress);\n\n  \/\/ Initialize HTTPS\n  modem.https_begin();\n\n  HTTPSGetRequest();\n}\n\nvoid loop() {\n  \/\/ Debug AT\n  if (SerialAT.available()) {\n    Serial.write(SerialAT.read());\n  }\n  if (Serial.available()) {\n    SerialAT.write(Serial.read());\n  }\n  delay(1);\n}\n\n#ifndef TINY_GSM_FORK_LIBRARY\n  #error &quot;The correct library was NOT found. You must install TinyGSM-fork by lewisxhe - https:\/\/github.com\/lewisxhe\/TinyGSM-fork - No correct definition detected, Please copy all the [lib directories](https:\/\/github.com\/Xinyuan-LilyGO\/LilyGO-T-A76XX\/tree\/main\/lib) to the arduino libraries directory , See README&quot;\n#endif\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_LILYGO_T_A7670G_HTTPS_GET.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 SIM_PIN \"\"<\/code><\/pre>\n\n\n\n<ol start=\"3\"><li>Insert your network APN details on the following line:<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define NETWORK_APN \"t\"<\/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>#define NETWORK_APN \"net2.vodafone.pt\"<\/code><\/pre>\n\n\n\n<ol start=\"4\"><li>Go to <strong>Tools <\/strong>&gt; <strong>Board <\/strong>and select <strong>ESP32 Dev Module<\/strong>.<\/li><\/ol>\n\n\n\n<ol start=\"5\"><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=\"30\" height=\"30\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/05\/arduino-2-0-upload-button.png?resize=30%2C30&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino 2.0 Upload Button\" class=\"wp-image-103678\"\/><\/figure><\/div>\n\n\n<p>Open the Serial Monitor at a baud rate of 115200. Press the on-board RST button to restart the board. Wait some time until the board connects to the network (in my case, it may take 1 to 2 minutes).<\/p>\n\n\n\n<p>You should get something similar in the Arduino IDE Serial Monitor.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"731\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-A7670E-A7670SA-dev-board-HTTPS-GET-Request-Demonstration.png?resize=1024%2C731&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 LILYGO TTGO T-A7670G A7670E A7670SA dev board HTTPS GET Request Demonstration\" class=\"wp-image-167090\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-A7670E-A7670SA-dev-board-HTTPS-GET-Request-Demonstration.png?resize=1024%2C731&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-A7670E-A7670SA-dev-board-HTTPS-GET-Request-Demonstration.png?resize=300%2C214&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-A7670E-A7670SA-dev-board-HTTPS-GET-Request-Demonstration.png?resize=768%2C548&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-A7670E-A7670SA-dev-board-HTTPS-GET-Request-Demonstration.png?resize=1536%2C1097&amp;quality=100&amp;strip=all&amp;ssl=1 1536w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-A7670E-A7670SA-dev-board-HTTPS-GET-Request-Demonstration.png?w=1591&amp;quality=100&amp;strip=all&amp;ssl=1 1591w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\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 relevant parts of code.<\/p>\n\n\n\n<p>First, insert the SIM card pin, APN details, and desired request URL (we&#8217;re just using a sample URL from GitHub that we created to test the connection):<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ set SIM card pin, if any\n#define SIM_PIN \"\"\n\n#define NETWORK_APN \"\"\n\nconst char *request_url&#091;] = {\n  \"https:\/\/gist.githubusercontent.com\/RuiSantosdotme\/7db8537cef1c84277c268c76a58d07ff\/raw\/d3fe4cd6eff1ed43e6dbd1883ab7eba8414e2406\/gistfile1.txt\"\n};<\/code><\/pre>\n\n\n\n<p>Then, you need to define the module you&#8217;re using. The library is compatible with many different modules. To use the T-A7670, include the following line (<a href=\"https:\/\/raw.githubusercontent.com\/Xinyuan-LilyGO\/LilyGO-T-A76XX\/refs\/heads\/main\/examples\/HttpsClient\/utilities.h\" target=\"_blank\" rel=\"noopener\" title=\"\">pin assignment for other T-A76XX modules<\/a>):<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define LILYGO_T_A7670<\/code><\/pre>\n\n\n\n<p>Include the <a href=\"https:\/\/github.com\/lewisxhe\/TinyGSM-fork\" target=\"_blank\" rel=\"noopener\" title=\"\"><span class=\"rnthl rntliteral\">TinyGSM<\/span>-fork library by lewisxhe<\/a>:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;TinyGsmClient.h&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">A-7670G 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 MODEM_BAUDRATE                      (115200)\n#define MODEM_DTR_PIN                       (25)\n#define MODEM_TX_PIN                        (26)\n#define MODEM_RX_PIN                        (27)\n\/\/ The modem boot pin needs to follow the startup sequence.\n#define BOARD_PWRKEY_PIN                    (4)\n#define BOARD_ADC_PIN                       (35)\n\/\/ The modem power switch must be set to HIGH for the modem to supply power.\n#define BOARD_POWERON_PIN                   (12)\n#define MODEM_RING_PIN                      (33)\n#define MODEM_RESET_PIN                     (5)\n#define BOARD_MISO_PIN                      (2)\n#define BOARD_MOSI_PIN                      (15)\n#define BOARD_SCK_PIN                       (14)\n#define BOARD_SD_CS_PIN                     (13)\n#define BOARD_BAT_ADC_PIN                   (35)\n#define MODEM_RESET_LEVEL                   HIGH\n#define SerialAT                            Serial1\n#define MODEM_GPS_ENABLE_GPIO               (-1)\n#define MODEM_GPS_ENABLE_LEVEL              (-1)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Serial Communication<\/h3>\n\n\n\n<p>Start the serial communication with the Serial Monitor for debugging and modem to send AT commands:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.begin(115200);\nSerial.println(\"Init...\");\nSerialAT.begin(115200, SERIAL_8N1, MODEM_RX_PIN, MODEM_TX_PIN);<\/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 always need to include the following procedure to power on and start the modem:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>pinMode(BOARD_POWERON_PIN, OUTPUT);\ndigitalWrite(BOARD_POWERON_PIN, HIGH);\n\n\/\/ Set modem reset pin, reset modem\npinMode(MODEM_RESET_PIN, OUTPUT);\ndigitalWrite(MODEM_RESET_PIN, !MODEM_RESET_LEVEL); delay(100);\ndigitalWrite(MODEM_RESET_PIN, MODEM_RESET_LEVEL); delay(2600);\ndigitalWrite(MODEM_RESET_PIN, !MODEM_RESET_LEVEL);\n\npinMode(BOARD_PWRKEY_PIN, OUTPUT);\ndigitalWrite(BOARD_PWRKEY_PIN, LOW);\ndelay(100);\ndigitalWrite(BOARD_PWRKEY_PIN, HIGH);\ndelay(100);\ndigitalWrite(BOARD_PWRKEY_PIN, LOW);\n\n\/\/ Check if the modem is online\nSerial.println(\"Start modem...\");<\/code><\/pre>\n\n\n\n<p>Wait until the T-A7670 module starts responding to AT commands, so it means it&#8217;s running properly.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>int retry = 0;\nwhile (!modem.testAT(1000)) {\n  Serial.print(\".\");\n  if (retry++ &gt; 10) {\n    digitalWrite(BOARD_PWRKEY_PIN, LOW);\n    delay(100);\n    digitalWrite(BOARD_PWRKEY_PIN, HIGH);\n    delay(1000);\n    digitalWrite(BOARD_PWRKEY_PIN, LOW);\n    retry = 0;\n  }\n}\nSerial.println();<\/code><\/pre>\n\n\n\n<p>After, check if the SIM card is properly inserted and unlock it with the <span class=\"rnthl rntliteral\">SIM_PIN<\/span> if necessary.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Check if SIM card is online\nSimStatus sim = SIM_ERROR;\nwhile (sim != SIM_READY) {\n  sim = modem.getSimStatus();\n  switch (sim) {\n    case SIM_READY:\n      Serial.println(\"SIM card online\");\n      break;\n    case SIM_LOCKED:\n      Serial.println(\"The SIM card is locked. Please unlock the SIM card first.\");\n      modem.simUnlock(SIM_PIN);\n      break;\n    default:\n      break;\n  }\n  delay(1000);\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Set Network Mode<\/h3>\n\n\n\n<p>Set the network mode and APN to establish an internet connection:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>  if (!modem.setNetworkMode(MODEM_NETWORK_AUTO)) {\n    Serial.println(\"Set network mode failed!\");\n  }\n  String mode = modem.getNetworkModes();\n  Serial.print(\"Current network mode : \");\n  Serial.println(mode);\n\n#ifdef NETWORK_APN\n  Serial.printf(\"Set network apn : %s\\n\", NETWORK_APN);\n  modem.sendAT(GF(\"+CGDCONT=1,\\\"IP\\\",\\\"\"), NETWORK_APN, \"\\\"\");\n  if (modem.waitResponse() != 1) {\n    Serial.println(\"Set network apn error !\");\n  }\n#endif<\/code><\/pre>\n\n\n\n<p>Then, run a loop that checks for the signal quality and stops when the board has established a successful internet connection.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Check network registration status and network signal status\nint16_t sq ;\nSerial.print(\"Wait for the modem to register with the network.\");\nRegStatus status = REG_NO_RESULT;\nwhile (status == REG_NO_RESULT || status == REG_SEARCHING || status == REG_UNREGISTERED) {\n  status = modem.getRegistrationStatus();\n  switch (status) {\n    case REG_UNREGISTERED:\n    case REG_SEARCHING:\n      sq = modem.getSignalQuality();\n      Serial.printf(\"&#091;%lu] Signal Quality:%d\\n\", millis() \/ 1000, sq);\n      delay(1000);\n      break;\n    case REG_DENIED:\n      Serial.println(\"Network registration was rejected, please check if the APN is correct\");\n      return ;\n    case REG_OK_HOME:\n      Serial.println(\"Online registration successful\");\n      break;\n    case REG_OK_ROAMING:\n      Serial.println(\"Network registration successful, currently in roaming mode\");\n      break;\n    default:\n      Serial.printf(\"Registration Status:%d\\n\", status);\n      delay(1000);\n      break;\n  }\n}\nSerial.println();\n\nSerial.printf(\"Registration Status:%d\\n\", status);\ndelay(1000);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Get Modem Info<\/h3>\n\n\n\n<p>You can run these commands to print the modem information in the Serial Monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>String ueInfo;\nif (modem.getSystemInformation(ueInfo)) {\n  Serial.print(\"Inquiring UE system information:\");\n  Serial.println(ueInfo);\n}\n\nif (!modem.setNetworkActive()) {\n  Serial.println(\"Enable network failed!\");\n}\ndelay(5000);\n\nString ipAddress = modem.getLocalIP();\nSerial.print(\"Network IP:\"); Serial.println(ipAddress);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">HTTPS GET Request<\/h3>\n\n\n\n<p>In order to make an HTTPS GET request to the <span class=\"rnthl rntliteral\">request_url<\/span> variable defined at the beginning of the sketch, you need to start an HTTPS client:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>modem.https_begin();<\/code><\/pre>\n\n\n\n<p>Finally, call the <span class=\"rnthl rntliteral\">HTTPSGetRequest()<\/span> to make the HTTPS GET request. This function will print the HTTP code, HTTP header and HTTP body of the request:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>HTTPSGetRequest();<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">HTTPSGetRequest()<\/h3>\n\n\n\n<p>This function receives one or multiple URLs, then it makes 3 attempts to GET a valid HTTPS response from a website. It prints some debugging information in the Serial Monitor such as the HTTP code, HTTP header and HTTP body from the response.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void HTTPSGetRequest() {\n  for (int i = 0; i &lt; sizeof(request_url) \/ sizeof(request_url&#091;0]); ++i) {\n    int retry = 3;\n    while (retry--) {\n      Serial.print(\"Request URL : \");\n      Serial.println(request_url&#091;i]);\n\n      \/\/ Set GET URT\n      if (!modem.https_set_url(request_url&#091;i])) {\n        Serial.print(\"Failed to request : \"); Serial.println(request_url&#091;i]);\n        \/\/ Debug\n        \/\/ modem.sendAT(\"+CSSLCFG=\\\"enableSNI\\\",0,1\");\n        \/\/ modem.waitResponse();\n        delay(3000);\n        continue;\n      }\n\n      \/\/ Send GET request\n      int httpCode = 0;\n      httpCode = modem.https_get();\n      if (httpCode != 200) {\n        Serial.print(\"HTTP get failed ! error code = \");\n        Serial.println(httpCode);\n        delay(3000);\n        continue;\n      }\n\n      \/\/ Get HTTPS header information\n      String header = modem.https_header();\n      Serial.print(\"HTTP Header : \");\n      Serial.println(header);\n      delay(1000);\n\n      \/\/ Get HTTPS response\n      String body = modem.https_body();\n      Serial.print(\"HTTP body : \");\n      Serial.println(body);\n      delay(3000);\n      break;\n    }\n    Serial.println(\"-------------------------------------\");\n  }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting Tips<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Code fails to compile<\/h3>\n\n\n\n<p><strong>IMPORTANT:<\/strong> for this tutorial, we&#8217;re not using the official TinyGSM library by vshymanskyy. We&#8217;re using the TinyGSM-fork by lewisxhe. If you already have the TinyGSM by vshymanskyy library installed, you must remove it.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Installing the TinyGSM-fork Library<\/h4>\n\n\n\n<p>The <a href=\"https:\/\/github.com\/lewisxhe\/TinyGSM-fork\" target=\"_blank\" rel=\"noopener\" title=\"\">TinyGSM-fork by lewisxhe<\/a> library is not available to install through the Arduino Library Manager, so you need to copy the library files to the Arduino installation Libraries folder. Alternatively, in your Arduino IDE, you can go to <strong>Sketch <\/strong>&gt; <strong>Include Library<\/strong> &gt; <strong>Add .zip Library<\/strong> and select the library that can be downloaded below.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/github.com\/lewisxhe\/TinyGSM-fork\/archive\/refs\/heads\/master.zip\" target=\"_blank\" rel=\"noopener\" title=\"\">Click here to download TinyGSM-fork (.zip folder)<\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. HTTPS GET Request returns status code 715<\/h3>\n\n\n\n<p>If you make an HTTPS GET request to a website and it returns the status code 715, you might need to update your SIMCOM firmware. You can <a href=\"https:\/\/github.com\/Xinyuan-LilyGO\/LilyGO-T-A76XX\/issues\/117\" target=\"_blank\" rel=\"noopener\" title=\"\">learn more about this issue here<\/a>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/github.com\/Xinyuan-LilyGO\/LilyGO-T-A76XX\/blob\/main\/docs\/update_fw.md\" target=\"_blank\" rel=\"noopener\" title=\"\">How to update the firmware SIMCOM T-A7670<\/a><\/li>\n<\/ul>\n\n\n\n<p>Please note that some websites block the ESP32 connection, so it might return an HTTP error. The githubusercontent.com URL defined in this project has been tested and it returns the proper HTTPS GET request.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Can&#8217;t upload code, because the COM port doesn&#8217;t appear<\/h3>\n\n\n\n<p>In order to program your board, you must power it using the USB Type-C cable, if you use the other USB port it will not allow you to program the ESP32.<\/p>\n\n\n\n<p>You also need to install in your computer the CH9102 USB bridge driver: <a href=\"https:\/\/www.wch-ic.com\/downloads\/CH343SER_ZIP.html\" target=\"_blank\" rel=\"noopener\" title=\"\">Windows<\/a> or <a href=\"https:\/\/www.wch-ic.com\/downloads\/CH34XSER_MAC_ZIP.html\" target=\"_blank\" rel=\"noopener\" title=\"\">Mac OS<\/a>.<\/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\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Board-connected-USB-Type-C-cable.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 LILYGO TTGO T-A7670G Board connected USB Type C cable\" class=\"wp-image-167079\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Board-connected-USB-Type-C-cable.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/01\/ESP32-LILYGO-TTGO-T-A7670G-Board-connected-USB-Type-C-cable.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<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this tutorial, you learned how to get started with the LILYGO TTGO T-A7670G ESP32 board, pinout, and it&#8217;s main features. This tutorial can also be applied if you&#8217;re using a &#8220;regular&#8221; ESP32 connected to an external SIM7670G module. This module supports 4G which can be very useful for IoT and Home Automation projects. You also learned how to connect the board to the internet and make an HTTPS GET request<\/p>\n\n\n\n<p>The LILYGO TTGO T-A7670G ESP32 board also comes with a <a href=\"https:\/\/randomnerdtutorials.com\/esp32-microsd-card-arduino\/\" title=\"\">microSD card slot<\/a> that can be useful for datalogging projects or to save configuration settings. Furthermore, it comes with a battery holder and a battery charging circuit to use with solar panels. So, it&#8217;s suitable to use in remote locations. However, I haven&#8217;t experimented with the battery circuit yet. For more examples, you can explore the the official <a href=\"https:\/\/github.com\/Xinyuan-LilyGO\/LilyGO-T-A76XX\/tree\/main\/examples\" target=\"_blank\" rel=\"noopener\" title=\"\">LILYGO T-A76XX GitHub page<\/a>.<\/p>\n\n\n\n<p>Do you have one of these boards? What do you think? Let us know in the comments below.<\/p>\n\n\n\n<p>You may also like the following guides:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\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\n\n\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-sim800l-publish-data-to-cloud\/\">ESP32 Publish Data to Cloud without Wi-Fi (TTGO T-Call ESP32 SIM800L)<\/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\/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>Get started with the ESP32 and the T-A7670G 4G\/GPS\/GPRS module. Throughout this guide, we&#8217;ll use the LILYGO TTGO T-A7670G ESP32 board that combines the ESP32 chip, the A7670G (or A7670E, &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Getting Started with LILYGO TTGO T-A7670G ESP32 (4G, GPRS, and GPS)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/lilygo-ttgo-t-a7670g-a7670e-a7670sa-esp32\/#more-167043\" aria-label=\"Read more about Getting Started with LILYGO TTGO T-A7670G ESP32 (4G, GPRS, and GPS)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":167128,"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-167043","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\/2025\/01\/Getting-Started-ESP32-LILYGO.TTGO-T-A7670G-4G-GPRS-GPS.jpg?fit=1920%2C1080&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/167043","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=167043"}],"version-history":[{"count":18,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/167043\/revisions"}],"predecessor-version":[{"id":168253,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/167043\/revisions\/168253"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/167128"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=167043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=167043"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=167043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}