As discussed in a previous thread, here is a description using AT commands to communicate with a Nokia 6100 cellphone.
The Nokia 6100 has two serial protocol buses available for interfacing - M-Bus and F-Bus. M-Bus is a bi-directional bus having a combined Rx/TX line. F-Bus, on the other hand, has seperate Rx and Tx lines. This is the bus I used.
I was able to test and use the following AT commands:
AT+CGMM Request Model Identification ; Will reply with phone model ident. In this case "Nokia 6100"
AT+CSQ Signal Quality ; Will reply with "+CSQ: rssi,ber" where rssi = 0 to 31 or 99 (usually in the range 2 to 30) & ber = 0 - 7 or 99
AT+CMGF=1 Set to text message format ; Will reply with "OK" (=0 sets to PDU mode)
Commands always start with AT (ATtention) and end with <CR>
Responses start and end with <CR><LF>. These have been ignored.
The original program made use of the ON ... GOSUB command for the various transmit, receive and error reporting routines. While this is compact, it does make the program flow a little difficult to follow. I have simplified the flow by rewriting the code in the following, more linear mode.
The following constants and variables are used:
To check if the phone is on and connected the following is used:Code:'Directives #PICAXE 28X1 #SIMSPEED 100 'Constants SYMBOL txpin = 0 ; select serial output pin to suit SYMBOL rxpin = 0 ; select serial input pin to suit SYMBOL gsmbaud = T4800_8 ; select baudrate to suit phone used. I used T4800_8 SYMBOL timeout = 100 ; Serial in timeout period (ms) SYMBOL errled = 7 ; Red error led SYMBOL goled = 6 ; Green system good led 'Variables SYMBOL genreg0 = b0 ; General purpose register 0 SYMBOL genreg1 = b1 ; General purpose register 1 SYMBOL genreg2 = b2 ; General purpose register 2 SYMBOL genreg3 = b3 ; General purpose register 3 SYMBOL errflag = b4 ; Error flag SYMBOL testdata = 145 ; Test data
Then a test of signal quality is done. No or low signal level causes a retest before signaling an error. If all is good then the program initialises Text mode:Code:'Main Program Initialise_Main: SETFREQ m8 errflag = 0 ; Clear error flag HIGH txpin ; Puts serial out pin into idle condition LOW errled ; Error LED off Model_Ident: 'This checks if phone is connected/on SEROUT txpin,gsmbaud,("AT+CGMM",10) ; Request Model Identification SERIN [timeout,Model_Error_1],rxpin,gsmbaud,("Nokia 6100"); Should receive "Nokia 6100" errflag = 0 ; Clear error flag GOTO Signal_Quality Model_Error_1: INC errflag IF errflag < 2 THEN GOTO Model_Ident Model_Error_2: HIGH errled ; Turns Red (Error) LED on PAUSE 10000 ; Wait 1 second LOW errled ; Turns Red (Error) LED off PAUSE 10000 ; Wait 1 second GOTO Model_Error_2
If all is good then the system sends a text message.Code:Text_Mode: SEROUT txpin,gsmbaud,("AT+CMGF=1",10) ; Set to text (not PDU) message format SERIN [timeout,Mode_Error_1],rxpin,gsmbaud,("OK") ; Will receive "OK" errflag = 0 ; Clear error flag GOTO Send_System_OK Mode_Error_1: INC errflag IF errflag < 2 THEN GOTO Text_Mode Mode_Error_2: HIGH errled ; Turns Red (Error) LED on PAUSE 2500 ; Wait 1/4 second LOW errled ; Turns Red (Error) LED off PAUSE 2500 ; Wait 1/4 second GOTO Mode_Error_2
To transmit any data gathered the receiving phone number has to be included in the GMSS string. In this case "+33146290800" ( a dud number). The number is in international format.Code:Send_System_OK: ' Send message directly LOW errled ; Turn off error LED HIGH goled ; Turn on System good LED SEROUT txpin,gsmbaud,("AT+CMGS=",34,"+33146290800",34,10,"System Active",26) SERIN [timeout,Transmit_Error_1],rxpin,gsmbaud,("OK") ; Will receive "OK" errflag = 0 ; Clear error flag GOTO Send_Data Transmit_Error_1: INC errflag IF errflag < 2 THEN GOTO Send_System_OK Transmit_Error_2: HIGH errled ; Turns Red (Error) LED on PAUSE 1250 ; Wait 1/8 second LOW errled ; Turns Red (Error) LED off PAUSE 1250 ; Wait 1/8 second GOTO Transmit_Error_2
As the text string can only hold ASCII characters, the # is put before the variable storing the data. This outputs the variable in ASCII format. Refer to the manual for more info.
I did have some trouble with receiving replies from the phone and had to make small adjustments to the timeout variable in each (sub)routine. This was probably due to the time taken for the phone to process the AT commands, especially sending the text message.Code:Send_Data: ' Send message directly LOW errled ; Turn off error LED HIGH goled ; Turn on System good LED SEROUT txpin,gsmbaud,("AT+CMGS=",34,"+33146290800",34,10,"Data = ",#testdata,26) SERIN [timeout,Send_Data_Error_1],rxpin,gsmbaud,("OK") ; Will receive "OK" errflag = 0 ; Clear error flag GOTO Endless ; End of program Send_Data_Error_1: INC errflag IF errflag < 2 THEN GOTO Send_Data_Error_1 Send_Data_Error_2: HIGH errled ; Turns Red (Error) LED on PAUSE 625 ; Wait 1/8 second LOW errled ; Turns Red (Error) LED off PAUSE 625 ; Wait 1/8 second GOTO Send_Data_Error_2 Endless: GOTO Endless
I hope this goes someway to answering vttom's query in the original post. And MPep's enquiry.
Cheers


Reply With Quote
I have been searching the forum and googling for days and finally a successful picaxe to nokia program...



Bookmarks