I have a Raspberry Pi 3 running Raspbian Stretch I've connected it to an Elemnt Engineerz Guild SIM900a GSM modem via the GPIO. I can't get it to send an SMS
- I connected gnd and 5v to gnd and 5v respectively between the Pi and the modem
- I connected pin 14 on the Pi to Rx on the modem
- I connected pin 15 on the pi to Tx on the modem
I have the interface tab of Pi Configuration like this:
Serial Port -> on Serial Console -> off
/boot/config.txt file includes these two lines:
ls -l /dev | grep serial returns
lrwxrwxrwx 1 root root 7 Aug 8 15:31 serial0 -> ttyAMA0 lrwxrwxrwx 1 root root 5 Aug 8 15:31 serial1 -> ttyS0
This is my python code:
#!/usr/bin/env python import serial import os, time ser = serial.Serial( port = '/dev/serial0', baudrate = 9600, timeout = 1 ) print('disabling echo') ser.write(str.encode('ATE0\r')) print(ser.readline()) print(ser.readline()) time.sleep(1) print('text format for messages') ser.write(str.encode('AT+CMGF=1\r')) print(ser.readline()) print(ser.readline()) time.sleep(1) print('send text message') ser.write(str.encode('AT+CMGS="XXXXXXXXXX"\ntest message\r')) print(ser.readline()) print(ser.readline()) ser.close()
I put my phone number where the X's are
And this is the output:
disabling echo b'ATE0\r\r\n' b'OK\r\n' text format for messages b'\r\n' b'OK\r\n' send text message b'\r\n' b'ERROR\r\n'
I really need to get this sending SMS messages, but the messages don't go through. The response is an error and when I've tried doing this sort of thing from the terminal I've got error code 3, which means operation not allowed. I've put the SIM into my phone and used it to send an SMS successfully. So why am I getting error 3 for sending SMS?