Recieving Blank SMS SIM800 using AT Commands and Python on Raspberry Pi 2
Asked Answered
A

2

4

I created this python script on rpi2, the message goes through, but it is a blank message. Is it a encoding issue?

import serial
import time
from sys import version_info
from curses import ascii
phone = serial.Serial("/dev/ttyAMA0", 115200, timeout=0.5)
def send_text(number,message):    
    phone.write(b'AT+CMGF=1\r')
    phone.write(b'AT+CMGS="' + number.encode() + b'"\r')
    phone.write(message.encode())
    phone.write(ascii.ctrl('z'))
    for i in range(len(reply)):
        reply[i] = reply[i].rstrip()
    print reply

AT commands (where 0000000000 is a 10 digit mobile number) in Minicom, still blank message

minicom -D /dev/ttyAMA0 -b 115200 -o

AT
OK
AT+CMGS="0000000000"
>Hello
 <ctrl-z>
+CMGS: 14
OK

Screenshot of Message from GSM Module

Antimonic answered 1/7, 2016 at 13:29 Comment(2)
You are properly terminating the AT command line correctly with \r, good. But you should never, never, ever use sleep as a substitute for waiting for the Final result code from the modem. See this answer for details. Without fixing that you will never get any of your AT command code to behave reliably.Celiotomy
Ya thanks for that! Ill fix that code! Though the above problem was solved by this AT command AT+CSMP=17,167,0,0Antimonic
A
3

There was an issue with the text mode parameters. The AT command below fixed it -

AT+CSMP=17,167,0,0

--info about it
AT+CSMP=<fo>,<vp>,<pid>,<dcs>
<fo>=17 Sets reply pat, user data header, status report request, validity period format, reject duplicates and message type.
<vp>=167 Sets validity period.
<pid>=0 Higher layer protocol indicator.
<dcs>=0 Information encode format.
OK Modem Response.
Antimonic answered 1/7, 2016 at 17:14 Comment(2)
Hi, what CSCS setting was used with this? I tried this, but it didn't work for me. This works if I send the data from a serial port utility, but not from the device firmware (Texas Instrument Launchpad).Abundance
Thank you mate .. your answer helped me in another issue rather than the question it self. ^_^Reprieve
H
0

AT+CSMP=17,167,0,0

Parameters Depending on the command or result code: first octet of GSM 03.40 SMS-DELIVER, SMS-SUBMIT (default 17),

SMS-STATUS-REPORT, or SMS-COMMAND (default 2) an integer format. SMS status report is supported under text mode if is set to 49.

Depending on SMS-SUBMIT setting: GSM 03.40 TP-Validity-Period either in integer format (default 167) or in time-string format (refer )

GSM 03.40 TP-Protocol-Identifier in integer format (default 0).

GSM 03.38 SMS Data Coding Scheme in Integer format.

Hierolatry answered 24/12, 2019 at 11:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.