Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Sending SMS via GSMshield (icomsat v1.1)...return error

Icomsat v1.1 GSMshield SMS

  • Please log in to reply
6 replies to this topic

#1 Fahdil

Fahdil

    Advanced Member

  • Members
  • PipPipPip
  • 59 posts
  • LocationJakarta, Indonesia

Posted 10 September 2013 - 01:14 AM

Hi Guys

 

lately I'm try to send SMS via GSMshield (using UART port Com1), but I dont know why it always return error as result (the SMS never sent). Can anybody help me to find the way out... :wacko:

Public Class GSM_UART_serial        Private Shared GSM_UART As SerialPort        Private Shared Respons As String        Private Shared bytesTosend As Byte()        Private Shared SendingSMS As Boolean        Public Shared Sub Main()            OnboardLed = New OutputPort(Pins.ONBOARD_LED, False)            D9 = New OutputPort(Pins.GPIO_PIN_D9, False)            SendingSMS = False            D9.Write(True)            Thread.Sleep(500)            D9.Write(False)            GSM_UART = New SerialPort("COM1", 9600, Parity.None, 8, StopBits.One)            AddHandler GSM_UART.DataReceived, New SerialDataReceivedEventHandler(AddressOf RecieveData)            If GSM_UART.IsOpen = False Then                GSM_UART.Open()                Debug.Print("Port Opening" & " : at baudRate= " & GSM_UART.BaudRate)            Else                Debug.Print("Port is ready...")            End If            SendingSMS = True            While SendingSMS = True                Thread.Sleep(250)                GSM_UART_dataWrite("AT+CMGF=1" & vbCr)                Thread.Sleep(250)                GSM_UART_dataWrite("ATE" & vbCr)                Thread.Sleep(250)                GSM_UART_dataWrite("AT+CMGS=")                Thread.Sleep(250)                GSM_UART.WriteByte(34)                GSM_UART_dataWrite("085218877358")                GSM_UART.WriteByte(34)                GSM_UART_dataWrite("" & vbCr)                Thread.Sleep(250)                GSM_UART_dataWrite("Body Massage being so good" & vbCr)                Thread.Sleep(250)                GSM_UART_dataWrite("x1A" & vbCr)                Thread.Sleep(1000)                SendingSMS = False            End While            Debug.Print(Respons & "?")            Thread.Sleep(Timeout.Infinite)        End Sub                Private Shared Sub GSM_UART_dataWrite(ByVal Command As String)            bytesTosend = Encoding.UTF8.GetBytes(Command)            Debug.Print("Send port : " & Command)            GSM_UART.Write(bytesTosend, 0, bytesTosend.Length)            Debug.Print("Port is writing...")        End Sub	    Private Shared Sub RecieveData(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs)		    Dim Length As Integer = GSM_UART.BytesToRead		    Dim bufferData As Byte() = New Byte(Length - 1) {}		    GSM_UART.Read(bufferData, 0, Length)		    Respons += New String(Encoding.UTF8.GetChars(bufferData))		    If Respons.IndexOf(vbLf) >= 0 Then			    Respons = Respons.Trim()			    If Respons <> "" Then				    OnboardLed.Write(state:=True)				    Debug.Print(Respons)			    End If			    Respons = ""			    If Respons = "" Then				    OnboardLed.Write(state:=False)				    Debug.Print(Respons)			    End If		    End If	    End Subend class

very appreciate for your help

 

Best Regards



#2 Fahdil

Fahdil

    Advanced Member

  • Members
  • PipPipPip
  • 59 posts
  • LocationJakarta, Indonesia

Posted 10 September 2013 - 04:54 AM

I little bit better... but still error..... after I modified the code like this, it's going better, the error comes after Ctrl-z. so I think, I need to know how to send Ctrl-Z  (0x1A)... I try to use GSM_UART.writebyte(0x1A) it doesnt work either.

 While SendingSMS = True                Thread.Sleep(250)                GSM_UART_dataWrite("AT+CMGS=")                Thread.Sleep(250)                GSM_UART.WriteByte(34)                GSM_UART_dataWrite("085218877358")                GSM_UART.WriteByte(34)                GSM_UART_dataWrite("" & vbLf)                Thread.Sleep(500)                GSM_UART_dataWrite("Body Massage being so good")                Thread.Sleep(250)                GSM_UART_dataWrite("0x1A" & vbCr)                Thread.Sleep(1000)                                SendingSMS = False            End While


#3 JoopC

JoopC

    Advanced Member

  • Members
  • PipPipPip
  • 148 posts

Posted 10 September 2013 - 12:00 PM

Your problem is the syntax of converting hex 0x1A is in Visual Basic &H1A   0x = &H



#4 Nighthawk

Nighthawk

    Member

  • Members
  • PipPip
  • 21 posts

Posted 10 September 2013 - 01:26 PM

Please note that after powering on the SIM900 (using pin D9), you need to WAIT till you get a "CALL READY" message before using any commands that use the SIM card. It is written in the IComSat manual.

 

This usually happens around 7-10 seconds after powering up the SIM900.



#5 Nighthawk

Nighthawk

    Member

  • Members
  • PipPip
  • 21 posts

Posted 10 September 2013 - 01:29 PM

Also, I'm not 100% sure about this, but I believe you need to send Carriage Return AND Line Feed (vbCrLf) over the serial connection. 



#6 Fahdil

Fahdil

    Advanced Member

  • Members
  • PipPipPip
  • 59 posts
  • LocationJakarta, Indonesia

Posted 28 January 2014 - 06:55 AM

it's done... and I adopt this class....

 

thx to forum

 

*edit

note for Icomsat v1.1:

 

you have to set up the serial :

baudrate : 9600 (up to 57000 see sim900 datasheet for details)

parity : none (seedstudio GSM sheild using parity.odd) 

dataBits = 8

stopBits = One

 

for Netduino Compatibility :

 

you have to set Pin D8 to Low. I dont know why but if it's still on High, powering the GSM shield via pin 9 (send High fo 500ms) wont work.

 

cheers

Attached Files



#7 Fahdil

Fahdil

    Advanced Member

  • Members
  • PipPipPip
  • 59 posts
  • LocationJakarta, Indonesia

Posted 03 February 2014 - 06:55 AM

next to try:

 

How to use IcomSat v1.1 as fax modem...







Also tagged with one or more of these keywords: Icomsat v1.1, GSMshield, SMS

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.