Tuesday, October 31, 2017

SIM800L Module Bringup


Check the SIM800L module working condition:
Specification: SIM800L Hardware spec
GSM Standard: GSM Standard - ETSI TS 127 007 - AT Commands
Courtesy: https://nettigo.eu/products/sim800l-gsm-grps-module

Mini GSM/GPRS module

SIM800L is a miniature cellular module which allows for GPRS transmission, sending and receiving SMS and making and receiving voice calls. Low cost and small footprint and quad band frequency support make this module perfect solution for any project that require long range connectivity. After connecting power module boots up, searches for cellular network and login automatically. On board LED displays connection state (no network coverage - fast blinking, logged in - slow blinking).
NOTICE: Be prepared to handle huge power consumption with peek up to 2A. Maximum voltage on UART in this module is 2.8V. Higher voltage will kill the module.

Two antennas!

This module have two antennas included. First is made of wire (which solders directly to NET pin on PCB) - very useful in narrow places. Second - PCB antenna - with double sided tape and attached pigtail cable with IPX connector. This one have better performance and allows to put your module inside a metal case - as long the antenna is outside.

Specification

  • Supply voltage: 3.8V - 4.2V
  • Recommended supply voltage: 4V
  • Power consumption:
    • sleep mode < 2.0mA
    • idle mode < 7.0mA
    • GSM transmission (avg): 350 mA
    • GSM transmission (peek): 2000mA
  • Module size: 25 x 23cm
  • Interface: UART (max. 2.8V) and AT commands
  • SIM card socket: microSIM (bottom side)
  • Supported frequencies: Quad Band (850 / 950 / 1800 /1900 MHz)
  • Antenna connector: IPX
  • Status signaling: LED
  • Working temperature range: -40 do + 85 ° C

Set includes:

  • SIM800L module
  • goldpin headers
  • wire antenna
  • PCB antenna with pigtail and IPX connector

Module pinout

ModuĊ‚ GSM GPRS SIM800L Pinout


Pinout (bottom side - left):
  • RING (not marked on PBC, first from top, square) - LOW state while receiving call
  • DTR - sleep mode. Default in HIGH state (module in sleep mode, serial communication disabled). After setting it in LOW the module will wake up.
  • MICP, MICN - microphone (P + / N -)
  • SPKP, SPKN - speaker (P + / N -)
Pinout (bottom side - right):
  • NET - antenna
  • VCC - supply voltage
  • RESET - reset
  • RXD - serial communication
  • TXD - serial communication
  • GND - ground
Moreinfo : https://github.com/stephaneAG/SIM800L/blob/master/README.md 

Sanity Test Connection: 


1.  Flash Arduino with empty code to connect SIM800L to laptop(Ardiuno act as USB to TTL converter) 

void setup() {

  // put your setup code here, to run once:

}

void loop() {

  // put your main code here, to run repeatedly:

}

3. Connect Arduino 3.3 V to VCC supply 800L and remove the SIM card ()
3. Connect GND to Arduino GND
4. Connect RX to Arduino RX0
5. Connect TX to Arduino TX0
6. Open Serial Monitor and choose 9600 or any 115200 baud rate, CR and LF, since 800L is supports auto baud rate


init the auto-bauder: AT
OK
get module name & version:ATI
SIM800 R14.18
turn on verbose errors:ATI+CMEE=2
SIM800 R14.18
get SIM card number:AT+CCID

get IMEI card number:AT+CGSN
to list available networks: AT+COPS=?

check that we're connected to a network:AT+COPS?
+COPS: 0
check signal strength:AT+CSQ
+CSQ: 26,0
check battery state:AT+CBC =?
+CBC: (0-2),(1-100),(voltage)
: Charge status
    0 ME is not charging
    1 ME is charging
    2 Charging has finished
: Battery connection level
    1...100 battery has 1-100 percent of capacity remaining

: Battery voltage(mV)
     0000 - 4700
check battery state:AT+CBC   (while i connected to 3.3v of Ardunio)
+CBC: 0,0,3286

pages: AT+CSCS=?
+CME ERROR: SIM not inserted

Observation: After inserting valid SIM CARD
check signal strength:AT+CSQ

+CSQ: 29,0
Syntax:  Response +CSQ: ,
  0 -115 dBm or less,
                 1 -111 dBm, 
                 2...30  -110...-54 dBm
                 31 -52 dBm or greater 
                 99 not known or not detectable 
(in %): 0...7 As RXQUAL values in the table in GSM 05.08 [20] subclause 7.2.4 
                 99 Not known or not detectable

Map value for range

long map(long x, long in_min, long in_max, long out_min, long out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
Re-maps a number from one range to another. That is, a value of fromLow would get mapped to toLow, a value of fromHigh to toHigh, values in-between to values in-between, etc.
val = map(val, 0, 1023, 0, 255);
Ref: Arduino Reference Map

Sunday, October 15, 2017

Creating swap space in Embedded System

It seems that you have insufficient RAM to build matplotlib from scratch. To overcome that, either turn on swap:
# create swap file of 512 MB
dd if=/dev/zero of=/swapfile bs=1024 count=524288
# modify permissions
chown root:root /swapfile
chmod 0600 /swapfile
# setup swap area
mkswap /swapfile
# turn swap on
swapon /swapfile
Or, if you have raspbian installed on your SD card, you can install matplotlib from the repository:
apt-get install python-matplotlib