It is my belief that modules like the SIM900a are intended to enable a device (Pi in this case) to connect to a remote machine, pull or push some data over mobile networks (2G/3G etc).
To do that the module will
- use the SIM card inserted to connect to a mobile network
- get a dynamic IP address assigned (leased is the term if I am not mistaken) for the duration of connectivity.
Up and down speeds depend on the network and are typically asymmetrical (meaning download speeds are higher than upload speeds)
This mode of usage is pretty much opposite to what you are looking for.
Typically there are number of considerations that would go into configuring a system that is going to be exposed to public such as
security, load balancing etc.
Assuming your use case doesn't require such rigorous effort or considerations but just a simple system that allows you to remotely access some information on your Pi from another system, you will need to deal with at least the following
have a "server" application that hosts the files (say using
apache) you intend to serve or a dynamically generated files (Ruby On Rails, Django or CherryPy using Python, ASP.NET/Mono etc)
firewall that limits the ports accessible and controls the request traffic
register a domain name and keep the dns current with the dynamic IP address assigned - this is only required during final deployment to allow external machines to find the current IP address. For testing you can skip this and just directly use entering the IP address assigned (by querying the module via AT commands) on the external machine's browser.
this, this and this should get you started.
Couple of things to remember are
- data transfer up or down on mobile networks are generally much more expensive and or limited compared to wired networks
- mobile networks might not be as reliable as wired networks (depending on where you deploy the setup)
Update based on comments below
Given the challenges I've mentioned above, Here is how I'd approach the problem
I have decribed them in the above 3 bullet points
Offline setup using a intermediate server / cloud storage such as google drive
PI side of things
- create a (incremental) backup of your MySQL database into a file say named
using a tool such as mysqldump
- if the backup files are large, use a compression such as 7z or tar.gz to produces smaller backups
- write a python script the will upload the backup archive to google drive using an API such as
- create cron jobs to execute
the above 2 tasks every hour or as frequently as required
Desktop side of things
- connect (programatically if required) to the google drive, check for updates and download the latest backups
- decompress if required and restore or update a local copy of the database using a tool such as
- make all queries against the local database in the VB program
some pros/cons of this approach I can think of
- if there are problems on the Rpi side of things like corrupted file system, h/w failure, bad network etc,
at least the last uploaded backups would still be available instead of a completely offline system
- the client (Desktop) and server(Rpi) are decoupled so it becomes easier to access the data from other client machines
- as this is a non real time setup the latest data available wont be available until the backup is uploaded and restored on the client machine
Further Updates on SIM900A module
In the spirit of improving on my answer, I dug a little deeper and came across this blog post which describes a similar attempt to host a web server behind a SIM900A module. Sorry to be bearer of bad news but, unfortunately the blogger's experience matches mine own suspicion on the way the module operates. Here's a extract from his blog
Are you thinking to use your SIM900 GSM/GPRS module as TCP server then you should re consider your decision. Because although SIM900 can run as a TCP server and has all the commands and software support inside, it cannot be directly used.
SIM900 supports TCP communication in both client mode and server mode. Client mode is straight forward and you can see the tutorial at this link,
How to get SIM900 running as a TCP server?
Now if you want to use SIM900 as TCP server you need to get its Public IP address and not the one you get when you issue the command AT+CIFSR because it is a local IP address. To get the public IP address you need to connect to some server and note down the IP address shown there.
If you are thinking, "Yes, we got the public IP and now we can just configure SIM900 as TCP server and connect to it." ... No you can't !!
I too was shocked when i came to know about this. The network service provider companies don't allow inbound connections, so no external device can directly connect to the SIM900 running as a TCP server. Because they use shared IP addresses and a single public IP address is shared by many more devices like SIM900.
Whats the Solution?
So if you want to use a SIM900 as a TCP server you need to get a private APN and a static IP from the network provider and connect. Its expensive and not affordable for small players and hobbyists. But there is no other option. Without this, its not possible !
Source: Reply from M2M company,
While using our test package, IP addresses are assigned dynamically to the devices because the test package includes our shared APN m2m.tag.com.
this APN we are using the NAT method, which means that privates IP addresses are assigned to the devices, which are NATed to the public IP 184.108.40.206.
Therefore inbound connections to the SIM cards are not possible while using this APN (or any other APN with NAT).
If you need these functionalities ins the future, we recommend to order a private APN with VPN/IPsec connection. Another advantage of a private APN is, that
you can define if the IP address assignment should be dynamic or static.
and more bad experiences.
Even an arduino example hints it might not work which quotes
if you cannot connect to the IP address, make sure your network operator enables incoming traffic.
In conclusion, I also understand the need for such measures from mobile carriers though .. imagine each mobile phone or device with such a sim900a like module potentially becoming a web server (ignoring other concerns such as security), I doubt there are enough ipv4 addresses available.