Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 15:47 18 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : SIM900 and uMite

Author Message
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 04:22pm 03 Jun 2014
Copy link to clipboard 
Print this post

Hi All,

In an effort to learn some serial stuff and more importantly to show my son that text messaging is for more than "meet me at the mall" type communication, I started playing with the GSM modem and using SMS to control things using a uMite. I have attached my code and know that it is not the best (not even close) as far as how I did things. I too am still learning. However, this does work well and can be easily modified to add more phone numbers, commands, responses, etc. This was just a quick first attempt to do a bit of show and tell. Take a look and feel really free to make comments on how I can make this better.

GOODNUM$ = "2223334444" 'GOOD NUMBER HERE - AREA CODE AND NUMBER NO SPACES
SETPIN 3, DOUT
PIN(3) = 0

OPEN "COM1:9600" AS #1

FLUSHBUF

PRINT "INITIALIZING SYSTEM.... PLEASE WAIT."
PRINT
PRINT #1,"AT"
PAUSE 200
PRINT #1,"AT"
PAUSE 200
PRINT #1,"ATE0" 'TURN ECHO OFF
PAUSE 200
FLUSHBUF

PRINT #1,"AT" 'DO QUICK MODEM RESPONSE CHECK
PAUSE 200
GETSTRING
CHECKOK

PRINT #1,"AT+CMGF=1" 'TURN ON TEXT MODE
PAUSE 200
GETSTRING
CHECKOK

PRINT #1,"AT+CLIP=1" 'TURN ON CALLER ID
PAUSE 200
GETSTRING
CHECKOK

PRINT #1,"AT+CNMI=2,2,0,0,0" 'SEND SMS DIRECT TO SERIAL PORT
PAUSE 200
GETSTRING
CHECKOK

'PRINT #1,"AT+CMGD=1,4" 'CLEAR SMS
'PAUSE 200
'GETSTRING
'CHECKOK

