Vous êtes sur la page 1sur 6

SIM900 / SIM800L gsm_gprs

Test for SIM800L modem

AT+CSQ? ; signal quality


+CSQ:18,99

OK

RSSI
Value dBm Condition
2 -109 Marginal
3 -107 Marginal
4 -105 Marginal
5 -103 Marginal
6 -101 Marginal
7 -99 Marginal
8 -97 Marginal
9 -95 Marginal
10 -93 OK
11 -91 OK
12 -89 OK
13 -87 OK
14 -85 OK
15 -83 Good
16 -81 Good
17 -79 Good
18 -77 Good
19 -75 Good
20 -73 Excellent
21 -71 Excellent
22 -69 Excellent
23 -67 Excellent
24 -65 Excellent
25 -63 Excellent
26 -61 Excellent
27 -59 Excellent
28 -57 Excellent
29 -55 Excellent
30 -53 Excellent

Network availability with the AT+CREG (network registration)


Example for OK registration:

AT+CREG?

+CREG: 0,1

Send/REC sms in text mode sms (default is PDU)

AT
OK
AT+CMGF=1 ; =1 == text mode
OK

Example receive sms QW :

+CMTI: "SM",8

AT+CMGR=8

+CMGR: "REC UNREAD","+38971262858","","17/11/30,18:55:42+04"

QWERTY

OK

Ezample send sms ABCD to number 087234111 (from any terminal in PC )

AT+CMGS="087234111"

> ABCD ;after this do: CTRL+Z

+CMGS: 12
*************************

SIM900 gsm_gprs PIC18f4550 program asm :

__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L


__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L &
_VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H
& _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L &
_XINST_OFF_4L & _DEBUG_OFF_4L
endasm

DEFINE OSC 48
DEFINE HSER_RCSTA 90h ' enable serial port,
DEFINE HSER_TXSTA 36 ' enable transmit, * we change 20h to 36 for
115200
DEFINE HSER_BAUD 115200
DEFINE HSER_CLOERR 1 ' automatic clear overrun error

TRISC = %10000000 ' PORTC.7 is the RX input, PORTC.6 is the TX


output

' Serial communication definition


' ===============================
'
ADCON1 = %00001111 'Set up ADCON1 register no matter what you're
doing!!!!!!
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::

INCLUDE "MODEDEFS.BAS" ' Include Shiftin/out modes

'**************************************************************************
***

Serialdata var byte

INTCON2.7 = 0 ' Enable PORTB pull-ups


TRISB = %11111000
TRISC = %10000000
led1 var PortC.0
TRISD = %00000000
Serout2 PORTD.5, 84, [$1B,$63,$30] 'cursor off for serial LCD
Serout2 PORTD.5, 84, [$1B,$45,"SMS DEBUG PORT"] ' serial LCD
main:
PORTB = 0 ' PORTB lines low to read buttons

If PORTB.4 = 0 Then ' If 1st button pressed...

HSEROUT ["Button 1",13]


Serout2 PORTD.5, 84, [$1B,$45, "SMS DEBUG PORT"]
Serout2 PORTD.5, 84, [$D, "Button 1 "]
pause 500
Serout2 PORTD.5, 84, [$1B,$45,"SMS DEBUG PORT"]
gosub GSM_CHECK
Endif
pause 200 ' pause to avoid sending repetation

goto main

End 'End program

GSM_CHECK:
HSEROUT ["AT",13] 'Send AT to modem followed by a CR
HSERIN 5000, GSM_CHECK_ERR, [WAIT("OK")] 'Check OK reply, wait 5sec max.
Serout2 PORTD.5, 84, [$D, "GSM OK"]
High PORTB.0 ' 1st LED on
PAUSE 1000
low PORTB.0
return

GSM_CHECK_ERR:
Serout2 PORTD.5, 84, [$D, "GSM ERROR"]

;HSEROUT ["GSM_ERROR",13]
Return

# last asm new correction and works:

asm
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L &
_USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L &
_VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H
& _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L &
_XINST_OFF_4L & _DEBUG_OFF_4L
endasm

DEFINE OSC 48

DEFINE HSER_RCSTA 90h ' enable serial port,


DEFINE HSER_TXSTA 20h ' enable transmit, * we change 20h to 36 for
115200
DEFINE HSER_BAUD 9600
DEFINE HSER_CLOERR 1 ' automatic clear overrun error

TRISC = %10000000 ' PORTC.7 is the RX input, PORTC.6 is the TX


output

' Serial communication definition


' ===============================
'
ADCON1 = %00001111 'Set up ADCON1 register no matter what you're
doing!!!!!!
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::

INCLUDE "MODEDEFS.BAS" ' Include Shiftin/out modes

'**************************************************************************
***

INTCON2.7 = 0 ' Enable PORTB pull-ups

TRISB = %11111000
TRISC = %10000000
led1 var PortC.0
cntr var byte
cntr = 0
TRISD = %00000000

Serout2 PORTD.5, 84, [$1B,$63,$30]


Serout2 PORTD.5, 84, [$1B,$45, "Start GSM SIMU"] ' Serial LCD
main:

PAUSE 1000
HSEROUT ["AT",13,10] 'Send AT to modem followed by a CR
pause 200
cntr=cntr+1
Serout2 PORTD.5, 84, [$1B,$45,"Start GSM SIMU"]
Serout2 PORTD.5, 84, [$D,"AT -Done",#cntr]
cntr=cntr+1

pause 1000
HSEROUT["AT+CMGF=1",13] 'Here the GSM module is being entered
in TEXT MODE.
PAUSE 1000
HSEROUT ["AT+CSQ",13,10]
pause 200
Serout2 PORTD.5, 84, [$1B,$45,"Start GSM SIMU"]
Serout2 PORTD.5, 84, [$D, "SIGNAL CHK",#cntr]

PAUSE 1000
HSEROUT ["AT+CGMI",13,10] 'Ask model name
pause 200
cntr=cntr+1
Serout2 PORTD.5, 84, [$1B,$45,"Start GSM SIMU"]
Serout2 PORTD.5, 84, [$D, "MANUFACT CHK",#cntr]

Pause 1000
Serout2 PORTD.5, 84, [$1B,$45,"Start GSM SIMU"]
Serout2 PORTD.5, 84, [$D,"GSM TEST DONE!",#cntr]

End ' End of program

That did it...yipee!

Hi tacbanon,

I loaded your code from post 19 into a circuit here, and tested hserout with your settings. I
couldn't seem to get anything out, unless I removed your brown out reset in the configs.

If you change this line, does it help anything?

; __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L


__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L

As a side note, for 115200 baud on earlier code, I had to use:


'DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
'DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
'DEFINE HSER_CLROERR 1 ' Clear overflow automatically
'DEFINE HSER_SPBRG 25 ' 115200 Baud @ 48MHz, 0.16%

Vous aimerez peut-être aussi