Receiving "NO CARRIER" error while tring to make a call using GSM modem in Python
Asked Answered
I

2

18

I want to make a call using my GSM modem. So I wrote the below program:

import time
import serial

recipient = "+98xxxxxxxxxx"

phone = serial.Serial("COM10",  115200, timeout=5)
try:
    time.sleep(0.5)
    phone.write(b'ATZ\r')
    time.sleep(1)
    phone.write(b'ATD"'+recipient.encode() +b'"\r')
    while(1):
        print(phone.readline())
    time.sleep(0.5)
finally:
    phone.close()

But when I run it I receive this output:

>>> ================================ RESTART ================================
>>> 
b'ATZ\r\r\n'
b'OK\r\n'
b'ATDxxxxxxxxxx\r\r\n'
b'NO CARRIER\r\n'

What does this "NO CARRIER" error means?

Note that I can send SMS successfully.


This is the program that I use to send SMS:

import time
import serial

recipient = "+98xxxxxxxxxx"
message = "Test"

phone = serial.Serial("COM10",  115200, timeout=5)


try:
    time.sleep(0.5)
    phone.write(b'ATZ\r')
    time.sleep(0.5)
    phone.write(b'AT+CMGF=1\r')
    time.sleep(0.5)
    phone.write(b'AT+CMGS="' + recipient.encode() + b'"\r')
    time.sleep(0.5)
    phone.write(message.encode() + b"\r")
    time.sleep(0.5)
    phone.write(bytes([26]))
    time.sleep(0.5)
finally:
    phone.close()
Inness answered 20/6, 2015 at 8:44 Comment(1)
Can you post your SMS sending code? I'm pretty sure I know what's happeningShaky
I
39

I found the origin of the error :

The syntax is ATD+98xxxxxxxxxx; followed by terminating string. I was forgotten to put semicolon at the end after the number.

So I replace

phone.write(b'ATD"'+recipient.encode() +b'"\r')

with

phone.write(b'ATD"'+recipient.encode() +b';"\r')

And now it works fine.


Based on the brackets in this documents, I thought that using ";" is optional. But it seems that I was wrong. enter image description here

Inness answered 20/6, 2015 at 9:53 Comment(6)
Personally I would use: phone.write(b'ATD"%s";\r' % recipient.encode()) as being clearer what is going on and a little more compact.Yoruba
For completeness regarding the semicolon: The ATD command has a L modifier that makes the modem dial the last dialed number. So if you first start a data call with ATD1234 then you can after that call ends give ATDL to set up a new data call to the same number. The not so obvious issue here is for voice calls. If you first set up a voice call with ATD1234; then just giving ATDL will set up a data call to number 1234, so the modem only reuses the number and not the type of the call. If you want to repeat a voice call you have to give ATDL; with a semicolon at the end.Aerophone
@Aerophone thank you dear friend. May I ask you to say me what's the difference between a voice call and a data call? Can I initiate a data call using a dial up modem also, or it is for GSM modems only?Inness
Hi nlovdal, I have "NO CARRIER" error with command ATD+39**********; . SIM is unlocked (AT+CPIN? returns READY), the signal quality is OK (AT+CSQ returns 9,3) and It's registered properly to a network (AT+COPS? returns 0,0,"vodafone IT",2). Any suggestion to fix the issue?Vinitavinn
@Vinitavinn me too getting the same error. did u found the answer ?Devindevina
I have found that getting NO CARRIER could also mean that you don't have any airtime left to dial.Acrocarpous
P
1

I had the same issue and ill tell you

Its all because of a semicolun

If you're using direct connection like me (UART, serial monitor)

Use semicolon

Ex: ATD+91xxxxxxxxxx;

This will solve NO CARRIER issue as i was able to send sms recieve sms and recieve calls Stil persist its because of signal 😇

Pairs answered 4/2 at 11:33 Comment(1)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewInconsequential

© 2022 - 2024 — McMap. All rights reserved.