Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] Send message using sim300 and picbasic - from a numberpicked from eeprom memory

Status
Not open for further replies.

alokdaga

Member level 2
Joined
Feb 10, 2011
Messages
44
Helped
9
Reputation
18
Reaction score
9
Trophy points
1,288
Activity points
1,479
I can send message normally using the following code

Code:
HSerout ["AT+CMGS=",34,"+91##########",34,13] 
HSERIN 5000 , error, [WAIT(">")]	
HSEROUT[ "Message" ,10,13]
HSEROUT[ 26] 
HSERIN 3000 , Error,[WAIT("+CMG")]
LCDout "OK"

How can I send message to a number which is stored from location 0 to 9 in eeprom

I tried storing value in variable N1 TO N9 respectively

HSerout ["AT+CMGS=",34,#N1,#N2,#N3,#N4,#N5,#N6,#N7,#N8,#N9,34,13]

This causes the sim300 to hang...
 
Last edited by a moderator:

You don't need to store the numbers in eeprom. Just store it in ROM memory and you can read it into RAM on startup before entering the super loop. It will be available all the time when PIC has power. Use a string variable or character array. in HSerialOut[] procedure call pass the variable (array) which holds the number.
 
Thanks for your suggestion... But my numbers are stored in eeprom only.... I can read them from eeprom into a variable and do... I tried sending the numbers one by one also in a loop but it does not work... sim 300 hangs... Pl suggest ... PICBASIC pro does not support string variable I think....
 

See the attached code. I tested it in Proteus and it works fine. I saw eeprom example code at PBP website and wrote this code. Try adding more numbers to eeprom.
 

Attachments

  • SIM300 SMS SEND PBP.rar
    13.3 KB · Views: 95
thanks a lot. will try morning and let u know... :)
 

Try this code. Before Compiling change the four 10 digit mobile numbers in eeprom[] instruction.


Code - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
'****************************************************************
'*  Name    : gsmSim300.BAS                                      *
'*  Author  : Jayanth D                                         *
'*  Notice  : Copyright (c) 2014 Power Tech                     *
'*          : All Rights Reserved                               *
'*  Date    : 3/23/2014                                         *
'*  Version : 1.0                                               *
'*  Notes   :                                                   *
'*          :                                                   *
'****************************************************************
INCLUDE "modedefs.BAS"
 
DEFINE OSC 4
 
DEFINE HSER_TXSTA 24h
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 9615
DEFINE HSER_CLROERR 1
DEFINE HSER_SPBRG  25                 
 
mobileNo var byte[$B]
InnerIndex var byte
OuterIndex var byte
NumberStartIndex var byte
 
TRISC = %10000000
PORTC = $0
 
EEPROM ["9742453836123456789009876543210011223344"]
'EEPROM ["9742453836",0,"1234567890",0,"09876543210",0,"011223344",0]
 
start: 
              
mainloop: 
      
SendAT:
      
      HSEROUT ["AT",13,10]
      HSERIN 1000,SendAT,[WAIT("OK")]
      pause 2000
            
SendATCMGF:
          
      HSerout ["AT+CMGF=1",13,10]
      HSERIN 1000,SendATCMGF,[WAIT("OK")]      
      pause 2000
      
      NumberStartIndex = 0
       
       for OuterIndex = 0 to 3 
            for InnerIndex = NumberStartIndex to (NumberStartIndex + 9)
                    if (NumberStartIndex >= 0) and (NumberStartIndex <= 9) then
                        Read InnerIndex, mobileNo[InnerIndex]
                    elseif (NumberStartIndex >= 10) and (NumberStartIndex <= 19) then
                        Read InnerIndex, mobileNo[InnerIndex - $A]
                    elseif (NumberStartIndex >= 20) and (NumberStartIndex <= 29) then
                        Read InnerIndex, mobileNo[InnerIndex - $14]
                    elseif (NumberStartIndex >= 30) and (NumberStartIndex <= 39) then
                        Read InnerIndex, mobileNo[InnerIndex - $1E]
                    endif
                                        
                    pause 50
            next InnerIndex 
            
            mobileNo[$A] = 0      
                 
            HSerout ["AT+CMGS=",$22,Str mobileNo,$22,13,10]
                             
            HSERIN 10000,SendAT,[WAIT(">")]
            HSEROUT["SMS from SIM 300", $1A]
            HSERIN 10000,SendAT,[WAIT("OK")]
            
            LCDout "OK"
      
            pause 4000
            
            NumberStartIndex = NumberStartIndex + $A
            
       next OuterIndex     
 
      GOTO mainloop
 
      END

 
tried... not working - loops out to sendAT
 

From where? After sending AT+CMGS="...?

It worked for me in Proteus. I have used PIC16F877A @ 4 MHz external clock. Change it to your MCU and clock.

Edit: Increase SerIn Timeout and delays and try.
 
Last edited:
It worked - .. thanks for your help.... I was using HSerout ["AT+CMGS=",34] instead of which I used HSerout ["AT+CMGS=",$22]
Thanks a lot
 

Decimal 34 and 0x22 are the same. It is ASCII char for double quotes. The versions with 34 and $22 both works for me.
 

But in mine it does not - 34 does not work and $22 works !! Even I am stumped...
 

Zip and post the code which doesn't work if 34 is used. I will test it.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top