Connect ESP32 to Cloud MQTT Broker (TTGO T-Call ESP32 SIM800L)
How to connect the TTGO T-Call ESP32 SIM800L board to the Internet using a SIM card data plan and publish data to the cloud MQTT broker without using Wi-Fi with Arduino IDE.
- Suitable forB.Tech/Diploma IoT/ESP32 students
- Build time1-2 weeks
- LevelIntermediate
- Available atAjvika Labs, Kakinada
About this project
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’ll also use Node-RED to visualize the readings and control the outputs from anywhere. The board will be programmed using Arduino IDE.
With this setup, you can monitor and control your ESP32 from anywhere in the world, and the ESP32 doesn’t need to be connected to a wireless router because it connects to the internet using a SIM card data plan.
Introducing the TTGO T-Call ESP32 SIM800L
The TTGO T-Call is an ESP32 development board that combines a SIM800L GSM/GPRS module.
You can get if for approximately $11
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’t have access to a nearby router.
Important:
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’t work.
To use the capabilities of this board you need to have a nano SIM card with data plan and a
USB-C cable
to upload code to the board.
The package includes some header pins, a battery connector, and an external antenna that you should connect to your board.
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.
Project Overview
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’t need to have access to a router via Wi-Fi, because it connects to the internet using a SIM card data plan.
In a previous project
, we created our own server with a database to plot sensor readings in charts that you can access from anywhere in the world.
In this project, we’ll publish sensor readings to a server via MQTT and we’ll use Mosquitto broker. You can publish your sensor readings to any other cloud broker.
In summary, here’s how the project works:
The T-Call ESP32 SIM800L board is connected to the internet using a SIM card data plan.
The T-Call ESP32 SIM800L board publishes the sensor readings via MQTT and the readings are displayed in Node-RED Dashboard.
Through Node-RED Dashboard, you can press buttons to send on and off commands to control the ESP32 GPIOs.
We’ll be using a
BME280 sensor
, but you can use any other sensor that best suits your needs.
Cloud MQTT Broker
You can search for a free cloud MQTT broker, however we’ll be using our own cloud MQTT broker. We recommend using
Digital Ocean with MQTT Mosquitto Broker
, because it can handle all the project requirements. We’ll also use
Node-RED software
to visualize the readings in gauges and publish MQTT messages to the ESP32.
Run Your Cloud MQTT Mosquitto Broker (access from anywhere using Digital Ocean)
Access Node-RED Dashboard from Anywhere (using Digital Ocean)
Prerequisites
1. ESP32 add-on Arduino IDE
We’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’t already.
Installing the ESP32 Board in Arduino IDE (Windows, Mac OS X, Linux)
2. Preparing your Cloud MQTT Broker
In this project we’ll show you how to exchange data via MQTT using a cloud MQTT broker.
We’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…
If you want to follow this exact project, you should follow the next two tutorials to prepare your own server and Node-RED software.
Run Your Cloud MQTT Mosquitto Broker (access from anywhere using Digital Ocean)
Access Node-RED Dashboard from Anywhere (using Digital Ocean)
The ESP32 is publishing temperature readings every 30 seconds on the
esp/temperature
and
esp/humidity
topics. It’s subscribed to these two topics
esp/output1
and
esp/output2
to update the state of the output LEDs.
Having Node-RED running, go to your server IP address followed by :1880.
http://cloud-mqtt-broker-ip-address:1880
Wire your nodes as shown below:
Finally, deploy your flow (press the button on the upper right corner).
Alternatively, you can go to
Menu
>
Import
and copy the following to your
Clipboard
to create your Node-RED flow.
[{"id":"a2c394d8.1544e8","type":"mqtt in","z":"537cca59.c4a014","name":"","topic":"esp/temperature","qos":"2","datatype":"auto","broker":"18f874c0.4a464b","x":140,"y":1020,"wires":[["6907217e.f39bf"]]},{"id":"b83c2ecf.8ab94","type":"mqtt in","z":"537cca59.c4a014","name":"","topic":"esp/humidity","qos":"2","datatype":"auto","broker":"18f874c0.4a464b","x":130,"y":1100,"wires":[["c92e354e.a27d48"]]},{"id":"ee844c66.3eda2","type":"mqtt out","z":"537cca59.c4a014","name":"","topic":"esp/output1","qos":"1","retain":"","broker":"18f874c0.4a464b","x":330,"y":1180,"wires":[]},{"id":"54540fba.e5877","type":"mqtt out","z":"537cca59.c4a014","name":"","topic":"esp/output2","qos":"1","retain":"","broker":"18f874c0.4a464b","x":330,"y":1260,"wires":[]},{"id":"56080a9a.c7bba4","type":"ui_switch","z":"537cca59.c4a014","name":"","label":"Output 1","tooltip":"","group":"1539f836.ed9378","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":120,"y":1180,"wires":[["ee844c66.3eda2"]]},{"id":"417bd6d1.1d1468","type":"ui_switch","z":"537cca59.c4a014","name":"","label":"Output 2","tooltip":"","group":"1539f836.ed9378","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":120,"y":1260,"wires":[["54540fba.e5877"]]},{"id":"6907217e.f39bf","type":"ui_gauge","z":"537cca59.c4a014","name":"","group":"1539f836.ed9378","order":2,"width":0,"height":0,"gtype":"gage","title":"Temperature","label":"Celsius Degrees","format":"{{value}}","min":"-10","max":"40","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":350,"y":1020,"wires":[]},{"id":"c92e354e.a27d48","type":"ui_gauge","z":"537cca59.c4a014","name":"","group":"1539f836.ed9378","order":2,"width":0,"height":0,"gtype":"gage","title":"Humidity","label":"%","format":"{{value}}","min":"0","max":"100","colors":["#93dae6","#0074cc","#002561"],"seg1":"","seg2":"","x":340,"y":1100,"wires":[]},{"id":"18f874c0.4a464b","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"1539f836.ed9378","type":"ui_group","z":"","name":"Dashboard","tab":"38becbd0.c13714","order":1,"disp":true,"width":"6","collapse":false},{"id":"38becbd0.c13714","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
3. SIM Card with data plan
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’ll spend.
4. APN Details
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.
In my case, I’m using vodafone Portugal. If you search for
GPRS APN settings
followed by your phone plan provider name, (in my case its: “
GPRS APN vodafone Portugal
”), you can usually find in a forum or in their website all the information that you need.
I’ve foun
With this setup, you can monitor and control your ESP32 from anywhere in the world, and the ESP32 doesn’t need to be connected to a wireless router because it connects to the internet using a SIM card data plan.
Introducing the TTGO T-Call ESP32 SIM800L
The TTGO T-Call is an ESP32 development board that combines a SIM800L GSM/GPRS module.
You can get if for approximately $11
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’t have access to a nearby router.
Important:
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’t work.
To use the capabilities of this board you need to have a nano SIM card with data plan and a
USB-C cable
to upload code to the board.
The package includes some header pins, a battery connector, and an external antenna that you should connect to your board.
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.
Project Overview
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’t need to have access to a router via Wi-Fi, because it connects to the internet using a SIM card data plan.
In a previous project
, we created our own server with a database to plot sensor readings in charts that you can access from anywhere in the world.
In this project, we’ll publish sensor readings to a server via MQTT and we’ll use Mosquitto broker. You can publish your sensor readings to any other cloud broker.
In summary, here’s how the project works:
The T-Call ESP32 SIM800L board is connected to the internet using a SIM card data plan.
The T-Call ESP32 SIM800L board publishes the sensor readings via MQTT and the readings are displayed in Node-RED Dashboard.
Through Node-RED Dashboard, you can press buttons to send on and off commands to control the ESP32 GPIOs.
We’ll be using a
BME280 sensor
, but you can use any other sensor that best suits your needs.
Cloud MQTT Broker
You can search for a free cloud MQTT broker, however we’ll be using our own cloud MQTT broker. We recommend using
Digital Ocean with MQTT Mosquitto Broker
, because it can handle all the project requirements. We’ll also use
Node-RED software
to visualize the readings in gauges and publish MQTT messages to the ESP32.
Run Your Cloud MQTT Mosquitto Broker (access from anywhere using Digital Ocean)
Access Node-RED Dashboard from Anywhere (using Digital Ocean)
Prerequisites
1. ESP32 add-on Arduino IDE
We’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’t already.
Installing the ESP32 Board in Arduino IDE (Windows, Mac OS X, Linux)
2. Preparing your Cloud MQTT Broker
In this project we’ll show you how to exchange data via MQTT using a cloud MQTT broker.
We’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…
If you want to follow this exact project, you should follow the next two tutorials to prepare your own server and Node-RED software.
Run Your Cloud MQTT Mosquitto Broker (access from anywhere using Digital Ocean)
Access Node-RED Dashboard from Anywhere (using Digital Ocean)
The ESP32 is publishing temperature readings every 30 seconds on the
esp/temperature
and
esp/humidity
topics. It’s subscribed to these two topics
esp/output1
and
esp/output2
to update the state of the output LEDs.
Having Node-RED running, go to your server IP address followed by :1880.
http://cloud-mqtt-broker-ip-address:1880
Wire your nodes as shown below:
Finally, deploy your flow (press the button on the upper right corner).
Alternatively, you can go to
Menu
>
Import
and copy the following to your
Clipboard
to create your Node-RED flow.
[{"id":"a2c394d8.1544e8","type":"mqtt in","z":"537cca59.c4a014","name":"","topic":"esp/temperature","qos":"2","datatype":"auto","broker":"18f874c0.4a464b","x":140,"y":1020,"wires":[["6907217e.f39bf"]]},{"id":"b83c2ecf.8ab94","type":"mqtt in","z":"537cca59.c4a014","name":"","topic":"esp/humidity","qos":"2","datatype":"auto","broker":"18f874c0.4a464b","x":130,"y":1100,"wires":[["c92e354e.a27d48"]]},{"id":"ee844c66.3eda2","type":"mqtt out","z":"537cca59.c4a014","name":"","topic":"esp/output1","qos":"1","retain":"","broker":"18f874c0.4a464b","x":330,"y":1180,"wires":[]},{"id":"54540fba.e5877","type":"mqtt out","z":"537cca59.c4a014","name":"","topic":"esp/output2","qos":"1","retain":"","broker":"18f874c0.4a464b","x":330,"y":1260,"wires":[]},{"id":"56080a9a.c7bba4","type":"ui_switch","z":"537cca59.c4a014","name":"","label":"Output 1","tooltip":"","group":"1539f836.ed9378","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":120,"y":1180,"wires":[["ee844c66.3eda2"]]},{"id":"417bd6d1.1d1468","type":"ui_switch","z":"537cca59.c4a014","name":"","label":"Output 2","tooltip":"","group":"1539f836.ed9378","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":120,"y":1260,"wires":[["54540fba.e5877"]]},{"id":"6907217e.f39bf","type":"ui_gauge","z":"537cca59.c4a014","name":"","group":"1539f836.ed9378","order":2,"width":0,"height":0,"gtype":"gage","title":"Temperature","label":"Celsius Degrees","format":"{{value}}","min":"-10","max":"40","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":350,"y":1020,"wires":[]},{"id":"c92e354e.a27d48","type":"ui_gauge","z":"537cca59.c4a014","name":"","group":"1539f836.ed9378","order":2,"width":0,"height":0,"gtype":"gage","title":"Humidity","label":"%","format":"{{value}}","min":"0","max":"100","colors":["#93dae6","#0074cc","#002561"],"seg1":"","seg2":"","x":340,"y":1100,"wires":[]},{"id":"18f874c0.4a464b","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"1539f836.ed9378","type":"ui_group","z":"","name":"Dashboard","tab":"38becbd0.c13714","order":1,"disp":true,"width":"6","collapse":false},{"id":"38becbd0.c13714","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
3. SIM Card with data plan
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’ll spend.
4. APN Details
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.
In my case, I’m using vodafone Portugal. If you search for
GPRS APN settings
followed by your phone plan provider name, (in my case its: “
GPRS APN vodafone Portugal
”), you can usually find in a forum or in their website all the information that you need.
I’ve foun
Technologies used
Hardware components
- ESP32
- Arduino
- BME280
- SIM800
Software & tools
- Arduino IDE
- Node-RED
- MQTT
What you get
- Working project / hardware kit, tested before delivery
- Complete source code with explanation
- Project demo and guidance for your viva
- Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed.
Payment is in two parts:
• 50% advance to start the project
• Remaining 50% before delivery
Note:
• Documentation and PPT are not included by default
• If you need documentation/PPT, it can be arranged for extra time and cost
We'll confirm the exact timeline and cost with you after reviewing your requirements.