Skip to content

1mul for GSM/GPRS module SIM800H v1_2

Latest
Compare
Choose a tag to compare
@eta-sys eta-sys released this 14 Nov 15:35
· 7 commits to master since this release
dfde56a
  • 8 tasks
  • 16 Pipes, up to 5 in each interface
  • 16 Strings
  • max. Pipe length 1024 Bytes
  • max. String length 256 Bytes
  • different interfaces count 8+1 for File System handle
  • ml program up to 1024 rows, max. size 100kB
  • File System up to 16 files
  • 16 Timers
  • 14 Digital IO
  • 1 Analog Input
  • 16 Variables 16-bit signed integer
  • 16 Flags
  • 1 PWM out
  • RTClock
  • 1-UART, 1-I2C, 1-SPI, 1-PWM, up to 5 GPRS-TCP/UDP Client/Servers, up to 5 GSM- Dial Voice or CSD, SMS or AT-commands Pipes
  • 1 Microphone input, 1 Speaker output 4Ω/0,5W.
  • SD Card interface

sim800h_33

Console default runs on USB interface. You may use '9600,8N1' but this is not mandatory for an USB interface.

   Red In/Outs 1..14 are 2,8V tolerant. 

The blue terminals, as well as ADC In are 12V tolerant
    Out1&Out2 (driven from pins 9, 10) are Open Collectors 300mA, up to 24V.
    12V Power can be input as well as output for Power  Supply.

Microphone input 'Mic' is differential self powered, so keep it away from ground.
Same situation with Speaker output 'Spc'. It can direct drive a 4Ω/0,5W Speaker.

UART port levels are 2,8V tolerant.

USB Console port needs a driver to be accessible as a PC COM port. 'http://ftp.etasys.net/SIM800_USB_DRIVER%201.1250.0/'

A SIM card with removed PIN code restriction can or can't be presented. The last one will exclude GSM/GPRS functions of the device. Removing PIN restriction from SIM card can be done using a cell-phone Security Settings.

If a SD card presents, to Create/Open a File you should use full path in format “C:\name” or “D:\name” in order to determine storage to read from. If prefix “C:\ “ omitted, in context means 'C' storage – internal Flash memory.

Examples:

Keep in mind that you always can get 'help' typing a '?' elsewhere in following functions from the Console.

Make a Voice Dial:

U1{4,1}
P1{1,CALL,”0888123456;”}  #instead 'CALL' you may write 'Call' or simply 'C'

Keep in mind that Phone number string ends with ';'. After the connection establishes you can send DTMF tones using:

P1=”1234”

and read DTMF sent to you using:

$1=$P1	

Make a CSD call:

U1{4,1}
P1{1,CALL,”0888123456”}  #instead 'CALL' you may write 'Call' or simply 'C'

As you can see ';' in phone number is missing.

To send data use:

   P1="text %X{hex data 0x1a,0x1b}...\r\n or any delimiter"

The receiving data goes to $Pipe, so you can retrieve it from there.

   !$P1

To terminate a voice or CSD call simply write:

P1=0

Wait for an incoming call

Attach to GSM Unit a CALL pipe without supplying a phone number:

 P1{1,CALL}

When an incoming call $Pipe contains clip of the caller, so you may decide to answer:

P1=1

or to cancel the connection:

P1=0

When an incoming call accepted and the connection established you may send data(if CSD call) or DTMF(if voice call) as per outgoing calls above.

Send a SMS Message:

U1{4,1}
P1{1,SMS,”0888123456”}	#as above you can write 'Sms' or just 'S'
P1=”My test SMS\r\n”

Wait for a SMS Message:

U1{4,1}
P1{1,SMS}
?_$P1 $1=$P1,$P1=”” #check if new SMS(length > 0), if yes, read SMS to $1, then clear P1

The new received SMS contains:
sender phone number
message
date, time

GPRS handling does not differ from WiFi Pipe handling, except that you should open interface as GSM\GPRS

U1{4,2,”APN”,(optional)\"user\",\"pword\"}	# if in doubt write just “GPRS” for APN 
U1{4,2,”GPRS”}

AT commands

U1{4,1}
P1{1,AT}

It's essential to know that simple answers as 'OK', 'ERROR', e.t.c. are not direct passed to AT-Pipe instead the result of operation is returned as AT-Pipe value, and can be checked by reading this value:

!P1	# if = 1 then 'OK', if = 0 – 'ERROR'

For a complete list of AT commands find a 'SIM800H AT Commands manual'.

Make a record to SIM card:

P1=”AT+CPBW=1,\”08899..\”,129,\”name\”\r”	# don't forget \r at the end of command
!P1
1

Read the record:

P1=”AT+CPBR=1\r”
!$P1
+CPBR: 1,”088911223344.”,129,”name”

From above answer you may extract the phone number to $1 executing:

$1=$P1](($P1/”\”,”)-2)]$P1/”,\””	# you have to escape " with \”
   cut tail after “, cut leading before ,”
!$1
08899....

I2C

I2C uses fixed I/O as follows:

  • 13 – SCL
  • 14 – SDA

If you use I2C you should not use pins 13&14 for common I/O. You have to use own power source 2,8 V and add two 10kΩ resistors from SCL and SDA to + of power source 2,8V, as standard requires. Then you open a serial interface unit as I2C and attach a pipe to it:

U1{1,5}
P1{1,0xa0,1000} 

where
0xa0 represents device address 'as is' (not moved one bit right).
1000 stays for speed = 1000 kbps (max allowed).

For device address and speed setting check your device's data sheet.
Then you can communicate with device using next:

P1="W%x{0x2a,0x00,0x01}" 	# Write 00,01 to register 0x2a
P1="4R%x0xfa" 			# read 4 Bytes from reg. 0xFA 

or

P1="4R%x{0xfa}"			# same meaning

As you see Read command runs some kind backward "4R%x{0xfa}" in fact says:
'send 0xfa to device('s address you already know), then R(ead) 4 Bytes'

SPI

SPI works only in 3-mode(CPOL=1, CPHA=1).
SPI pins are mapped to SD card place as follows up(near antenna) to down(near the SIM holder):

  • MOSI
  • MISO
  • not used
    • 2,8V
  • CS (pin 15 you can see in output's list, executing 'O{?}' from Console)
  • GND
  • not used
  • CLK

Interface Unit opens like that:

U1{1,3,0,52,8}

where:
{1, stays for 'serial'
3, type SPI
0, hardware interface number – don't care as we have just one
52 speed =52 Mbps, you may choose from 13,26 or 52
8} means bits. You may choose 8,9,16,24 or 32

If not specified default settings are ',52,8}', so you can write just:

 U1{1,3}

Then attach a pipe:

P1{1,15,1}

where:
{1, goes for interface Unit 1
15, is the Chip Select pin you will use to select SPI device
1} means 'invert CS pin state', 0 = no inversion

If you have 2 SPI interfaces to same device – data and command, just open 2 Pipes to different CS pins and put a 'diode OR' from CSD to CSC on order to get CSD selected when CSC is selected.
Read/Write to SPI uses same format as I2C.

P1="W%x{0x2a,0x00,0x01}" 	# Write 00,01 to register 0x2a
P1="4R%x0xfa" 			# read 4Bytes from reg. 0xFA 

If you had chosen 16 or 32 bit SPI format above, provide according data length to send.

PWM

You can use only pin 12 to output a PWM signal.

To run PWM 800Hz/50% duty write:

U1{9,2,800}	# 800 Hz
P1{1}
P1=50		# % duty
P1=10		#set duty to 10%
U1{9,2,500}	#set freq. to 500Hz