isan98
Posts: 19
Joined: Sun May 14, 2017 6:36 am

How to connecting GSM module to the internet and sending sms at same time with raspberry pi

Sat Nov 10, 2018 5:34 pm

I installed sakis3g packet and use it for connect pi3 to the internet on /dev/serial0 with sim800l GSM module
And I use this code to send sms :

Code: Select all

import serial
import RPi.GPIO as GPIO
import os, time

GPIO.setmode(GPIO.BOARD)

# Enable Serial Communication
port = serial.Serial("/dev/serial0", baudrate=9600, timeout=1)

# Transmitting AT Commands to the Modem
# '\r\n' indicates the Enter key

port.write('AT'+'\r\n')
rcv = port.read(10)
print rcv
time.sleep(5)

port.write('ATE0'+'\r\n')      # Disable the Echo
rcv = port.read(10)
print rcv
time.sleep(5)

port.write('AT+CMGF=1'+'\r\n')  # Select Message format as Text mode
rcv = port.read(10)
print rcv
time.sleep(5)

port.write('AT+CNMI=2,1,0,0,0'+'\r\n')   # New SMS Message Indications
rcv = port.read(10)
print rcv
time.sleep(5)

port.write('AT+CSCS="GSM"'+'\r\n')   # New SMS Message Indications
rcv = port.read(10)
print rcv
time.sleep(5)


# Sending a message to a particular Number
port.write('AT+CMGS="+5432567899"'+'\r\n')
rcv = port.read(10)
print rcv
time.sleep(5)

port.write('Hello User'+'\r\n')  # Message
rcv = port.read(10)
print rcv

port.write("\x1A") # Enable to send SMS
for i in range(10):
    rcv = port.read(10)
    print rcv


IT'S OK when the module is not connected to the Internet,
But I want to send SMS when the module is connected to the Internet, actually sending SMS and connecting to the Internet at the same time.
Serial port is busy because of Internet connection, so how can I to do this?

Andyroo
Posts: 433
Joined: Sat Jun 16, 2018 12:49 am
Location: Side of the hill in Lincolnshire

Re: How to connecting GSM module to the internet and sending sms at same time with raspberry pi

Sat Nov 10, 2018 6:07 pm

That would make sense as the SMS message uses GSM and does not use an internet connection (GPRS) and the chipset either delivers SMS or Internet as the data stream over the serial port.

The simplest way of sending SMS messages while connected is to use a third party to convert emails to text messages.

You may be able to configure a second serial port through the USB if provided but as a guess you are looking to multiplex the data streams over one serial line and I see this chip does support multiplexing. Unfortunately this is not a module I have used so I’m a bit stuck there.
Need Pi spray - these things are breeding in my house...

Andyroo
Posts: 433
Joined: Sat Jun 16, 2018 12:49 am
Location: Side of the hill in Lincolnshire

Re: How to connecting GSM module to the internet and sending sms at same time with raspberry pi

Sat Nov 10, 2018 6:16 pm

Ignore what I said about the USB port - looks like it’s for debug use only as per https://drive.google.com/file/d/0B7t_g4 ... hXRDg/view

Also I hate the use of two wire serial as this supports full handshaking but it’s disabled by default :o

You may want to have a look at the ring line details if you want to receive texts as well as send them - it’s a neat way of telling voice from texts!
Need Pi spray - these things are breeding in my house...

isan98
Posts: 19
Joined: Sun May 14, 2017 6:36 am

Re: How to connecting GSM module to the internet and sending sms at same time with raspberry pi

Sat Nov 10, 2018 6:41 pm

Andyroo wrote:
Sat Nov 10, 2018 6:16 pm
Ignore what I said about the USB port - looks like it’s for debug use only as per https://drive.google.com/file/d/0B7t_g4 ... hXRDg/view

Also I hate the use of two wire serial as this supports full handshaking but it’s disabled by default :o

You may want to have a look at the ring line details if you want to receive texts as well as send them - it’s a neat way of telling voice from texts!
what is the ring line details?

Andyroo
Posts: 433
Joined: Sat Jun 16, 2018 12:49 am
Location: Side of the hill in Lincolnshire

Re: How to connecting GSM module to the internet and sending sms at same time with raspberry pi

Sat Nov 10, 2018 6:48 pm

Page 35 and 36 of the above linked document show you how the RI lines tells you if it’s voice or SMS comming in.

It will not help you sending SMS while connected to the internet.
Need Pi spray - these things are breeding in my house...

isan98
Posts: 19
Joined: Sun May 14, 2017 6:36 am

Re: How to connecting GSM module to the internet and sending sms at same time with raspberry pi

Sat Nov 10, 2018 7:07 pm

Andyroo wrote:
Sat Nov 10, 2018 6:48 pm
Page 35 and 36 of the above linked document show you how the RI lines tells you if it’s voice or SMS comming in.

It will not help you sending SMS while connected to the internet.
yes I need to send sms while module connected to the internet.

Andyroo
Posts: 433
Joined: Sat Jun 16, 2018 12:49 am
Location: Side of the hill in Lincolnshire

Re: How to connecting GSM module to the internet and sending sms at same time with raspberry pi

Sat Nov 10, 2018 10:33 pm

Then have a look at Text Anywhere or ITTT style services else:

1) I think you are going to have to dig up the manual on multiplexing and write a pig of a routine
2) Drop the internet connection for a short while, send the text and re-connect
3) Look at modules that could do both at once
Need Pi spray - these things are breeding in my house...

Return to “General discussion”