SIMCom SIM800/SIM900 GSM/GPRS Module
The SIM900 is a GSM/GPRS module that can provide internet access via an AT command set.
Support is provided in Espruino by the SIM900 (About Modules) module.
Both SIM900 and SIM900A use the same command set and so are compatible with this Espruino driver, however SIM900A is dual band (often locked to Asia), while SIM900 is quad band.
Note: Many SIM900A modules only work in Asia - see this site for details on how to modify them
If you want more information, or need to send your own commands to the SIM900 module, check out the SIM900 AT Command Manual
Note: If you want to send and receive SMS text messages then check out the ATSMS module.
Wiring Up
Pin | Espruino | Pico | Notes |
---|---|---|---|
VCC5 | Bat | 5V/VCC | 5V input (see note below) |
VCCMCU / VIO | 3.3v | 3.3v | 3.3v input |
GND | GND | GND | |
RST | B4 | B4 | Reset Pin |
SIMR / RXD | B6 | B6 | Serial data Espruino -> SIM900 |
SIMT / TXD | B7 | B7 | Serial data SIM900 -> Espruino |
You don't need to wire up reset, and can instead just pass undefined
into the require('SIM900').connect
call shown below.
Once wired up, power is applied, and the PWR
button is held down for 2 seconds a 'Network Connection' LED should flash every second to show that the SIM900 is trying to connect. Once connected, the light will slow down to flashing every 3 seconds and the SIM900 is ready to use.
Note: If the SIM800/SIM900 powers down after a few seconds of flashing, check your battery/power supply. These modules draw a lot of power when they transmit, and will shut themselves down if your battery is unable to provide enough. Some modules use two diodes to drop the voltage from 5V to something acceptable for the SIM900, which means that even a LiPo battery won't provide enough power.
Software
Just use something like the following for the Espruino Pico:
Serial1.setup(115200, { rx: B7, tx : B6 });
console.log("Connecting to SIM900 module");
var gprs = require('SIM900').connect(Serial1, B4 /*reset*/, function(err) {
if (err) throw err;
gprs.connect('APN', 'USERNAME', 'PASSWORD', function(err) {
if (err) throw err;
gprs.getIP(function(err, ip) {
if (err) throw err;
console.log('IP:' + ip);
require("http").get("http://www.pur3.co.uk/hello.txt", function(res) {
console.log("Response: ",res);
res.on('data', function(d) {
console.log("--->"+d);
});
});
});
});
});
You'll need to replace APN
, USERNAME
, and PASSWORD
with your mobile carrier's access point settings.
For instance for Vodefone in the UK, use:
gprs.connect('internet', 'web', 'web', function(err) { ... });
Reference
gprs.at
The AT command handler - use this to send your own AT commands to the SIM900
You can also call gprs.at.debug()
to return debugging information and to turn
on debug messages.
gprs.debug()
Return information on open sockets and received data.
gprs.init(function(err) { ... })
Initialise WiFi settings - you shouldn't ever need to call this. The callback is called with err==null
on success.
gprs.reset(function(err) { ... });
Reset the SIM900 by pulsing the RST wire.
gprs.getVersion(function(err, version) { ... });
Call the callback with the version number reported back from the AT+GMR
command. The callback is called with err==null
on success.
gprs.connect(access_point_name, username, password, function(err) { ... });
Connect to the given access point - you'll have to find out which details to use from your mobile operator. The callback is called with err==null
on success.
gprs.getIP(function(err, ip) { ... });
Call the callback with the current IP address, as a String. The callback is called with err==null
on success.
Using
Buying
This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.