Quantcast
Channel: busylog.net
Viewing all articles
Browse latest Browse all 10

SIM900 Tutorial (Arduino shield)

$
0
0

Send SMS with arduino or receive phone calls with arduino … If you are interesting in send/receive SMS, phone calls, emails … and more (like GSM Location) in this post my notes about SIM900 Arduino shield.

Index

** (Click) Download Manuals **

    SIM900 Arduino shield

    SIM900 is a wireless module for M2M applications now in EOL (replaced by SIM800x). This module is quad band (850/900/1800/1900MHz) with a built in core AMR926EJ-S .
    The processor is an general-purpose microprocessor of ARM9 family: 156Mhz/1MB RAM  which supports 32-bit/16-bit instruction set (more details about AMR926EJ-S here). SIM900 is a module that is mounted on PCB with different layout depending on vendor.

    In this post my notes how to test the SIM900 shield quickly without arduino and code (notes are related to this SIM900 Shield ),

    … details here http://simcom.ee/modules/gsm-gprs/sim900/

    … about the Shield SIM900

    ** (Click) Download Manuals **

      Main features

      • VOICE
      • SMS/MMS
      • DATA (embedded TCP/UDP protocol E-Mail/FTP/HTTP/NTP …)
      • FAX
      • TTS : TextToSpeech (*)
      • 12 GPIOs : General Purpose IO (**) 
      • RTC : Rial time clock (needs battery)
       (*) TTS Note  TTS through AT command but…available only for some versions! requires special FW and HW.
       The Shield in this post
      doesn’t support TTS.

       (**) GPIO Note GPIO can expand your arduino. GPIO are addressable through AT commands.
       The shield in this post
      supports 12 GPIOs and 2 PWMs


      What we need to use

      1 SIM900 Shiled (30 €)
      1 USB to TTL converter (10 €)
      4+ Jumper Wire (7 €)
      1 SIM ( 0 € )

      Grand Total: ~50 €

      SIM (2G Network)

      About SIM you need a 2G SIM with the proper price plan.
      The SIM has to be for 2G Network with  “2FF 25mm x 15mm x 0.76mm – Mini”  factor.

      In my tests I sent plenty of SMS and spending $$$ IoT and M2M SIM are not easy to evaluate and choose.
      So depending on the usage of this Shield  a regular 2G SIM with a low price for SMS/Data and a pay-as-you-go plan should be the best choice to start quickly.

      Read  this (GiffGaff SIM) .

      Get a free giffgaff Sim

      Warning! keep in mind to unlock the SIM turning off the PIN before inserting in the shield.

      SIM900 Shield hardware layout

      SIM900 arduino shield layout
      SIM900 arduino shield layout

      SIM900 Leds status codes

      LED Status Meaning
      Power led  OFF SIM900 shield is not powered (no power) 
        RED SIM900 shield is powered (power is ok)
      Status led  OFF Power off
        RED Power on (SIM900 is on)
      Network led  OFF SIM900 is not working
        64ms RED / 800ms   OFF SIM900 does not find the network
        64ms RED / 3000ms OFF SIM900 finds the network
        64ms RED / 300ms   OFF GPRS communication

      SIM900 images

      How to send commands

      Commands are sent to the Shield through the Serial port on-board of the Shield (see layout “Hardware Serialhere).  So we can communicate with the SIM900 sending AT commands through the USB port (using an converter).

      A command to the Shield can be sent by a PC (as said) or by Arduino :

      For quick tests (using PC instead of arduino) you need to use a serial terminal application such as Arduino IDE (serial monitor), screen, minicon, cuCoolTerm or putty.

      USB to Serial (TTL)
      USB to Serial (TTL)

      screen (shell)

      In order to send AT commands the easiest way is to use shell commands like screen (linux and OSX) :
      1 Search Serial

      ls -1 /dev/tty.* 
      /dev/tty.Bluetooth-Incoming-Port 
      /dev/tty.SLAB_USBtoUART 

      Connect

      screen /dev/tty.SLAB_USBtoUART 19200 -L
      AT
      OK
      
      Exit screen and terminate the serial session with key :
       CTRL  + A + \

      minicon (shell)

      minicom -b 19200 -D /dev/tty.SLAB_USBtoUART

      Configure “Hardware flow control: NO” and “Software Flow:control:YESpressing keys :
      •  CTRL  + A + Z 
      •  o 
      • Select menu option “Serial Port Setup
      •  F 
      •  G 

      cu (shell)

      sudo cu -l /dev/tty.SLAB_USBtoUART -s 19200
      Connected.
      To exit from cu by typing keys: ~ .

      Screenshots: screen, minicon and cu

      Connecting (without using Arduino)

      As said communication can be done using Arduino or using USB of your PC (with USB to TTL converter). In this last case you need to wire as described in below image.
      Warning! Please pay attention to set PCB jumpers (serial selector) as “Hardware Serial“.

      SIM900 connecting to Serial
      SIM900 connecting to Serial

      Try with AT Commands (Cut & Paste)

      Using serial terminal application (here) you can send the following AT commands to the Shield.

      Commands are described  in “Sim900 AT Commands (list of sim900 commands)” here. Below are examples related to network, clock, SIM status, Battery…

      (Click) Simple Test / SIM / Clock / Network / ...

      Simple test
      AT
      OK

      Display Product Identification Information
      AT+GSV
      SIMCOM_Ltd
      SIMCOM_SIM900
      Revision:1137B06SIM900M64_ST_ENHANCE
      OK


      SIM Inserted Status Reporting
      AT+CSMINS?
      +CSMINS: 0,1
      OK

      (*) 1 is inserted

      Get Service Provider Name from SIM
      AT+CSPN?
      +CSPN: “giffgaff”, 0
      OK


      Signal quality
      AT+CSQ
      +CSQ: 12,0
      OK

      (*) 12 is the rssl value :
      0 -115 dBm or less
      1 -111 dBm
      2…30 -110… -54 dBm
      31 -52 dBm or greater
      99 not known or not detectable

      Battery Charge
      AT+CBC
      +CBC: 0,98,4175
      OK

      (*) 0 is not charging, 98% , 4174mV

      Clock
      AT+CCLK?
      +CCLK: “00/01/01,01:34:03+00”
      OK

      Below commands are related to SMS (receive, send, list and delete). Commands are described in “Sim900 AT Commands (list of sim900 commands)” here.

      (Click) Simple SMS tests
      Send SMS
      AT+CMGF=1
      OK
      AT+CMGS=”+39XXXXXXXXXX”
      > TEST SMS
      >
      +CMGS: 5

      (*)  CTRL  + Z   (0x1A) to exit (wait few seconds)
      SMS Messages from Preferred Store
      >List supported status
      AT+CMGL=?
      +CMGL: (“REC UNREAD”,”REC READ”,”STO UNSENT”,”STO SENT”,”ALL”)
      OK

      (*) “REC UNREAD” => Received unread messages
      “REC READ” => Received read messages
      “STO UNSENT” => Stored unsent messages
      “STO SENT” => Stored sent messages
      “ALL” => All messages
      >List of  “ALL” SMS (no change status)
      AT+CMGL=”ALL”,1
      +CMGL: 1,”REC UNREAD”,”+39XXXXXXXXXX”,””,”18/01/09,22:43:22+00″
      Test Message 1

      +CMGL: 2,”REC UNREAD”,”Giffgaff”,””,”18/02/01,10:52:38+00″
      Hey, welcome to ITALY. Calls, texts and data will now come out of your normal UK allowance, just like being at home. For more info and terms, we recomme

      OK

      (*) AT+CMGL=”ALL”,1 -> 1 Not change status of the specified SMS record / 0 change in read

      >Read SMS Index 1  (change status to read)
      AT+CMGR=1,0
      +CMGR: “REC UNREAD”,”+39XXXXXXXXXX”,””,”18/01/09,22:43:22+00″
      Test Message 1

      OK

      (*) AT+CMGR=1,1 -> 1  Not change status of the specified SMS record


      >List of “REC UNREAD” SMS
      AT+CMGL=”REC UNREAD”,1
      +CMGL: 2,”REC UNREAD”,”Giffgaff”,””,”18/02/01,10:52:38+00″
      Hey, welcome to ITALY. Calls, texts and data will now come out of your normal UK allowance, just like being at home. For more info and terms, we recomme

      OK


      Delete SMS 
      >Delete SMS with index 1
      AT+CMGD=1,0
      OK

      >Delete ALL SMS
      AT+CMGD=0,4
      OK

      >Delete ALL SMS (NOT delete unread)
      AT+CMGD=0,3
      OK

      (*) Delete all read messages from preferred message storage, sent and unsent mobile originated messages leaving unread messages untouched

      When SMS is received on serial is sent
      +CMTI: “SM”,1

      +CMTI: “SM”,2

      (*) 1 row for each new message

      Phone calls and Calling Line Identification Presentation…Commands are described in “Sim900 AT Commands (list of sim900 commands)” here.

      (Click) Phone call outcoming and incoming

      When incoming call on serial is sent (without MSISDN) 
      RING
      RING
      RING
      NO CARRIER

      (*) 1 rows (RING)  for each new ring. / “NO CARRIER” if caller hang-up


      Set Caller Identification on incoming call (show MSISDN)
      AT+CLIP=1
      OK

      When incoming call on serial is sent (with MSISDN AT+CLIP=1)
      RING
      +CLIP: “+39XXXXXXXXXX“,145,””,,””,0

      RING
      +CLIP: “+39XXXXXXXXXX“,145,””,,””,0

      RING
      +CLIP: “+39XXXXXXXXXX“,145,””,,””,0

      NO CARRIER

      (*) 2 rows (RING and +CLIP)  for each new ring / “NO CARRIER” if caller hang-up


      Call a phone number
      ATD+39XXXXXXXXXX

      Example for GSM location …Commands are described in “SIM900 GSM location AT Commands (geolocalisation)here

      (Click) GSM location

      Define APN and get IP
      AT+CGDCONT= 1,”IP”,”giffgaff.com

      OK
      AT+CSTT= “giffgaff.com”,”giffgaff”,””
      OK
      AT+SAPBR =1,1
      OK
      AT+SAPBR =2,1
      +SAPBR: 1,1,”10.142.58.100″
      OK


      Define GET Location

      AT+CIPGSMLOC=1,1
      +CIPGSMLOC: 0,9.181164,45.456692,2018/02/11,14:26:39
      OK
      AT+CIPGSMLOC=2,1
      +CIPGSMLOC: 0,2018/02/11,14:27:05
      OK

      (*) AT+CIPGSMLOC=1,1 View the longitude, latitude and time
      AT+CIPGSMLOC=2,1 
      View time
      (**) I used giffgaff APN
      (***) In my case my location has been detected with ~500m of error.

      Send emails and get IP network…  Commands are presents in “Sim900 e-mail AT Commands (to send email)here

      (Click) Send emails

      Define APN and get IP
      AT+CGDCONT= 1,”IP”,”giffgaff.com”
      OK
      AT+CSTT= “giffgaff.com”,”giffgaff”,””
      OK


      Get IP
      AT+CIICR
      OK
      AT+CIFSR
      10.146.139.0
      AT+SAPBR =1,1
      OK
      AT+SAPBR=2,1
      +SAPBR: 1,1,”10.145.189.160″

      Send an email
      AT+SMTPSRV=”smtpout.example.com”,587
      OK
      AT+SMTPAUTH=1,”**username***”,”**password**”
      OK
      AT+SMTPFROM=”giovanni@example.com”,”Giovanni FreeFormName”
      OK
      AT+SMTPRCPT=0,0,”alice@example.com”,”Alice FreeFormName”
      OK
      AT+SMTPSUB=”Subject email”
      OK
      AT+SMTPBODY
      >This is the body…

      (*)  CTRL  + Z     (0x1A) to exit (wait few seconds)

      AT+SMTPSEND
      +SMTPSEND: 1

      (*)
      AT+SMTPRCPT=1,0, -=> CC
      AT+SMTPRCPT=2,0, -=> BCC
      Example :
      AT+SMTPRCPT=1,0,”is.cc.recipient@example.com”,”FreeFormName”

      The post SIM900 Tutorial (Arduino shield) appeared first on busylog.net.


      Viewing all articles
      Browse latest Browse all 10

      Latest Images

      Trending Articles





      Latest Images