'********************** MAIN *************************
DO
FLUSHBUF
PRINT
PRINT "WAITING FOR SMS TO COME..."
DO WHILE LOC(#1)=0:LOOP
GETSTRING
CHECKNUM
PRINT "SMS COMING IN FROM ";CHECKNUM$
IF GOODNUM = 0 THEN
PRINT "NOT A GOOD NUMBER...":PRINT
REPLY$ = "YOUR NUMBER IS NO GOOD HERE BUSTER!" 'SENT BACK TO BAD NUMBER
REPLYSMS REPLY$
ENDIF
CHECKCMD
ERASESMS
LOOP


'*********************************************
SUB ERASESMS
print #1, "AT+CMGDA = " + CHR$(34) + "DEL ALL" + CHR$(34)
PAUSE 200
GETSTRING
END SUB

'**********************************************
sub FLUSHBUF
PAUSE 100
DO:A$=INPUT$(1,#1):LOOP WHILE LOC(#1) <> 0
END SUB

'**********************************************
SUB GETSTRING
SMS$=""
PAUSE 200
DO
S$=INPUT$(1,#1)
SMS$=SMS$ + S$
LOOP WHILE LOC(#1) > 0
PRINT "GETSTRING = ";SMS$
END SUB

'***********************************************
SUB CHECKOK
IF INSTR(SMS$,"OK")<>0 THEN EXIT SUB
ERROR "MODEM NOT RESPONDING.... ENDING PROGRAM"
END SUB

'***********************************************
SUB CHECKNUM
GOODNUM = 0
B = INSTR(SMS$,"+1")+2
CHECKNUM$ = MID$(SMS$,B,10)
IF CHECKNUM$ = GOODNUM$ THEN GOODNUM = 1
END SUB

'************************************************
SUB CHECKCMD
IF INSTR(SMS$,"aon")<> 0 THEN
PIN(3)=1
PRINT "A IS NOW ON"
PRINT
REPLY$ = "HELLO MASTER... A IS NOW ON"
REPLYSMS REPLY$
EXIT SUB
ENDIF
IF INSTR(SMS$,"aoff")<> 0 then
PIN(3)=0
PRINT "A IS NOW OFF"
PRINT
REPLY$ = "HELLO MASTER... A IS NOW OFF"
REPLYSMS REPLY$
EXIT SUB
ENDIF
PRINT "COMMAND NOT RECOGNIZED"
PRINT
REPLY$ = "SORRY MASTER... COMMAND NOT RECOGNIZED"
REPLYSMS REPLY$
END SUB

'************************************************
SUB REPLYSMS REPLY$
print #1, "AT+CMGS=" + chr$(34) + CHECKNUM$ + chr$(34)
pause 200
GETSTRING
DO
IF INSTR(SMS$,CHR$(62))<>0 THEN EXIT DO 'RECEIVED ">"
LOOP
print #1, REPLY$
pause 200
GETSTRING
DO
IF INSTR(SMS$,CHR$(62))<>0 THEN EXIT DO 'RECEIVED ">"
LOOP
print #1, chr$(26) 'SEND CNTL Z TO SEND TEXT SMS
pause 5000 'WAIT FOR MODEM RESPONSE 5 SECONDS!!! WORKING ON THIS...
GETSTRING
DO
IF INSTR(SMS$,"+CMGS")<>0 THEN EXIT DO 'FINISHED SEND
LOOP
end SUB
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9081
Posted: 05:38pm 03 Jun 2014
Copy link to clipboard 
Print this post

Nice.

I too love the SIM900 module - it was so easy to get it going, for a start, I thought I must have done something wrong, cos it "Just worked"!!!

Was it you who linked me to the ElecFreaks SIM900 module?
I have a feeling it was.......

Cellphones and cell technology is so reliable these days, I am seriously thinking about dropping pagers in the my new system, in favour of cheap easily replaced cell-phones. You can get them as cheap as $20 new here now, and if all you need is a basic phone for it's text message ability, it's hard to beat $20 - especially when new pagers are still about $250 new, plus about $1000 for the transmitter, and $400 per year for the transmitter license....adds a-lot to the system cost.
Smoke makes things work. When the smoke gets out, it stops!
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 09:41pm 03 Jun 2014
Copy link to clipboard 
Print this post

Hi Grogster,

Yes, this is the elecfreaks sim900 module, and your are correct, it just works. One of my buddies bought several dozen of these and made a sms marketing machine that works really well. You just have to find a cheap cell plan and you can control anything from anywhere. We have the cheap phones too, however, finding unlimited text without data, even thought the sim900 can do data, is rare. The plan I found is $10.00 a month for 150 minutes, which if you are not using talk equates to 450 texts a month. Not to shabby.

Being able to do 2 way control and communication from anywhere in the world using a uMite is truly a lot of fun. I am actually using this in a vending machine which will report to the owner some sales status info. Another cool thing that can be done using this module is, if the vending customer has an issue, all he has to do is push a "live help" button, and the module will call the owners cell phone and a 2 way voice communication is activated using the external mic and speaker jacks on this module, again, all handled by uMite. Not to bad for $45.00 bucks.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9081
Posted: 03:25pm 04 Jun 2014
Copy link to clipboard 
Print this post

Yeah, I also bought another 5 of those SIM900 modules by ElecFreaks(via eBay), cos the first one worked so well.

I also have a fully commercial GSM terminal module, but they are $400 each or so, but do the same thing(has a Telit module in it). The $400 module does have RS232 and a 9-pin D socket on-board, but in my case, I needed TTL anyway, to use an MCU to talk to it, so the ElecFreaks modules were exactly what I needed, at exactly the right price.

I was delighted when I found these things - was it you who linked me to them?

Smoke makes things work. When the smoke gets out, it stops!
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 04:46pm 04 Jun 2014
Copy link to clipboard 
Print this post

Hi Grogster,

Yes, a while back we discussed this module. I am glad you are as happy with it as I am. Which commercial GSM terminal module did you buy for $400 and what do you use them for? Just curious...
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9081
Posted: 05:17pm 04 Jun 2014
Copy link to clipboard 
Print this post

It is a Contrive GsmTerminal-232 unit.

I only every bought one at that price.

The plan was always to find an alternative to pagers, cos paging is 30 year old technology now, and very expensive - they always have been though.

It's a big expense using pagers, and they are no less or more reliable then text messaging these days. That was not always true - text messaging used to have a few failures, but now that we are up a few more generations of cellphone technology, I can't remember EVER losing or not getting a text message in the last few years.

The only disadvantage of cellphones, is that you have to send the same message to several different phones, if you are using more then one, cos cellphones don't support group-calling, at least, not that I can find anyway. With pagers, generally speaking, you setup the frequency, baud-rate(usually 512), and RIC codes the same on all pagers, and anytime there is a page, ALL the pagers respond to the same message, which is handy if you have staff in different areas.

I will have to run some tests, but it may not be that drastic a delay to forward the message to several cellphones, but group-calling pagers is a nice thirty-year old concept...
Smoke makes things work. When the smoke gets out, it stops!
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 01:53pm 08 Jun 2014
Copy link to clipboard 
Print this post

Hi Grogster, have you tried to use DTMF with the sim900 module? Like calling it and using DTMF to control anything, or just SMS?
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9081
Posted: 02:59pm 08 Jun 2014
Copy link to clipboard 
Print this post

Just SMS. DTMF could come in handy, but it is not high on my to-do pile with the module at the current time. Nevertheless, I would be interested to hear your experiences if you are playing with DTMF.
Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024