GSM Based Web Server on Esp32 with Public APN

Hello,

I have created a webserver in ESP32 using AsyncWebServer Library and Wifi connection. the web server handles the http (GET and POST)request very well, But this server requires Wifi and is restricted to one place and it is local.

Hence therefore, I want to acheive the same task using GSM Module where the client send a Http(GET and POST) requests to web server running at ESP32-S3 using GSM Module. I have a private apn through Sim card provider, my GSM module is Sim7607G and Controller is ESP32-S3.

Is there any library or way to create a webserver on Esp32 like I did using wifi? but with GSM Moduel.

Looking forward for suggestions.

I am not sure how this would help make your server reachable from anywhere .

A private APN usually assigns private, non-routable IP addresses that are isolated from the public internet. External devices cannot directly reach the server because the assigned IP is only accessible within the private network of the provider.

Many private APNs are designed for internal corporate use and block inbound traffic from the internet. The provider typically uses Network Address Translation and firewall rules that prevent incoming connections.

Can you add colors to your ultimate goal and network topology ?

It does require WiFi but by poking holes into your WiFi network (open ports and use ports forwarding and possibly DynDNS ) you could make the ESP visible to/reachable from the internet.

If there is no local WiFi, create one ➜ It would probably be easier to add your SIM card into a 4G/5G WiFi router and use your code as is, joining the WLAN of the router.

Hello @J-M-L, thanks for your response!

I'm planning to use a group of SIM cards that are locally connected to each other — similar to how multiple computers are connected through a switch. These SIM cards will never access the internet, and they don’t need to.

Let’s consider a simple scenario with two SIM cards, both able to communicate within the same private APN.

  • One SIM will be inserted into a GSM module connected to an ESP32, which will act as a web server.
  • The other SIM will be inserted into another GSM module, which will act as a client, sending HTTP GET and POST requests to the ESP32 server.

My goal is to set up a local GSM-based communication system between these modules without internet access.

ah OK - got it. Yes that would work from a network perspective as both devices would appear in the same virtual network although you would need to confirm with your provider how IP assignment works for your specific private APN to ensure both devices end up within the same subnet (usually the case - mobile network provider assigns IP addresses based on the APN configuration, and devices on the same private APN are often given IP addresses from a reserved pool within the same subnet).

I've never used an ESP32 with onboard SIM card, so you would to explore possibly libraries such as TinyGsm or Adafruit FONA or if you can change platform, what Arduino offers with the MKR NB 1500

1 Like

Yes, what I hope both devices will end up within the same subnet. I will explore TinyGsm or Adafruit FONA, but I don't think they don't create a server in esp32.

No they won’t create a server but you need a route between the traditional network stack and the cell network connection. If that works then it would be transparent for the web server code as it relies on higher level APis.

Dear Jackson,

Thank you for your assistance.

As a beginner in networking, Wi-Fi, and IP stack concepts, I find it a bit challenging to understand how messages are transmitted through the various layers of the network stack.

I would greatly appreciate it if you could kindly explain your previous explanation in more detail to help me better grasp the concepts.

Additionally, I have come across a resource that outlines how to set up a web server, which I believe could be relevant to our discussion. Please feel free to review it as well.

https://docs.arduino.cc/retired/library-examples/gsm-library/GSMExamplesWebServer/

Systems are designed around the OSI model, which separates networking into layers so that applications can work without needing to understand how data moves through the network,.

Using a web server without worrying about the network is like sending a letter through the mail.

You just write the recipient’s name and address on the envelope and drop it in a mailbox. You don’t need to know how postal workers sort the mail, which trucks or planes transport it, or the exact route it takes. The postal system handles everything behind the scenes, and the letter arrives at the right place.

Similarly, when you write code for a web server, you just tell it to listen for requests and send responses. The networking system takes care of routing the data, managing connections, and handling IP addresses without you needing to worry about it.

Basically Your code only deals with high-level actions like starting a server, listening for requests, and sending responses. The functions in the API takes care of opening network sockets, handling IP addresses, and managing connections.

This abstraction makes it possible to write the same web server code whether the connection is over Wi-Fi, Ethernet, or a GSM module. The lower-level networking details are hidden, so you can focus on handling requests and responses..

So what you need to find out is a library that provides the network connectivity layer in a transparent way for the higher level APIs. In the Arduino built for cell and WiFI communication I think it’s done that way. I don’t know what’s provided for the ESP32 with an on board SIM card.

1 Like