1

As I was using pigpio ,so that I can use the GPIO pins as UART or bit banging the serial. I am using a SIM900 gsm module. Here is the code:

import pigpio
import time
import sys

TX=23
RX=18
baudrate=9600
bytesize=8

try:
    pi = pigpio.pi()
    pi.set_mode(RX, pigpio.INPUT)
    pi.set_mode(TX, pigpio.OUTPUT)

    pi.exceptions=False
    pi.bb_serial_read_close(RX)
    pi.exceptions=True

    pi.bb_serial_read_open(RX, baudrate, bytesize)

    pi.wave_add_new()
    pi.wave_add_serial(TX,9600,'AT\r',8)
    wid = pi.wave_create()
    pi.wave_send_once(wid)
    pi.wave_delete(wid)
    (count, data) = pi.bb_serial_read(RX)
    if count:
        print data
    time.sleep(1.5)

    pi.wave_add_new()
    pi.wave_add_serial(TX,9600,'AT+CPIN?\r',8)
    wid = pi.wave_create()
    pi.wave_send_once(wid)
    pi.wave_delete(wid)
    (count, data) = pi.bb_serial_read(RX)
    if count:
        print data
    time.sleep(1.5)

    pi.wave_add_new()
    pi.wave_add_serial(TX,9600,'AT+CIPSHUT\r',8)
    wid = pi.wave_create()
    pi.wave_send_once(wid)
    pi.wave_delete(wid)
    (count, data) = pi.bb_serial_read(RX)
    if count:
        print data
    time.sleep(1.5)

    pi.wave_add_new()
    pi.wave_add_serial(TX,9600,"AT+CIPMUX=0\r",8)
    wid = pi.wave_create()
    pi.wave_send_once(wid)
    pi.wave_delete(wid)
    (count, data) = pi.bb_serial_read(RX)
    if count:
        print data
    time.sleep(1.5)

    pi.wave_add_new()
    pi.wave_add_serial(TX,9600,"AT+CGATT=1\r",8)
    wid = pi.wave_create()
    pi.wave_send_once(wid)
    pi.wave_delete(wid)
    (count, data) = pi.bb_serial_read(RX)
    if count:
        print data + '\n'
    time.sleep(1.5)

    pi.wave_add_new()
    pi.wave_add_serial(TX,9600,"AT\r",8)
    wid = pi.wave_create()
    pi.wave_send_once(wid)
    pi.wave_delete(wid)
    (count, data) = pi.bb_serial_read(RX)
    if count:
        print data
    time.sleep(1.5)

except:
    pi.bb_serial_read_close(RX)
    pi.stop()

I think the problem is with the delay of outputting.

output is :

>>> 
AT

OK

AT+CPIN?

+CPIN: READY

OK

AT+CIPSHUT

SHUT OK

AT+CIPMUX=0

OK


AT+CGATT=1

OK

>>> 

it skips the last AT command which is a simple "AT"(even if I delete that command, all in the last command will not be displayed). Can someone help me?.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.